GroupsController.cs 1.3 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438
  1. using Aspose.Cells;
  2. using Aspose.Words;
  3. using Aspose.Words.Drawing;
  4. using Aspose.Words.Tables;
  5. using DiffMatchPatch;
  6. using Dm.util;
  7. using Humanizer;
  8. using Microsoft.AspNetCore.SignalR;
  9. using NPOI.SS.Formula.Functions;
  10. using NPOI.SS.UserModel;
  11. using NPOI.SS.Util;
  12. using NPOI.Util;
  13. using NPOI.XSSF.UserModel;
  14. using OASystem.API.Middlewares;
  15. using OASystem.API.OAMethodLib;
  16. using OASystem.API.OAMethodLib.APNs;
  17. using OASystem.API.OAMethodLib.DeepSeekAPI;
  18. using OASystem.API.OAMethodLib.File;
  19. using OASystem.API.OAMethodLib.Hub.HubClients;
  20. using OASystem.API.OAMethodLib.Hub.Hubs;
  21. using OASystem.API.OAMethodLib.JuHeAPI;
  22. using OASystem.API.OAMethodLib.KiMiApi;
  23. using OASystem.API.OAMethodLib.Logging;
  24. using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
  25. using OASystem.Domain.AesEncryption;
  26. using OASystem.Domain.Attributes;
  27. using OASystem.Domain.Dtos.CRM;
  28. using OASystem.Domain.Dtos.FileDto;
  29. using OASystem.Domain.Dtos.Financial;
  30. using OASystem.Domain.Dtos.Groups;
  31. using OASystem.Domain.Dtos.System;
  32. using OASystem.Domain.Entities.Customer;
  33. using OASystem.Domain.Entities.Financial;
  34. using OASystem.Domain.Entities.Groups;
  35. using OASystem.Domain.ViewModels.CRM;
  36. using OASystem.Domain.ViewModels.Financial;
  37. using OASystem.Domain.ViewModels.Groups;
  38. using OASystem.Domain.ViewModels.OCR;
  39. using OASystem.Domain.ViewModels.SmallFun;
  40. using OASystem.Infrastructure.Repositories.CRM;
  41. using OASystem.Infrastructure.Repositories.Financial;
  42. using OASystem.Infrastructure.Repositories.Groups;
  43. using Quartz.Logging;
  44. using Quartz.Util;
  45. using SQLitePCL;
  46. using SqlSugar.Extensions;
  47. using System.Collections;
  48. using System.ComponentModel.DataAnnotations;
  49. using System.Data;
  50. using System.Diagnostics;
  51. using System.Globalization;
  52. using System.IO;
  53. using System.IO.Compression;
  54. using System.Linq.Expressions;
  55. using System.Text.Json;
  56. using System.Text.RegularExpressions;
  57. using System.Threading.Tasks;
  58. using System.Web;
  59. using static OASystem.API.OAMethodLib.JWTHelper;
  60. using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
  61. using static OpenAI.GPT3.ObjectModels.SharedModels.IOpenAiModels;
  62. using Bookmark = Aspose.Words.Bookmark;
  63. using Cell = Aspose.Words.Tables.Cell;
  64. using Table = Aspose.Words.Tables.Table;
  65. namespace OASystem.API.Controllers
  66. {
  67. /// <summary>
  68. /// 团组相关
  69. /// </summary>
  70. //[Authorize]
  71. [Route("api/[controller]/[action]")]
  72. public class GroupsController : ControllerBase
  73. {
  74. private readonly ILogger<GroupsController> _logger;
  75. private readonly ITextFileLogger _eec_textLogger;
  76. private readonly IGroupTextFileLogger _groupTextLogger;
  77. private readonly GrpScheduleRepository _grpScheduleRep;
  78. private readonly IMapper _mapper;
  79. private readonly DelegationInfoRepository _groupRepository;
  80. private readonly TaskAssignmentRepository _taskAssignmentRep;
  81. private readonly AirTicketResRepository _airTicketResRep;
  82. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  83. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  84. private readonly DelegationEnDataRepository _delegationEnDataRep;
  85. private readonly DelegationVisaRepository _delegationVisaRep;
  86. private readonly VisaPriceRepository _visaPriceRep;
  87. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  88. private readonly HotelPriceRepository _hotelPriceRep;
  89. private readonly CustomersRepository _customersRep;
  90. private readonly MessageRepository _message;
  91. private readonly SqlSugarClient _sqlSugar;
  92. private readonly TourClientListRepository _tourClientListRep;
  93. private readonly TeamRateRepository _teamRateRep;
  94. #region 成本相关
  95. private readonly CheckBoxsRepository _checkBoxs;
  96. private readonly GroupCostRepository _GroupCostRepository;
  97. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  98. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  99. #endregion
  100. private readonly SetDataRepository _setDataRep;
  101. private string url;
  102. private string path;
  103. private readonly EnterExitCostRepository _enterExitCostRep;
  104. private readonly IHubContext<ChatHub, IChatClient> _hubContext;
  105. private readonly UsersRepository _usersRep;
  106. private readonly IJuHeApiService _juHeApi;
  107. private readonly InvertedListRepository _invertedListRep;
  108. private readonly VisaFeeInfoRepository _visaFeeInfoRep;
  109. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  110. private readonly ThreeCodeRepository _threeCodeRepository;
  111. private readonly HotelInquiryRepository _hotelInquiryRep;
  112. private readonly FeeAuditRepository _feeAuditRep;
  113. private readonly VisaCommissionRepository _visaCommissionRep;
  114. private readonly ForeignReceivablesRepository _ffrRep; //对外收款账单仓库
  115. private readonly OpinionaireRepository _opinionaireRep; //对外收款账单仓库
  116. private readonly List<CurrencyInfo> _currencyInit;
  117. private readonly List<int> _portTypeData;
  118. private readonly TableOperationRecordRepository _tableorRep;
  119. private readonly EnterExitCostDraftRepository _enterExitCostDraftRep;
  120. private readonly RestaurantRepository _restaurantRep;
  121. private readonly EnterExitCostQuoteRepository _enterExitCostQuoteRep;
  122. private readonly GroupOrderPreInfoRepository _grpOrderPreInfoRep;
  123. private readonly VisaProcessRepository _visaProcessRep;
  124. private readonly ProcessOverviewRepository _processOverviewRep;
  125. private readonly IDeepSeekService _deepSeekService;
  126. /// <summary>
  127. /// 初始化岗位对应负责的数据类型
  128. ///
  129. /// 岗位ID
  130. /// 24 机票、25 酒店、26 签证、27 商邀、28 OP
  131. ///
  132. /// 费用类型ID
  133. /// 76 酒店预订、79 车/导游地接、80 签证、81 邀请/公务活动、82 团组客户保险、85 机票预订、98 其他款项
  134. /// </summary>
  135. private readonly Dictionary<int, List<int>> _dataInit = new() {
  136. { 24, new List<int> { 85 } }, // 机票 -> 机票预订
  137. { 25, new List<int> { 76 } }, // 酒店 -> 酒店预订
  138. { 26, new List<int> { 80, 82 } }, // 签证 -> 签证, 团组客户保险
  139. { 27, new List<int> { 81 } }, // 地接专员 -> 邀请/公务活动
  140. { 28, new List<int> { 79 } } // 商邀 -> 车/导游地接
  141. };
  142. /// <summary>
  143. /// 构造函数
  144. /// </summary>
  145. /// <param name="logger"></param>
  146. /// <param name="eec_textLogger"></param>
  147. /// <param name="groupTextLogger"></param>
  148. /// <param name="mapper"></param>
  149. /// <param name="hubContext"></param>
  150. /// <param name="sqlSugar"></param>
  151. /// <param name="grpScheduleRep"></param>
  152. /// <param name="groupRepository"></param>
  153. /// <param name="taskAssignmentRep"></param>
  154. /// <param name="airTicketResRep"></param>
  155. /// <param name="decreasePaymentsRep"></param>
  156. /// <param name="InvitationOfficialActivitiesRep"></param>
  157. /// <param name="delegationEnDataRep"></param>
  158. /// <param name="enterExitCostRep"></param>
  159. /// <param name="delegationVisaRep"></param>
  160. /// <param name="message"></param>
  161. /// <param name="visaPriceRep"></param>
  162. /// <param name="carTouristGuideGroundRep"></param>
  163. /// <param name="checkBoxs"></param>
  164. /// <param name="GroupCostRepository"></param>
  165. /// <param name="CostTypeHotelNumberRepository"></param>
  166. /// <param name="GroupCostParameterRepository"></param>
  167. /// <param name="hotelPriceRep"></param>
  168. /// <param name="customersRep"></param>
  169. /// <param name="setDataRep"></param>
  170. /// <param name="tourClientListRep"></param>
  171. /// <param name="teamRateRep"></param>
  172. /// <param name="usersRep"></param>
  173. /// <param name="juHeApi"></param>
  174. /// <param name="invertedListRep"></param>
  175. /// <param name="visaFeeInfoRep"></param>
  176. /// <param name="ticketBlackCodeRep"></param>
  177. /// <param name="hotelInquiryRep"></param>
  178. /// <param name="threeCodeRepository"></param>
  179. /// <param name="feeAuditRep"></param>
  180. /// <param name="visaCommissionRep"></param>
  181. /// <param name="ffrRep"></param>
  182. /// <param name="opinionaireRep"></param>
  183. /// <param name="tableorRep"></param>
  184. /// <param name="enterExitCostDraftRep"></param>
  185. /// <param name="restaurantRep"></param>
  186. /// <param name="enterExitCostQuoteRep"></param>
  187. /// <param name="grpOrderPreInfoRep"></param>
  188. /// <param name="visaProcessRep"></param>
  189. /// <param name="processOverviewRep"></param>
  190. public GroupsController(
  191. ILogger<GroupsController> logger,
  192. ITextFileLogger eec_textLogger,
  193. IGroupTextFileLogger groupTextLogger,
  194. IMapper mapper,
  195. IHubContext<ChatHub, IChatClient> hubContext,
  196. SqlSugarClient sqlSugar,
  197. GrpScheduleRepository grpScheduleRep,
  198. DelegationInfoRepository groupRepository,
  199. TaskAssignmentRepository taskAssignmentRep,
  200. AirTicketResRepository airTicketResRep,
  201. DecreasePaymentsRepository decreasePaymentsRep,
  202. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep,
  203. DelegationEnDataRepository delegationEnDataRep,
  204. EnterExitCostRepository enterExitCostRep,
  205. DelegationVisaRepository delegationVisaRep,
  206. MessageRepository message,
  207. VisaPriceRepository visaPriceRep,
  208. CarTouristGuideGroundRepository carTouristGuideGroundRep,
  209. CheckBoxsRepository checkBoxs,
  210. GroupCostRepository GroupCostRepository,
  211. CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  212. GroupCostParameterRepository GroupCostParameterRepository,
  213. HotelPriceRepository hotelPriceRep,
  214. CustomersRepository customersRep,
  215. SetDataRepository setDataRep,
  216. TourClientListRepository tourClientListRep,
  217. TeamRateRepository teamRateRep,
  218. UsersRepository usersRep,
  219. IJuHeApiService juHeApi,
  220. InvertedListRepository invertedListRep,
  221. VisaFeeInfoRepository visaFeeInfoRep,
  222. TicketBlackCodeRepository ticketBlackCodeRep,
  223. HotelInquiryRepository hotelInquiryRep,
  224. ThreeCodeRepository threeCodeRepository,
  225. FeeAuditRepository feeAuditRep,
  226. VisaCommissionRepository visaCommissionRep,
  227. ForeignReceivablesRepository ffrRep,
  228. OpinionaireRepository opinionaireRep,
  229. TableOperationRecordRepository tableorRep,
  230. EnterExitCostDraftRepository enterExitCostDraftRep,
  231. RestaurantRepository restaurantRep,
  232. EnterExitCostQuoteRepository enterExitCostQuoteRep,
  233. GroupOrderPreInfoRepository grpOrderPreInfoRep,
  234. VisaProcessRepository visaProcessRep,
  235. ProcessOverviewRepository processOverviewRep
  236. )
  237. {
  238. _logger = logger;
  239. _eec_textLogger = eec_textLogger;
  240. _groupTextLogger = groupTextLogger;
  241. _mapper = mapper;
  242. _grpScheduleRep = grpScheduleRep;
  243. _groupRepository = groupRepository;
  244. _taskAssignmentRep = taskAssignmentRep;
  245. _airTicketResRep = airTicketResRep;
  246. _sqlSugar = sqlSugar;
  247. url = AppSettingsHelper.Get("ExcelBaseUrl");
  248. path = AppSettingsHelper.Get("ExcelBasePath");
  249. if (!System.IO.Directory.Exists(path))
  250. {
  251. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  252. }
  253. _decreasePaymentsRep = decreasePaymentsRep;
  254. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  255. _delegationEnDataRep = delegationEnDataRep;
  256. _enterExitCostRep = enterExitCostRep;
  257. _delegationVisaRep = delegationVisaRep;
  258. _message = message;
  259. _visaPriceRep = visaPriceRep;
  260. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  261. _checkBoxs = checkBoxs;
  262. _GroupCostRepository = GroupCostRepository;
  263. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  264. _GroupCostParameterRepository = GroupCostParameterRepository;
  265. _hotelPriceRep = hotelPriceRep;
  266. _customersRep = customersRep;
  267. _setDataRep = setDataRep;
  268. _tourClientListRep = tourClientListRep;
  269. _teamRateRep = teamRateRep;
  270. _hubContext = hubContext;
  271. _usersRep = usersRep;
  272. _juHeApi = juHeApi;
  273. _invertedListRep = invertedListRep;
  274. _visaFeeInfoRep = visaFeeInfoRep;
  275. _ticketBlackCodeRep = ticketBlackCodeRep;
  276. _hotelInquiryRep = hotelInquiryRep;
  277. _threeCodeRepository = threeCodeRepository;
  278. _feeAuditRep = feeAuditRep;
  279. _visaCommissionRep = visaCommissionRep;
  280. _ffrRep = ffrRep;
  281. _opinionaireRep = opinionaireRep;
  282. _currencyInit = new List<CurrencyInfo>()
  283. {
  284. new(){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  285. new(){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  286. new(){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  287. new(){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  288. new(){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  289. };
  290. _portTypeData = new List<int>() { 2, 3 };
  291. _tableorRep = tableorRep;
  292. _enterExitCostDraftRep = enterExitCostDraftRep;
  293. _restaurantRep = restaurantRep;
  294. _enterExitCostQuoteRep = enterExitCostQuoteRep;
  295. _grpOrderPreInfoRep = grpOrderPreInfoRep;
  296. _visaProcessRep = visaProcessRep;
  297. _processOverviewRep = processOverviewRep;
  298. }
  299. #region 页面加载弹窗信息
  300. /// <summary>
  301. /// 提示用户录入团组费用信息
  302. /// 根据用户ID获取分配权限内团组名称
  303. /// </summary>
  304. /// <param name="currUserId">用户Id</param>
  305. /// <param name="daysAgo">往前推的天数</param>
  306. /// <returns></returns>
  307. [HttpGet]
  308. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  309. public async Task<IActionResult> GetGroupNamesByUserId(int currUserId, int daysAgo = 5)
  310. {
  311. var stopwatch = Stopwatch.StartNew();
  312. var userInfo = await _sqlSugar.Queryable<Sys_Users>()
  313. .Where(x => x.Id == currUserId && x.IsDel == 0)
  314. .Select(x => new { x.Id, x.JobPostId, x.CnName })
  315. .FirstAsync();
  316. if (userInfo == null)
  317. {
  318. return Ok(JsonView(false, "用户不存在或已被禁用!"));
  319. }
  320. var jobId = userInfo.JobPostId;
  321. var feeTypeIds = new List<int>() { };
  322. if (_dataInit.TryGetValue(jobId, out var values))
  323. {
  324. feeTypeIds = values;
  325. }
  326. /*
  327. * 获取今天时间往前推5天查询团组c表里有没有费用
  328. */
  329. var today_startDate = DateTime.Now.Date.AddDays(-daysAgo);
  330. //var today_endDate = DateTime.Now.Date.AddDays(-daysAgo).AddDays(1).AddSeconds(-1);
  331. var today_endDate = DateTime.Now.Date.AddDays(1).AddSeconds(-1);
  332. var groupNames = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  333. .Where(di => di.IsDel == 0)
  334. .Where(di => di.VisitDate >= today_startDate && di.VisitDate <= today_endDate)
  335. // 存在任务分配记录
  336. .Where(di => SqlFunc.Subqueryable<Grp_GroupsTaskAssignment>()
  337. .Where(gta => gta.DIId == di.Id && gta.IsDel == 0 && feeTypeIds.Contains(gta.CTId))
  338. .Any())
  339. // 不存在费用记录
  340. .Where(di => !SqlFunc.Subqueryable<Grp_CreditCardPayment>()
  341. .Where(ccp => ccp.DIId == di.Id && ccp.IsDel == 0 && feeTypeIds.Contains(ccp.CTable))
  342. .Any())
  343. // 新增条件:不在确认记录表中(排除已确认的团组)
  344. .Where(di => !SqlFunc.Subqueryable<Grp_FeeEntryAcknowledge>()
  345. .Where(ack => ack.GroupId == di.Id && ack.IsDel == 0 && ack.UserId == currUserId)
  346. .Where(ack => feeTypeIds.Contains(ack.FeeTypeId))
  347. .Where(ack => ack.IsAcknowledged == AcknowledgeStatusEnum.Acknowledged) // 只排除已确认的记录
  348. .Any())
  349. .Select(di => new
  350. {
  351. di.Id,
  352. di.TeamName,
  353. di.VisitDate
  354. })
  355. .OrderBy(di => di.VisitDate)
  356. .ToListAsync();
  357. stopwatch.Stop();
  358. return Ok(JsonView(true, $"操作成功!【耗时:{stopwatch.ElapsedMilliseconds}ms】", new
  359. {
  360. isTips = groupNames.Any(),
  361. groupNames = groupNames.Select(x => new { x.Id, GroupName = x.TeamName, x.VisitDate }).ToList()
  362. }));
  363. }
  364. /// <summary>
  365. /// 提示用户录入团组费用信息
  366. /// 已知晓确认操作记录(添加) 批量
  367. /// </summary>
  368. /// <param name="dto">请求体</param>
  369. /// <returns></returns>
  370. [HttpPost]
  371. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  372. public async Task<IActionResult> FeeEntryAcknowledgeCrate(FeeEntryAcknowledgeCrateDto dto)
  373. {
  374. // 1. 参数验证
  375. if (dto?.GroupIds == null || !dto.GroupIds.Any())
  376. return Ok(JsonView(false, "请选择需要确认的团组!"));
  377. if (dto.GroupIds.Count > 100)
  378. return Ok(JsonView(false, "一次性确认团组数量不能超过100个!"));
  379. if (dto.CurrUserId <= 0)
  380. return Ok(JsonView(false, "用户ID无效!"));
  381. // 2. 验证用户存在性
  382. var userInfo = await _sqlSugar.Queryable<Sys_Users>()
  383. .Where(x => x.Id == dto.CurrUserId && x.IsDel == 0)
  384. .Select(x => new { x.Id, x.JobPostId, x.CnName })
  385. .FirstAsync();
  386. if (userInfo == null)
  387. return Ok(JsonView(false, "用户不存在或已被禁用!"));
  388. // 3. 获取费用类型
  389. if (!_dataInit.TryGetValue(userInfo.JobPostId, out var feeTypeIds) || feeTypeIds?.Count == 0)
  390. return Ok(JsonView(false, "当前用户岗位无对应的费用类型配置!"));
  391. // 4. 验证团组存在性
  392. var validGroupIds = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  393. .Where(x => dto.GroupIds.Contains(x.Id) && x.IsDel == 0)
  394. .Select(x => x.Id)
  395. .ToListAsync();
  396. if (!validGroupIds.Any())
  397. return Ok(JsonView(false, "未找到有效的团组信息!"));
  398. // 5. 检查团组费用表中是否存在对应费用类型的数据
  399. var existingFeeRecords = await _sqlSugar.Queryable<Grp_CreditCardPayment>()
  400. .Where(x => validGroupIds.Contains(x.DIId) && x.IsDel == 0)
  401. .Where(x => feeTypeIds.Contains(x.CTable))
  402. .Select(x => new { GroupId = x.DIId, FeeTypeId = x.CTable })
  403. .ToListAsync();
  404. if (existingFeeRecords.Count > 0)
  405. {
  406. // 找出有问题的团组和费用类型
  407. var problematicGroups = existingFeeRecords
  408. .GroupBy(x => x.GroupId)
  409. .Select(g => new
  410. {
  411. GroupId = g.Key,
  412. FeeTypeIds = string.Join(",", g.Select(x => x.FeeTypeId).Distinct())
  413. })
  414. .ToList();
  415. var errorMessage = $"以下团组的费用表中已存在费用数据,不可添加确认记录:";
  416. foreach (var group in problematicGroups)
  417. {
  418. errorMessage += $"\n团组 {group.GroupId} - 费用类型ID: [{group.FeeTypeIds}]";
  419. }
  420. return Ok(JsonView(false, errorMessage));
  421. }
  422. // 6. 检查是否已存在确认记录(避免重复确认)
  423. var existingAcknowledgeRecords = await _sqlSugar.Queryable<Grp_FeeEntryAcknowledge>()
  424. .Where(x => x.UserId == dto.CurrUserId && x.IsDel == 0)
  425. .Where(x => validGroupIds.Contains(x.GroupId))
  426. .Where(x => feeTypeIds.Contains(x.FeeTypeId))
  427. .Select(x => new { x.GroupId, x.FeeTypeId })
  428. .ToListAsync();
  429. // 7. 准备插入数据(过滤已存在的记录)
  430. var recordsToInsert = new List<Grp_FeeEntryAcknowledge>();
  431. foreach (var groupId in validGroupIds)
  432. {
  433. foreach (var feeTypeId in feeTypeIds)
  434. {
  435. // 检查是否已存在相同记录
  436. var exists = existingAcknowledgeRecords.Any(x => x.GroupId == groupId && x.FeeTypeId == feeTypeId);
  437. if (!exists)
  438. {
  439. recordsToInsert.Add(new Grp_FeeEntryAcknowledge()
  440. {
  441. GroupId = groupId,
  442. UserId = dto.CurrUserId,
  443. JobPostId = userInfo.JobPostId,
  444. FeeTypeId = feeTypeId,
  445. IsAcknowledged = Domain.Enums.AcknowledgeStatusEnum.Acknowledged,
  446. AcknowledgeTime = DateTime.Now,
  447. AcknowledgeType = Domain.Enums.AcknowledgeTypeEnum.WebConfirm,
  448. CreateUserId = 4, // 系统创建
  449. CreateTime = DateTime.Now
  450. });
  451. }
  452. }
  453. }
  454. if (!recordsToInsert.Any())
  455. return Ok(JsonView(true, "所选团组已确认,无需重复操作!"));
  456. // 8. 批量插入数据
  457. var successCount = await _sqlSugar.Insertable(recordsToInsert).ExecuteCommandAsync();
  458. if (successCount <= 0)
  459. return Ok(JsonView(false, "操作失败,未能保存确认记录!"));
  460. // 9. 记录操作日志
  461. _logger.LogInformation("用户 {UserName}(ID:{UserId}) 批量确认了 {GroupCount} 个团组的费用类型,共添加 {RecordCount} 条确认记录",
  462. userInfo.CnName, dto.CurrUserId, validGroupIds.Count, successCount);
  463. // 10. 操作成功 返回成功视图
  464. var result = await GetGroupNamesByUserId(dto.CurrUserId, dto.DaysAgo);
  465. if (result is OkObjectResult okObjectResult)
  466. {
  467. return Ok(okObjectResult.Value);
  468. }
  469. //return Ok(result);
  470. return Ok(JsonView(true, $"操作成功!共为 {validGroupIds.Count} 个团组添加了 {successCount} 条确认记录"));
  471. }
  472. /// <summary>
  473. /// 提示用户录入团组费用信息
  474. /// 已知晓确认操作记录(添加) 单个
  475. /// </summary>
  476. /// <param name="dto">请求体</param>
  477. /// <returns></returns>
  478. [HttpPost]
  479. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  480. public async Task<IActionResult> FeeEntryAcknowledgeSingleCreate(FeeEntryAcknowledgeSingleDto dto)
  481. {
  482. // 1. 参数验证
  483. if (dto.GroupId <= 0)
  484. return Ok(JsonView(false, "请选择有效的团组ID!"));
  485. if (dto.CurrUserId <= 0)
  486. return Ok(JsonView(false, "用户ID无效!"));
  487. // 2. 验证用户存在性
  488. var userInfo = await _sqlSugar.Queryable<Sys_Users>()
  489. .Where(x => x.Id == dto.CurrUserId && x.IsDel == 0)
  490. .Select(x => new { x.Id, x.JobPostId, x.CnName })
  491. .FirstAsync();
  492. if (userInfo == null)
  493. return Ok(JsonView(false, "用户不存在或已被禁用!"));
  494. // 3. 获取费用类型
  495. if (!_dataInit.TryGetValue(userInfo.JobPostId, out var feeTypeIds) || feeTypeIds?.Count == 0)
  496. return Ok(JsonView(false, "当前用户岗位无对应的费用类型配置!"));
  497. // 4. 验证团组存在性
  498. var groupExists = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  499. .AnyAsync(x => x.Id == dto.GroupId && x.IsDel == 0);
  500. if (!groupExists)
  501. return Ok(JsonView(false, "未找到有效的团组信息!"));
  502. // 5. 检查团组费用表中是否存在对应费用类型的数据
  503. var existingFeeRecords = await _sqlSugar.Queryable<Grp_CreditCardPayment>()
  504. .Where(x => x.DIId == dto.GroupId && x.IsDel == 0)
  505. .Where(x => feeTypeIds.Contains(x.CTable))
  506. .Select(x => new { x.CTable })
  507. .ToListAsync();
  508. if (existingFeeRecords.Count > 0)
  509. {
  510. var existingFeeTypeNames = existingFeeRecords.Select(x => x.CTable).Distinct().ToList();
  511. return Ok(JsonView(false, $"团组费用表中已存在费用类型ID [{string.Join(",", existingFeeTypeNames)}] 的数据,不可添加确认无费用记录!"));
  512. }
  513. // 6. 检查已存在的确认记录
  514. var existingAcknowledgeRecords = await _sqlSugar.Queryable<Grp_FeeEntryAcknowledge>()
  515. .Where(x => x.UserId == dto.CurrUserId && x.IsDel == 0)
  516. .Where(x => x.GroupId == dto.GroupId)
  517. .Where(x => feeTypeIds.Contains(x.FeeTypeId))
  518. .Select(x => new { x.FeeTypeId })
  519. .ToListAsync();
  520. var existingAcknowledgeFeeTypeIds = existingAcknowledgeRecords.Select(x => x.FeeTypeId).ToHashSet();
  521. // 7. 准备插入数据(过滤已存在的记录)
  522. var recordsToInsert = feeTypeIds
  523. .Where(feeTypeId => !existingAcknowledgeFeeTypeIds.Contains(feeTypeId))
  524. .Select(feeTypeId => new Grp_FeeEntryAcknowledge
  525. {
  526. GroupId = dto.GroupId,
  527. UserId = dto.CurrUserId,
  528. JobPostId = userInfo.JobPostId,
  529. FeeTypeId = feeTypeId,
  530. IsAcknowledged = Domain.Enums.AcknowledgeStatusEnum.Acknowledged,
  531. AcknowledgeTime = DateTime.Now,
  532. AcknowledgeType = Domain.Enums.AcknowledgeTypeEnum.WebConfirm,
  533. CreateUserId = 4, // 系统创建
  534. CreateTime = DateTime.Now
  535. })
  536. .ToList();
  537. if (recordsToInsert.Count == 0)
  538. return Ok(JsonView(true, "所选团组已确认,无需重复操作!"));
  539. // 8. 批量插入数据
  540. var successCount = await _sqlSugar.Insertable(recordsToInsert).ExecuteCommandAsync();
  541. if (successCount <= 0)
  542. return Ok(JsonView(false, "操作失败,未能保存确认记录!"));
  543. // 9. 记录操作日志(可选)
  544. _logger.LogInformation("用户 {UserName}(ID:{UserId}) 确认了团组 {GroupId} 的费用类型",
  545. userInfo.CnName, dto.CurrUserId, dto.GroupId);
  546. return Ok(JsonView(true, $"操作成功!"));
  547. }
  548. #endregion
  549. #region 流程管控
  550. /// <summary>
  551. /// 获取团组流程管控信息
  552. /// </summary>
  553. /// <param name="_jsonDto">查询参数</param>
  554. /// <returns></returns>
  555. [HttpPost]
  556. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  557. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  558. {
  559. if (string.IsNullOrEmpty(_jsonDto.Paras))
  560. {
  561. return Ok(JsonView(false, "参数为空"));
  562. }
  563. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  564. if (_ScheduleDto != null)
  565. {
  566. if (_ScheduleDto.SearchType == 2)//获取列表
  567. {
  568. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  569. return Ok(JsonView(_grpScheduleViewList));
  570. }
  571. else//获取对象
  572. {
  573. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  574. if (_grpScheduleView != null)
  575. {
  576. return Ok(JsonView(_grpScheduleView));
  577. }
  578. }
  579. }
  580. else
  581. {
  582. return Ok(JsonView(false, "参数反序列化失败"));
  583. }
  584. return Ok(JsonView(false, "暂无数据!"));
  585. }
  586. /// <summary>
  587. /// 修改团组流程管控详细表数据
  588. /// </summary>
  589. /// <param name="dto"></param>
  590. /// <returns></returns>
  591. [HttpPost]
  592. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  593. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  594. {
  595. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  596. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  597. .SetColumns(it => it.Duty == _detail.Duty)
  598. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  599. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  600. .SetColumns(it => it.JobContent == _detail.JobContent)
  601. .SetColumns(it => it.Remark == _detail.Remark)
  602. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  603. .Where(s => s.Id == dto.Id)
  604. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  605. .ExecuteCommandAsync();
  606. if (result > 0)
  607. {
  608. return Ok(JsonView(true, "保存成功!"));
  609. }
  610. return Ok(JsonView(false, "保存失败!"));
  611. }
  612. /// <summary>
  613. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  614. /// </summary>
  615. /// <param name="dto"></param>
  616. /// <returns></returns>
  617. [HttpPost]
  618. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  619. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  620. {
  621. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  622. _detail.IsDel = 1;
  623. _detail.DeleteUserId = dto.Duty;
  624. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  625. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  626. .SetColumns(it => it.IsDel == _detail.IsDel)
  627. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  628. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  629. .Where(it => it.Id == dto.Id)
  630. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  631. //.WhereColumns(s => s.Id == dto.Id)
  632. .ExecuteCommandAsync();
  633. if (result > 0)
  634. {
  635. return Ok(JsonView(true, "删除成功!"));
  636. }
  637. return Ok(JsonView(false, "删除失败!"));
  638. }
  639. /// <summary>
  640. /// 增加团组流程管控详细表数据
  641. /// </summary>
  642. /// <param name="dto"></param>
  643. /// <returns></returns>
  644. [HttpPost]
  645. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  646. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  647. {
  648. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  649. if (DateTime.Now < _detail.ExpectBeginDt)
  650. {
  651. _detail.StepStatus = 0;
  652. }
  653. else
  654. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  655. _detail.StepStatus = 1;
  656. }
  657. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  658. if (result > 0)
  659. {
  660. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  661. return Ok(JsonView(true, "添加成功!", _result));
  662. }
  663. return Ok(JsonView(false, "添加失败!"));
  664. }
  665. #endregion
  666. #region 团组前期信息
  667. /// <summary>
  668. /// 团组前期信息H5-URL(员工对应地址)
  669. /// </summary>
  670. /// <param name="name">用户名称</param>
  671. /// <returns></returns>
  672. [HttpGet]
  673. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  674. public async Task<IActionResult> GroupOrderPreInfoH5URLList([FromQuery] string name)
  675. {
  676. var userURLs = await _sqlSugar.Queryable<Sys_Users>()
  677. .Where(x => x.IsDel == 0)
  678. .WhereIF(!string.IsNullOrEmpty(name), x => x.CnName.Contains(name))
  679. .OrderBy(x => x.Id)
  680. .Select(x => new
  681. {
  682. name = x.CnName,
  683. url = $"http://oa.pan-american-intl.com:4399/#/MarketplacePick?userid={x.Id}",
  684. })
  685. .ToListAsync();
  686. return Ok(JsonView(true, "操作成功!", userURLs, userURLs.Count));
  687. }
  688. /// <summary>
  689. /// 团组前期信息 List
  690. /// </summary>
  691. /// <returns></returns>
  692. [HttpPost]
  693. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  694. public async Task<IActionResult> GroupOrderPreInfoList(GroupOrderPreInfoListDto dto)
  695. {
  696. var search = dto.Search;
  697. int[] nameTempIds = new int[] { 1, 12, 28 },
  698. countryTempIds = new int[] { 2, 13, 29 },
  699. daysTempIds = new int[] { 4, 15, 31 },
  700. ppNumTempIds = new int[] { 6 };
  701. var list = await _sqlSugar.Queryable<Grp_OrderPreInfo>()
  702. .LeftJoin<Sys_Users>((opi, u) => opi.CreateUserId == u.Id)
  703. .Where((opi, u) => opi.IsDel == 0)
  704. .OrderByDescending((opi, u) => opi.CreateTime)
  705. .Select((opi, u) => new GroupOrderPreInfoListView()
  706. {
  707. Id = opi.Id,
  708. Name = opi.Name,
  709. UnitName = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && nameTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  710. VisitCountryVal = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && countryTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  711. VisitDays = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && daysTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  712. VisiPpNum = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && ppNumTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  713. Operator = u.CnName,
  714. OperationTime = opi.CreateTime
  715. })
  716. //.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search) || x.UnitName.Contains(search) || x.VisitCountrys.Contains(search))
  717. //.ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  718. .ToListAsync();
  719. var listPageData = list.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search) || x.UnitName.Contains(search) || x.VisitCountrys.Contains(search)).ToList();
  720. int total = list.Count;
  721. int totalPageCount = (int)Math.Ceiling(list.Count / (double)dto.PageSize);
  722. var listPageData1 = listPageData
  723. .Skip((dto.PageIndex - 1) * dto.PageSize)
  724. .Take(dto.PageSize)
  725. .ToList();
  726. var infoIds = listPageData1.Select(x => x.Id).ToList();
  727. var typeDatas = await _sqlSugar.Queryable<Sys_SetData>()
  728. .Where(x => x.IsDel == 0 && x.STid == 109)
  729. .ToArrayAsync();
  730. var items = await _sqlSugar.Queryable<Grp_OrderPreItem>()
  731. .LeftJoin<Sys_FormTemp>((opi, ft) => opi.FormTempId == ft.Id)
  732. .Where((opi, ft) => opi.IsDel == 0 && infoIds.Contains(opi.ParentId))
  733. .Select((opi, ft) => new { opi.ParentId, opi.FormTempId, ft.TempId })
  734. .ToListAsync();
  735. foreach (var item in listPageData1)
  736. {
  737. var typeDatas1 = typeDatas.Select(x => new
  738. {
  739. x.Id,
  740. x.Name,
  741. IsNull = !items.Any(x1 => item.Id == x1.ParentId && x.Id == x1.TempId)
  742. }).ToArray();
  743. item.VersionDetails = typeDatas1;
  744. }
  745. return Ok(JsonView(listPageData1, listPageData1.Count));
  746. }
  747. /// <summary>
  748. /// 团组前期信息 Init
  749. /// </summary>
  750. /// <returns></returns>
  751. [HttpGet("{userId}")]
  752. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  753. public async Task<IActionResult> GroupOrderPreInfo(int userId)
  754. {
  755. return Ok(await _grpOrderPreInfoRep.DataInit(userId));
  756. }
  757. /// <summary>
  758. /// 国家数据源
  759. /// </summary>
  760. /// <param name="pageIndex">当前页码</param>
  761. /// <param name="pageSize">每页条数</param>
  762. /// <param name="search">查询条件</param>
  763. /// <returns></returns>
  764. [HttpGet]
  765. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  766. public async Task<IActionResult> CountryInit([FromQuery] int pageIndex, [FromQuery] int pageSize, [FromQuery] string search)
  767. {
  768. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => x.Country).Distinct().ToListAsync();
  769. if (pageIndex == 0 && pageSize == 0)
  770. {
  771. //所有数据
  772. return Ok(JsonView(countrys, countrys.Count));
  773. }
  774. //分页
  775. int skip = (pageIndex - 1) * pageSize;
  776. int take = pageSize;
  777. if (!string.IsNullOrEmpty(search))
  778. {
  779. IEnumerable<char> charSequence = search.Select(c => c);
  780. var pageResult1 = countrys.Where(x => charSequence.All(x1 => x.Contains(x1))).ToList();
  781. var pageData = pageResult1.Skip(skip).Take(take).ToList();
  782. return Ok(JsonView(pageData, pageResult1.Count));
  783. }
  784. var pageResult2 = countrys.Skip(skip).Take(take).ToList();
  785. return Ok(JsonView(pageResult2, countrys.Count));
  786. }
  787. /// <summary>
  788. /// 城市数据源
  789. /// </summary>
  790. /// <param name="countryLabel">国家名称 多个使用英文逗号隔开</param>
  791. /// <param name="pageIndex">当前页码</param>
  792. /// <param name="pageSize">每页条数</param>
  793. /// <param name="search">查询条件</param>
  794. /// <returns></returns>
  795. [HttpGet("{countryLabel}")]
  796. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  797. public async Task<IActionResult> CityByCountry(
  798. string countryLabel,
  799. [FromQuery] int pageIndex,
  800. [FromQuery] int pageSize,
  801. [FromQuery] string search)
  802. {
  803. countryLabel = HttpUtility.UrlDecode(countryLabel);
  804. var countryList = countryLabel.Split(',', StringSplitOptions.RemoveEmptyEntries).ToArray();
  805. var citys = Array.Empty<string?>();
  806. if (countryList.Any())
  807. {
  808. var cityDatas = await _sqlSugar
  809. .Queryable<Grp_NationalTravelFee>()
  810. .Where(x => x.IsDel == 0 && countryList.Contains(x.Country) && !string.IsNullOrEmpty(x.City))
  811. .ToArrayAsync();
  812. foreach (var item in cityDatas)
  813. {
  814. if (item.City.Contains("城市"))
  815. {
  816. item.City = item.Country + "-所有城市";
  817. }
  818. }
  819. var cityDatas1 = cityDatas.OrderBy(x => x.Country);
  820. citys = cityDatas1.Select(x => x.City).Distinct().ToArray();
  821. }
  822. if (pageIndex == 0 && pageSize == 0)
  823. {
  824. //所有数据
  825. return Ok(JsonView(citys, citys?.Length ?? 0));
  826. }
  827. //分页
  828. int skip = (pageIndex - 1) * pageSize;
  829. int take = pageSize;
  830. if (!string.IsNullOrEmpty(search))
  831. {
  832. IEnumerable<char> charSequence = search.Select(c => c);
  833. var pageResult1 = citys.Where(x => charSequence.All(x1 => x.Contains(x1))).ToList();
  834. var pageData = pageResult1.Skip(skip).Take(take).ToList();
  835. return Ok(JsonView(pageData, pageResult1.Count));
  836. }
  837. var pageResult2 = citys.Skip(skip).Take(take).ToList();
  838. return Ok(JsonView(pageResult2, citys?.Length ?? 0));
  839. }
  840. /// <summary>
  841. /// 团组前期信息 Info
  842. /// </summary>
  843. /// <param name="dto">Id</param>
  844. /// <returns></returns>
  845. [HttpGet("{Id}/{TempId}")]
  846. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  847. public async Task<IActionResult> GroupOrderPreInfo([FromRoute] GroupOrderPreInfoDto dto)
  848. {
  849. return Ok(await _grpOrderPreInfoRep.InfoAsync(dto.Id, dto.TempId));
  850. }
  851. /// <summary>
  852. /// 团组前期信息 移动端 Info
  853. /// </summary>
  854. /// <param name="dto">Id</param>
  855. /// <returns></returns>
  856. [HttpGet("{Id}/{TempId}")]
  857. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  858. public async Task<IActionResult> GroupOrderPreMobileInfo([FromRoute] GroupOrderPreInfoDto dto)
  859. {
  860. return Ok(await _grpOrderPreInfoRep.MobileInfoAsync(dto.Id, dto.TempId));
  861. }
  862. /// <summary>
  863. /// 团组前期信息 Save
  864. /// </summary>
  865. /// <param name="dto">Id</param>
  866. /// <returns></returns>
  867. [HttpPost]
  868. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  869. public async Task<IActionResult> GroupOrderPreInfoSave(GroupOrderPreInfoOpDto dto)
  870. {
  871. return Ok(await _grpOrderPreInfoRep.OpAsync(dto));
  872. }
  873. /// <summary>
  874. /// 团组前期信息 Del
  875. /// </summary>
  876. /// <param name="dto">Id</param>
  877. /// <returns></returns>
  878. [HttpPost]
  879. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  880. public async Task<IActionResult> GroupOrderPreInfoDel(GroupOrderPreInfoDelDto dto)
  881. {
  882. return Ok(await _grpOrderPreInfoRep.DelAsync(dto));
  883. }
  884. /// <summary>
  885. /// 团组前期信息 文件下载
  886. /// </summary>
  887. /// <param name="dto">Id</param>
  888. /// <returns></returns>
  889. [HttpGet("{Id}/{TempId}")]
  890. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  891. public async Task<IActionResult> GroupOrderPreInfoFileDownload([FromRoute] GroupOrderPreInfoDto dto)
  892. {
  893. int id = dto.Id, tempId = dto.TempId;
  894. var view = await _grpOrderPreInfoRep.InfoAsync(id, tempId);
  895. var data = view.Data as GrpOrderPreInfoView;
  896. #region Excel
  897. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  898. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  899. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "GroupOrderPreInfo/";
  900. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "GroupOrderPreInfo/";
  901. var fileNamePrefix = string.Empty;
  902. if (tempId == 1405)
  903. {
  904. tempPath += $"前期需客户提供信息_无商邀版Temp.xlsx";
  905. fileNamePrefix = $"{data.Name}_无商邀版";
  906. }
  907. else if (tempId == 1406)
  908. {
  909. tempPath += $"前期需客户提供信息_有商邀版Temp.xlsx";
  910. fileNamePrefix = $"{data.Name}_有商邀版";
  911. }
  912. else
  913. {
  914. //tempId == 1404 默认下载
  915. tempPath += $"前期需客户提供信息_单接送机Temp.xlsx";
  916. fileNamePrefix = $"{data.Name}_单接送机";
  917. }
  918. foreach (var item in data.Items)
  919. {
  920. var obj = item.NewValue;
  921. if (obj == null) item.OriginVal = "";
  922. else if (obj.Equals("有") || obj.Equals("无"))
  923. {
  924. item.OriginVal = obj.ToString();
  925. }
  926. else if (obj is object[] objArray)
  927. {
  928. string[] stringArray = Array.ConvertAll(objArray, item => item?.ToString() ?? string.Empty);
  929. item.OriginVal = string.Join("、", stringArray);
  930. }
  931. else if (obj is string[] stringArray)
  932. {
  933. item.OriginVal = string.Join("、", stringArray);
  934. }
  935. else if (obj.Equals("-"))
  936. {
  937. item.OriginVal = "";
  938. }
  939. }
  940. var fileName = $"{fileNamePrefix}{CommonFun.GUID}.xlsx";
  941. fileName = CommonFun.ValidFileName(fileName);
  942. //载入模板
  943. var designer = new WorkbookDesigner
  944. {
  945. Workbook = new Workbook(tempPath)
  946. };
  947. if (tempId == 1406)
  948. {
  949. var view1 = data.Items.Where(x => x.Index < 11).ToArray();
  950. var view2 = data.Items.Where(x => x.Index > 10).ToArray();
  951. for (int i = 1; i <= view2.Length; i++)
  952. {
  953. view2[i - 1].Index = i;
  954. }
  955. designer.SetDataSource("View1", view1);
  956. designer.SetDataSource("View2", view2);
  957. }
  958. else
  959. {
  960. designer.SetDataSource("View", data.Items);
  961. }
  962. designer.Process();
  963. if (!Directory.Exists(savePath))
  964. {
  965. Directory.CreateDirectory(savePath);
  966. }
  967. string serverPath = $"{savePath}{fileName}";
  968. designer.Workbook.Save(serverPath);
  969. string rst = $"{servicePath}{ftpPath}{fileName}";
  970. #endregion
  971. return Ok(JsonView(new { url = rst }));
  972. }
  973. #endregion
  974. #region 团组基本信息
  975. /// <summary>
  976. /// 接团信息列表
  977. /// </summary>
  978. /// <param name="dto">团组列表请求dto</param>
  979. /// <returns></returns>
  980. [HttpPost]
  981. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  982. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  983. {
  984. var groupData = await _groupRepository.GetGroupList(dto);
  985. if (groupData.Code != 0)
  986. {
  987. return Ok(JsonView(false, groupData.Msg));
  988. }
  989. return Ok(JsonView(groupData.Data));
  990. }
  991. /// <summary>
  992. /// 分页查询团组列表
  993. /// </summary>
  994. /// <param name="dto"></param>
  995. /// <returns></returns>
  996. [HttpPost]
  997. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  998. public async Task<IActionResult> QueryGroupListOffset(QueryGroupListOffsetDto dto)
  999. {
  1000. var watch = new Stopwatch();
  1001. watch.Start();
  1002. RefAsync<int> total = 0;
  1003. var countyDatas = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  1004. .Where((di) => di.IsDel == 0 && !string.IsNullOrWhiteSpace(di.TeamName))
  1005. .WhereIF(!string.IsNullOrEmpty(dto.Search), (di) => di.TeamName.Contains(dto.Search))
  1006. .OrderBy((di) => new { id = SqlFunc.Desc(di.Id) })
  1007. .Select((di) => new { id = di.Id, name = di.TeamName, di.ClientName, di.VisitPNumber, di.VisitCountry, di.VisitDays, di.VisitStartDate, di.VisitEndDate, di.TourCode })
  1008. .Distinct()
  1009. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  1010. watch.Stop();
  1011. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  1012. }
  1013. /// <summary>
  1014. /// 接团信息列表 Page Init
  1015. /// </summary>
  1016. /// <returns></returns>
  1017. [HttpPost]
  1018. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1019. public async Task<IActionResult> PostGroupPageListInit()
  1020. {
  1021. var depDatas = await GeneralMethod.GroupOpAffiliationBranchInit();
  1022. var rankDatas = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 56).Select(x => new { x.Id, x.Name }).ToListAsync();
  1023. rankDatas.Insert(0, new { Id = 0, Name = "全部" });
  1024. var _view = new
  1025. {
  1026. depData = depDatas,
  1027. rankData = rankDatas
  1028. };
  1029. return Ok(JsonView(true, "查询成功!", _view));
  1030. }
  1031. /// <summary>
  1032. /// 接团信息列表 Page
  1033. /// </summary>
  1034. /// <param name="dto">团组列表请求dto</param>
  1035. /// <returns></returns>
  1036. [HttpPost]
  1037. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1038. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  1039. {
  1040. #region 参数验证
  1041. if (dto.UserId < 1)
  1042. return Ok(JsonView(false, "员工Id为空"));
  1043. if (dto.PageId < 1)
  1044. return Ok(JsonView(false, "页面Id为空"));
  1045. #region 页面操作权限验证
  1046. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  1047. if (pageFunAuthView.CheckAuth == 0)
  1048. return Ok(JsonView(false, "您没有查看权限"));
  1049. #endregion
  1050. #endregion
  1051. //if (dto.PortType != 1 && dto.PortType != 2) // web/Android
  1052. // return Ok(JsonView(false, "不支持的端口类型"));
  1053. // 构建查询条件
  1054. var sqlWhereBuilder = new StringBuilder(" WHERE gdi.IsDel = 0");
  1055. var parameters = new List<SugarParameter>();
  1056. // 完成状态筛选
  1057. if (dto.IsSure == 0 || dto.IsSure == 1)
  1058. {
  1059. sqlWhereBuilder.Append(" AND gdi.IsSure = @IsSure");
  1060. parameters.Add(new SugarParameter("@IsSure", dto.IsSure));
  1061. }
  1062. // 搜索条件
  1063. if (!string.IsNullOrWhiteSpace(dto.SearchCriteria))
  1064. {
  1065. var searchParam = $"%{dto.SearchCriteria.Trim()}%";
  1066. sqlWhereBuilder.Append(@"
  1067. AND (ssd.Name LIKE @SearchCriteria
  1068. OR gdi.TeamName LIKE @SearchCriteria
  1069. OR gdi.ClientName LIKE @SearchCriteria
  1070. OR su.CnName LIKE @SearchCriteria)");
  1071. parameters.Add(new SugarParameter("@SearchCriteria", searchParam));
  1072. }
  1073. // 等级筛选
  1074. if (int.TryParse(dto.Rank, out int rankId) && rankId > 0)
  1075. {
  1076. sqlWhereBuilder.Append(" AND gdi.TeamLevSId = @RankId");
  1077. parameters.Add(new SugarParameter("@RankId", rankId));
  1078. }
  1079. // 部门筛选
  1080. var departmentWhere = string.Empty;
  1081. if (!string.IsNullOrWhiteSpace(dto.Department) && !dto.Department.Equals("全部"))
  1082. {
  1083. departmentWhere = " WHERE Department = @Department";
  1084. parameters.Add(new SugarParameter("@Department", dto.Department));
  1085. }
  1086. // 构建SQL查询
  1087. string sql = $@"
  1088. SELECT Row_Number, Id, SalesQuoteNo, TourCode, TeamTypeId, TeamType, Department,
  1089. TeamLevId, TeamLev, TeamName, ClientName, ClientUnit,
  1090. VisitDate, VisitDays, VisitPNumber, JietuanOperatorId,
  1091. JietuanOperator, IsSure, CreateTime, IsBid, Step
  1092. FROM (
  1093. SELECT ROW_NUMBER() OVER(ORDER BY gdi.VisitStartDate DESC) AS Row_Number,
  1094. CASE
  1095. WHEN gdi.JietuanOperator IN (4, 21) THEN '国交部'
  1096. ELSE (SELECT DepName FROM OA2023DB.dbo.Sys_Department WHERE Id = su.DepId)
  1097. END AS 'Department',
  1098. gdi.Id, SalesQuoteNo, TourCode, ssd.Id AS TeamTypeId, ssd.Name AS TeamType, gdi.Step,
  1099. ssd1.Id AS TeamLevId, ssd1.Name AS TeamLev, TeamName, ClientName, ClientUnit,
  1100. VisitDate, VisitDays, VisitPNumber, JietuanOperator AS JietuanOperatorId,
  1101. su.CnName AS JietuanOperator, IsSure, gdi.CreateTime, gdi.IsBid
  1102. FROM Grp_DelegationInfo gdi
  1103. LEFT JOIN Sys_SetData ssd ON gdi.TeamDid = ssd.Id
  1104. LEFT JOIN Sys_SetData ssd1 ON gdi.TeamLevSId = ssd1.Id
  1105. LEFT JOIN Sys_Users su ON gdi.JietuanOperator = su.Id
  1106. {sqlWhereBuilder}
  1107. ) temp {departmentWhere}";
  1108. // 执行分页查询
  1109. RefAsync<int> total = 0;
  1110. var delegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql)
  1111. .AddParameters(parameters)
  1112. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  1113. if (!delegationList.Any())
  1114. {
  1115. var emptyView = new
  1116. {
  1117. PageFuncAuth = pageFunAuthView,
  1118. Data = delegationList
  1119. };
  1120. return Ok(JsonView(true, "查询成功,暂无数据", emptyView, total));
  1121. }
  1122. // 批量处理团组模块实际操作人和背景颜色设置
  1123. await ProcessDelegationListData(delegationList);
  1124. var resultView = new
  1125. {
  1126. PageFuncAuth = pageFunAuthView,
  1127. Data = delegationList
  1128. };
  1129. return Ok(JsonView(true, "查询成功!", resultView, total));
  1130. }
  1131. /// <summary>
  1132. /// 批量处理团组数据
  1133. /// </summary>
  1134. private async Task ProcessDelegationListData(List<DelegationListView> delegationList)
  1135. {
  1136. var groupIds = delegationList.Select(x => x.Id).ToList();
  1137. // 批量查询信用卡支付记录
  1138. var creditCardPayments = await _sqlSugar.Queryable<Grp_CreditCardPayment>()
  1139. .Where(y => groupIds.Contains(y.DIId) && y.IsDel == 0)
  1140. .Select(y => y.DIId)
  1141. .Distinct()
  1142. .ToListAsync();
  1143. // 批量查询费用确认记录
  1144. var feeAcknowledgements = await _sqlSugar.Queryable<Grp_FeeEntryAcknowledge>()
  1145. .Where(y => groupIds.Contains(y.GroupId) && y.IsDel == 0)
  1146. .Where(y => y.IsAcknowledged == AcknowledgeStatusEnum.Acknowledged)
  1147. .Select(y => y.GroupId)
  1148. .Distinct()
  1149. .ToListAsync();
  1150. var creditCardPaymentSet = creditCardPayments.ToHashSet();
  1151. var feeAcknowledgementSet = feeAcknowledgements.ToHashSet();
  1152. // 并行处理每个团组
  1153. var tasks = delegationList.Select(async x =>
  1154. {
  1155. // 处理团组模块实际操作人
  1156. var operators = GeneralMethod.GetGroupModuleOperators(x.Id);
  1157. var operatorNames = new StringBuilder();
  1158. if (operators.Any())
  1159. {
  1160. foreach (var operatorInfo in operators)
  1161. {
  1162. string label = operatorInfo.OperationUsers.Any()
  1163. ? string.Join('、', operatorInfo.OperationUsers.Select(u => u.UserName))
  1164. : "暂未指定";
  1165. operatorNames.AppendLine($"{operatorInfo.CTableName}:{label}");
  1166. operatorNames.AppendLine();
  1167. }
  1168. }
  1169. x.OperatorLabel = operatorNames.ToString().TrimEnd('\n', '\r');
  1170. // 设置背景颜色为红色
  1171. // C表没数据并且没点提醒确认按钮(无成本费用按钮)的团组该行显示红色
  1172. bool hasCreditCardPayment = creditCardPaymentSet.Contains(x.Id);
  1173. bool hasFeeAcknowledgement = feeAcknowledgementSet.Contains(x.Id);
  1174. x.UseRedBackground = !hasCreditCardPayment && !hasFeeAcknowledgement;
  1175. });
  1176. await Task.WhenAll(tasks);
  1177. }
  1178. /// <summary>
  1179. /// 团组列表
  1180. /// </summary>
  1181. /// <returns></returns>
  1182. [HttpPost]
  1183. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  1184. {
  1185. #region 参数验证
  1186. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1187. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1188. #region 页面操作权限验证
  1189. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  1190. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1191. #endregion
  1192. #endregion
  1193. if (dto.PortType != 1 && dto.PortType != 2)
  1194. {
  1195. return Ok(JsonView(false, "查询失败!"));
  1196. }
  1197. string orderbyStr = "order by gdi.CreateTime Desc";
  1198. string sqlWhere = string.Empty;
  1199. if (dto.IsSure == 0) //未完成
  1200. {
  1201. sqlWhere += string.Format(@" And IsSure = 0");
  1202. }
  1203. else if (dto.IsSure == 1) //已完成
  1204. {
  1205. sqlWhere += string.Format(@" And IsSure = 1");
  1206. }
  1207. //团组类型
  1208. if (dto.TeamDid > 0)
  1209. {
  1210. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  1211. }
  1212. //团组名称
  1213. if (!string.IsNullOrEmpty(dto.TeamName))
  1214. {
  1215. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  1216. }
  1217. //客户名称
  1218. if (!string.IsNullOrEmpty(dto.ClientName))
  1219. {
  1220. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  1221. }
  1222. //客户单位
  1223. if (!string.IsNullOrEmpty(dto.ClientUnit))
  1224. {
  1225. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  1226. }
  1227. //出访时间
  1228. if (!string.IsNullOrEmpty(dto.visitDataTime))
  1229. {
  1230. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  1231. orderbyStr = "order by gdi.VisitDate";
  1232. }
  1233. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  1234. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  1235. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  1236. JietuanOperator,IsSure,CreateTime
  1237. From (
  1238. Select row_number() over({0}) as Row_Number,
  1239. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  1240. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  1241. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  1242. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  1243. From Grp_DelegationInfo gdi
  1244. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  1245. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  1246. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  1247. Where gdi.IsDel = 0 {1}
  1248. ) temp ", orderbyStr, sqlWhere);
  1249. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  1250. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  1251. #region 处理所属部门
  1252. /*
  1253. * 1.sq 和 gyy 等显示 市场部
  1254. * 2.王鸽和主管及张总还有管理员号统一国交部
  1255. * 2-1. 4 管理员 ,21 张海麟
  1256. */
  1257. var userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  1258. var userIds1 = new List<int>() { 4, 21 };
  1259. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  1260. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  1261. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  1262. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  1263. .ToList();
  1264. foreach (var item in _DelegationList)
  1265. {
  1266. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  1267. }
  1268. #endregion
  1269. var _view = new
  1270. {
  1271. PageFuncAuth = pageFunAuthView,
  1272. Data = _DelegationList
  1273. };
  1274. return Ok(JsonView(true, "查询成功!", _view, total));
  1275. }
  1276. /// <summary>
  1277. /// 接团信息详情
  1278. /// </summary>
  1279. /// <param name="dto">团组info请求dto</param>
  1280. /// <returns></returns>
  1281. [HttpPost]
  1282. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1283. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  1284. {
  1285. var groupData = await _groupRepository.GetGroupInfo(dto);
  1286. if (groupData.Code != 0)
  1287. {
  1288. return Ok(JsonView(false, groupData.Msg));
  1289. }
  1290. return Ok(JsonView(groupData.Data));
  1291. }
  1292. /// <summary>
  1293. /// 接团信息 编辑添加
  1294. /// 基础信息数据源
  1295. /// </summary>
  1296. /// <param name="dto"></param>
  1297. /// <returns></returns>
  1298. [HttpPost]
  1299. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1300. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  1301. {
  1302. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  1303. if (groupData.Code != 0)
  1304. {
  1305. return Ok(JsonView(false, groupData.Msg));
  1306. }
  1307. return Ok(JsonView(groupData.Data));
  1308. }
  1309. /// <summary>
  1310. /// 成本修改团组信息
  1311. /// </summary>
  1312. /// <param name="dto"></param>
  1313. /// <returns></returns>
  1314. [HttpPost]
  1315. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1316. public async Task<IActionResult> GroupCostEditGroupInfo(GroupCostEditGroupInfoDto dto)
  1317. {
  1318. var jw = JsonView(false, "操作失败");
  1319. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  1320. if (di == null)
  1321. {
  1322. jw.Msg = "参数有误!";
  1323. return Ok(jw);
  1324. }
  1325. #region 添加出访起止时间
  1326. var startTime = new DateTime();
  1327. var endTime = new DateTime();
  1328. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1329. {
  1330. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1331. }
  1332. else
  1333. {
  1334. jw.Msg = "参数有误!";
  1335. return Ok(jw);
  1336. }
  1337. #endregion
  1338. di.VisitDate = startTime;
  1339. di.VisitPNumber = dto.VisitPNumber;
  1340. di.VisitDays = dto.VisitDays;
  1341. di.VisitStartDate = startTime;
  1342. di.VisitEndDate = endTime;
  1343. var count = _sqlSugar.Updateable(di)
  1344. .UpdateColumns(x => new { x.VisitDate, x.VisitPNumber, x.VisitDays, x.VisitStartDate, x.VisitEndDate })
  1345. .ExecuteCommand();
  1346. return Ok(count > 0 ? JsonView(true, "操作成功") : jw);
  1347. }
  1348. /// <summary>
  1349. /// 接团信息 编辑添加
  1350. /// 省份-城市 基础信息数据源
  1351. /// </summary>
  1352. /// <param name="dto"></param>
  1353. /// <returns></returns>
  1354. [HttpPost]
  1355. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1356. public async Task<IActionResult> GroupProvCityBasicSource(GroupProvCityBasicSourceDto dto)
  1357. {
  1358. int pageIndex = dto.PageIndex, pageSize = dto.PageSize;
  1359. string search = dto.Search;
  1360. var data = await _groupRepository.CityBasicSource();
  1361. int total = data.Length;
  1362. data = data.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search))
  1363. .Skip((pageIndex - 1) * pageSize)
  1364. .Take(pageSize)
  1365. .ToArray();
  1366. return Ok(JsonView(data, total));
  1367. }
  1368. /// <summary>
  1369. /// 接团信息 操作(增改)
  1370. /// </summary>
  1371. /// <param name="dto"></param>
  1372. /// <returns></returns>
  1373. [HttpPost]
  1374. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1375. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  1376. {
  1377. // 创建 Stopwatch 实例
  1378. Stopwatch stopwatch = Stopwatch.StartNew();
  1379. decimal ffrPrice = 0.00M;
  1380. DateTime? visitDt = null;
  1381. if (dto.Status == 2)
  1382. {
  1383. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1384. if (groupInfo != null)
  1385. {
  1386. ffrPrice = groupInfo.PaymentMoney;
  1387. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1388. }
  1389. }
  1390. var groupData = await _groupRepository.GroupOperation(dto);
  1391. if (groupData.Code != 0)
  1392. {
  1393. return Ok(JsonView(false, groupData.Msg));
  1394. }
  1395. int diId = 0;
  1396. try
  1397. {
  1398. //添加时 默认加入团组汇率
  1399. if (dto.Status == 1) //添加
  1400. {
  1401. diId = groupData.Data;
  1402. //添加默认币种
  1403. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1404. //默认分配权限
  1405. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1406. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1407. var _managerIds = new List<int>() { 22, 32, 21 };
  1408. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1409. if (userIds.Count > 0)
  1410. {
  1411. userIds.Add(208);
  1412. //创建团组管控
  1413. GroupStepForDelegation.CreateWorkStep(diId);
  1414. //发送消息
  1415. string groupName = dto.TeamName;
  1416. string createGroupUser = string.Empty;
  1417. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1418. if (userInfo != null) createGroupUser = userInfo.CnName;
  1419. string title = $"系统通知";
  1420. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1421. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1422. }
  1423. //默认创建倒推表
  1424. await _invertedListRep._Create(dto.UserId, diId);
  1425. //默认创建签证流程
  1426. await _visaProcessRep.Create(dto.UserId, diId);
  1427. //默认创建团组流程总览信息
  1428. await _processOverviewRep.ProcessInitAsync(diId, dto.UserId);
  1429. }
  1430. else if (dto.Status == 2)
  1431. {
  1432. diId = dto.Id;
  1433. }
  1434. #region 签证人员团组时间通知
  1435. #region 计算出访起止时间
  1436. var startTime = new DateTime();
  1437. var endTime = new DateTime();
  1438. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1439. {
  1440. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1441. }
  1442. #endregion
  1443. #endregion
  1444. #region 团组操作默认添加/修改收款账单
  1445. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1446. {
  1447. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1448. .Where(x => x.IsDel == 0 &&
  1449. x.Diid == diId &&
  1450. x.Remark.Equals("预付款")
  1451. )
  1452. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1453. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1454. .FirstAsync();
  1455. ffrInfo = new Fin_ForeignReceivables()
  1456. {
  1457. Diid = diId,
  1458. PriceName = dto.ClientUnit,
  1459. Price = dto.PaymentMoney,
  1460. Count = 1,
  1461. Unit = $"元",
  1462. ItemSumPrice = dto.PaymentMoney,
  1463. Rate = 1.0000M,
  1464. Currency = 836,
  1465. AddingWay = 0,
  1466. CreateUserId = dto.UserId,
  1467. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1468. Remark = $"预付款"
  1469. };
  1470. if (ffrInfo == null) //Add
  1471. {
  1472. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1473. }
  1474. else //修改
  1475. {
  1476. await _sqlSugar.Updateable(ffrInfo)
  1477. .UpdateColumns(x => new
  1478. {
  1479. x.PriceName,
  1480. x.Price,
  1481. x.ItemSumPrice,
  1482. x.CreateTime,
  1483. x.CreateUserId
  1484. })
  1485. .WhereColumns(x => x.Id)
  1486. .ExecuteCommandAsync();
  1487. }
  1488. }
  1489. #endregion
  1490. if (diId > 0)
  1491. {
  1492. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1493. }
  1494. // 停止计时
  1495. stopwatch.Stop();
  1496. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  1497. }
  1498. catch (Exception ex)
  1499. {
  1500. // 停止计时
  1501. stopwatch.Stop();
  1502. Logs("[response]" + JsonConvert.SerializeObject(dto));
  1503. Logs(ex.Message);
  1504. //return Ok(JsonView(false, $"{ex.Message}[{stopwatch.ElapsedMilliseconds}ms]"));
  1505. }
  1506. // 停止计时
  1507. stopwatch.Stop();
  1508. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  1509. }
  1510. /// <summary>
  1511. /// 接团流程操作(增改)
  1512. /// 安卓端使用 建团时添加客户名单
  1513. /// </summary>
  1514. /// <param name="dto"></param>
  1515. /// <returns></returns>
  1516. [HttpPost]
  1517. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1518. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  1519. {
  1520. #region 参数验证
  1521. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  1522. #region 页面操作权限验证
  1523. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  1524. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  1525. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  1526. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  1527. #endregion
  1528. #endregion
  1529. try
  1530. {
  1531. //_sqlSugar.BeginTran();
  1532. decimal ffrPrice = 0.00M;
  1533. DateTime? visitDt = null;
  1534. if (dto.Status == 2)
  1535. {
  1536. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1537. if (groupInfo != null)
  1538. {
  1539. ffrPrice = groupInfo.PaymentMoney;
  1540. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1541. }
  1542. }
  1543. var _dto = new GroupOperationDto();
  1544. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  1545. var groupData = await _groupRepository.GroupOperation(_dto);
  1546. if (groupData.Code != 0)
  1547. {
  1548. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  1549. }
  1550. int diId = 0;
  1551. //添加时 默认加入团组汇率
  1552. if (dto.Status == 1) //添加
  1553. {
  1554. diId = groupData.Data;
  1555. //添加默认币种
  1556. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1557. //默认分配权限
  1558. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1559. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1560. var _managerIds = new List<int>() { 21, 22, 32 };
  1561. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1562. if (userIds.Count > 0)
  1563. {
  1564. userIds.Add(208);
  1565. //创建团组管控
  1566. GroupStepForDelegation.CreateWorkStep(diId);
  1567. //发送消息
  1568. string groupName = dto.TeamName;
  1569. string createGroupUser = string.Empty;
  1570. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1571. if (userInfo != null) createGroupUser = userInfo.CnName;
  1572. string title = $"系统通知";
  1573. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1574. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1575. }
  1576. #region 应用推送
  1577. try
  1578. {
  1579. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1580. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1581. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1582. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1583. {
  1584. var userList = new List<string>() { users.QiyeChatUserId };
  1585. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1586. }
  1587. }
  1588. catch (Exception ex)
  1589. {
  1590. }
  1591. #endregion
  1592. //默认创建倒推表
  1593. await _invertedListRep._Create(dto.UserId, diId);
  1594. //默认创建签证流程
  1595. await _visaProcessRep.Create(dto.UserId, diId);
  1596. //默认创建团组流程总览信息
  1597. await _processOverviewRep.ProcessInitAsync(diId, dto.UserId);
  1598. }
  1599. if (dto.Status == 2)
  1600. {
  1601. diId = dto.Id;
  1602. if (diId == 0)
  1603. {
  1604. //_sqlSugar.RollbackTran();
  1605. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  1606. }
  1607. }
  1608. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1609. if (viewData.Code != 0)
  1610. {
  1611. //_sqlSugar.RollbackTran();
  1612. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1613. }
  1614. #region 团组操作默认添加/修改收款账单
  1615. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1616. {
  1617. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1618. .Where(x => x.IsDel == 0 &&
  1619. x.Diid == diId &&
  1620. x.Remark.Equals("预付款")
  1621. )
  1622. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1623. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1624. .FirstAsync();
  1625. ffrInfo = new Fin_ForeignReceivables()
  1626. {
  1627. Diid = diId,
  1628. PriceName = dto.ClientUnit,
  1629. Price = dto.PaymentMoney,
  1630. Count = 1,
  1631. Unit = $"元",
  1632. ItemSumPrice = dto.PaymentMoney,
  1633. Rate = 1.0000M,
  1634. Currency = 836,
  1635. AddingWay = 0,
  1636. CreateUserId = dto.UserId,
  1637. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1638. Remark = $"预付款"
  1639. };
  1640. if (ffrInfo == null) //Add
  1641. {
  1642. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1643. }
  1644. else //修改
  1645. {
  1646. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1647. .UpdateColumns(x => new
  1648. {
  1649. x.PriceName,
  1650. x.Price,
  1651. x.ItemSumPrice,
  1652. x.CreateTime,
  1653. x.CreateUserId
  1654. })
  1655. .WhereColumns(x => x.Id)
  1656. .ExecuteCommandAsync();
  1657. }
  1658. }
  1659. #endregion
  1660. #region 签证人员团组时间通知
  1661. #region 计算出访起止时间
  1662. var startTime = new DateTime();
  1663. var endTime = new DateTime();
  1664. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1665. {
  1666. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1667. }
  1668. #endregion
  1669. if (diId > 0)
  1670. {
  1671. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1672. }
  1673. #endregion
  1674. //_sqlSugar.CommitTran();
  1675. return Ok(JsonView(true, "添加成功"));
  1676. }
  1677. catch (Exception ex)
  1678. {
  1679. _sqlSugar.RollbackTran();
  1680. return Ok(JsonView(false, ex.Message));
  1681. }
  1682. }
  1683. /// <summary>
  1684. /// 接团流程操作(增改)
  1685. /// 安卓端使用 建团时添加客户名单
  1686. /// </summary>
  1687. /// <param name="dto"></param>
  1688. /// <returns></returns>
  1689. [HttpPost]
  1690. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1691. public async Task<IActionResult> GroupProcessOperation1(GroupProcessOperationDto dto)
  1692. {
  1693. #region 参数验证
  1694. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  1695. #region 页面操作权限验证
  1696. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  1697. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  1698. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  1699. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  1700. #endregion
  1701. #endregion
  1702. _sqlSugar.BeginTran();
  1703. decimal ffrPrice = 0.00M;
  1704. DateTime? visitDt = null;
  1705. if (dto.Status == 2)
  1706. {
  1707. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1708. if (groupInfo != null)
  1709. {
  1710. ffrPrice = groupInfo.PaymentMoney;
  1711. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1712. }
  1713. }
  1714. var _dto = new GroupOperationDto();
  1715. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  1716. var groupData = await _groupRepository.GroupOperation(_dto);
  1717. if (groupData.Code != 0)
  1718. {
  1719. _sqlSugar.RollbackTran();
  1720. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  1721. }
  1722. try
  1723. {
  1724. int diId = 0;
  1725. //添加时 默认加入团组汇率
  1726. if (dto.Status == 1) //添加
  1727. {
  1728. diId = groupData.Data;
  1729. //添加默认币种
  1730. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1731. //默认分配权限
  1732. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1733. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1734. var _managerIds = new List<int>() { 21, 22, 32 };
  1735. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1736. if (userIds.Count > 0)
  1737. {
  1738. userIds.Add(208);
  1739. //创建团组管控
  1740. GroupStepForDelegation.CreateWorkStep(diId);
  1741. //发送消息
  1742. string groupName = dto.TeamName;
  1743. string createGroupUser = string.Empty;
  1744. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1745. if (userInfo != null) createGroupUser = userInfo.CnName;
  1746. string title = $"系统通知";
  1747. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1748. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1749. }
  1750. #region 应用推送
  1751. try
  1752. {
  1753. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1754. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1755. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1756. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1757. {
  1758. var userList = new List<string>() { users.QiyeChatUserId };
  1759. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1760. }
  1761. }
  1762. catch (Exception ex)
  1763. {
  1764. _sqlSugar.CommitTran();
  1765. return Ok(JsonView(true, "操作成功! 应用推送异常:" + groupData.Msg));
  1766. }
  1767. #endregion
  1768. //默认创建倒推表
  1769. await _invertedListRep._Create(dto.UserId, diId);
  1770. }
  1771. else if (dto.Status == 2)
  1772. {
  1773. diId = dto.Id;
  1774. if (diId == 0)
  1775. {
  1776. _sqlSugar.RollbackTran();
  1777. return Ok(JsonView(false, "操作失败! 未添加团组id" + groupData.Msg));
  1778. }
  1779. }
  1780. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1781. if (viewData.Code != 0)
  1782. {
  1783. _sqlSugar.RollbackTran();
  1784. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1785. }
  1786. #region 团组操作默认添加/修改收款账单
  1787. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1788. {
  1789. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1790. .Where(x => x.IsDel == 0 &&
  1791. x.Diid == diId &&
  1792. x.Remark.Equals("预付款")
  1793. )
  1794. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1795. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1796. .FirstAsync();
  1797. ffrInfo = new Fin_ForeignReceivables()
  1798. {
  1799. Diid = diId,
  1800. PriceName = dto.ClientUnit,
  1801. Price = dto.PaymentMoney,
  1802. Count = 1,
  1803. Unit = $"元",
  1804. ItemSumPrice = dto.PaymentMoney,
  1805. Rate = 1.0000M,
  1806. Currency = 836,
  1807. AddingWay = 0,
  1808. CreateUserId = dto.UserId,
  1809. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1810. Remark = $"预付款"
  1811. };
  1812. if (ffrInfo == null) //Add
  1813. {
  1814. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1815. }
  1816. else //修改
  1817. {
  1818. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1819. .UpdateColumns(x => new
  1820. {
  1821. x.PriceName,
  1822. x.Price,
  1823. x.ItemSumPrice,
  1824. x.CreateTime,
  1825. x.CreateUserId
  1826. })
  1827. .WhereColumns(x => x.Id)
  1828. .ExecuteCommandAsync();
  1829. }
  1830. }
  1831. #endregion
  1832. #region 签证人员团组时间通知
  1833. #region 计算出访起止时间
  1834. var startTime = new DateTime();
  1835. var endTime = new DateTime();
  1836. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1837. {
  1838. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1839. }
  1840. #endregion
  1841. if (diId > 0)
  1842. {
  1843. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1844. }
  1845. #endregion
  1846. _sqlSugar.CommitTran();
  1847. return Ok(JsonView(true));
  1848. }
  1849. catch (Exception ex)
  1850. {
  1851. _sqlSugar.RollbackTran();
  1852. return Ok(JsonView(false, ex.Message));
  1853. }
  1854. }
  1855. /// <summary>
  1856. /// 接团信息 操作(删除)
  1857. /// </summary>
  1858. /// <param name="dto"></param>
  1859. /// <returns></returns>
  1860. [HttpPost]
  1861. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1862. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  1863. {
  1864. var diId = dto.Id;
  1865. if (diId < 1) return Ok(JsonView(false, MsgTips.Id));
  1866. #region 删除 验证
  1867. /*
  1868. * 1、收款账单数据:0 条
  1869. * 2、收款退还数据:0 条
  1870. * 3、机票费用数据:0 条
  1871. * 4、签证费用数据:0 条
  1872. * 5、保险费用数据:0 条
  1873. * 6、酒店费用数据:0 条
  1874. * 7、公务出访数据:1 条
  1875. * 8、邀请公务活动费用数据:1 条
  1876. * 9、OP费用数据:5 条
  1877. * 10、其他费用数据:0 条
  1878. * 11、团组日付报销费用数据:0 条
  1879. *
  1880. * 温馨提示:该团组已产生费用,不允许删除;如需删除,请先删除对应版块费用,谢谢!
  1881. */
  1882. //收款账单
  1883. int frCount = _sqlSugar.Queryable<Fin_ForeignReceivables>().Where(x => x.IsDel == 0 && x.Diid == diId).Count();
  1884. //收款退还
  1885. int fraomCount = _sqlSugar.Queryable<Fin_PaymentRefundAndOtherMoney>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1886. //机票费用
  1887. int arCount = _sqlSugar.Queryable<Grp_AirTicketReservations>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
  1888. //签证费用
  1889. int viCount = _sqlSugar.Queryable<Grp_VisaInfo>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
  1890. //保险费用
  1891. int cCount = _sqlSugar.Queryable<Grp_Customers>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1892. //酒店费用
  1893. int hrCount = _sqlSugar.Queryable<Grp_HotelReservations>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1894. //公务出访
  1895. int oaCount = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1896. //邀请公务活动费用
  1897. int ioaCount = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1898. //OP费用
  1899. int ctggrCount = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1900. //其他费用
  1901. int dpCount = _sqlSugar.Queryable<Grp_DecreasePayments>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1902. //团组日付报销费用
  1903. int dfpCount = _sqlSugar.Queryable<Fin_DailyFeePayment>().Where(x => x.IsDel == 0 && x.GroupId == diId).Count();
  1904. var feeCount = frCount + fraomCount + arCount + viCount + cCount + hrCount + oaCount + ioaCount + ctggrCount + dpCount + dfpCount;
  1905. if (feeCount > 0)
  1906. {
  1907. var delMsgTips = new StringBuilder();
  1908. delMsgTips.AppendLine($"1、收款账单数据:{frCount} 条");
  1909. delMsgTips.AppendLine($"2、收款退换数据:{fraomCount} 条");
  1910. delMsgTips.AppendLine($"3、机票费用数据:{arCount} 条");
  1911. delMsgTips.AppendLine($"4、签证费用数据:{viCount} 条");
  1912. delMsgTips.AppendLine($"5、保险费用数据:{cCount} 条");
  1913. delMsgTips.AppendLine($"6、酒店费用数据:{hrCount} 条");
  1914. delMsgTips.AppendLine($"7、公务出访数据:{oaCount} 条");
  1915. delMsgTips.AppendLine($"8、邀请公务活动费用数据:{ioaCount} 条");
  1916. delMsgTips.AppendLine($"9、OP费用数据:{ctggrCount} 条");
  1917. delMsgTips.AppendLine($"10、其他费用数据:{dpCount} 条");
  1918. delMsgTips.AppendLine($"11、团组日付报销费用数据:{dfpCount} 条");
  1919. delMsgTips.AppendLine($"");
  1920. delMsgTips.AppendLine($"温馨提示:该团组已产生费用,不允许删除;如需删除,请先删除对应版块费用,谢谢!");
  1921. return Ok(JsonView(false, delMsgTips.ToString()));
  1922. }
  1923. #endregion
  1924. var groupData = await _groupRepository.GroupDel(dto);
  1925. if (groupData.Code != 0)
  1926. {
  1927. return Ok(JsonView(false, groupData.Msg));
  1928. }
  1929. return Ok(JsonView(true));
  1930. }
  1931. /// <summary>
  1932. /// 获取团组销售报价号
  1933. /// 团组添加时 使用
  1934. /// </summary>
  1935. /// <returns></returns>
  1936. [HttpPost]
  1937. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1938. public async Task<IActionResult> GetGroupSalesQuoteNo()
  1939. {
  1940. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  1941. if (groupData.Code != 0)
  1942. {
  1943. return Ok(JsonView(false, groupData.Msg));
  1944. }
  1945. object salesQuoteNo = new
  1946. {
  1947. SalesQuoteNo = groupData.Data
  1948. };
  1949. return Ok(JsonView(salesQuoteNo));
  1950. }
  1951. /// <summary>
  1952. /// 设置确认出团
  1953. /// </summary>
  1954. /// <param name="dto"></param>
  1955. /// <returns></returns>
  1956. [HttpPost]
  1957. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1958. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  1959. {
  1960. var groupData = await _groupRepository.ConfirmationGroup(dto);
  1961. if (groupData.Code != 0)
  1962. {
  1963. return Ok(JsonView(false, groupData.Msg));
  1964. }
  1965. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  1966. #region OA消息推送
  1967. try
  1968. {
  1969. string groupName = groupInfo.TeamName;
  1970. var userIds = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).Select(x => x.Id).ToList();
  1971. string title = $"系统通知";
  1972. string content = $"团组[{groupName}]已确认出团!";
  1973. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  1974. }
  1975. catch (Exception ex)
  1976. {
  1977. }
  1978. #endregion
  1979. #region 应用推送
  1980. try
  1981. {
  1982. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  1983. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  1984. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1985. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1986. {
  1987. var userList = new List<string>() { users.QiyeChatUserId };
  1988. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  1989. }
  1990. }
  1991. catch (Exception ex)
  1992. {
  1993. }
  1994. #endregion
  1995. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  1996. return Ok(JsonView(true, "操作成功!", groupData.Data));
  1997. }
  1998. /// <summary>
  1999. /// 获取团组名称data And 签证国别Data
  2000. /// </summary>
  2001. /// <param name="dto"></param>
  2002. /// <returns></returns>
  2003. [HttpPost]
  2004. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2005. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  2006. {
  2007. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  2008. if (groupData.Code != 0)
  2009. {
  2010. return Ok(JsonView(false, groupData.Msg));
  2011. }
  2012. return Ok(JsonView(groupData.Data));
  2013. }
  2014. /// <summary>
  2015. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  2016. /// </summary>
  2017. /// <returns></returns>
  2018. [HttpPost]
  2019. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2020. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  2021. {
  2022. try
  2023. {
  2024. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  2025. if (groupData.Code != 0)
  2026. {
  2027. return Ok(JsonView(false, groupData.Msg));
  2028. }
  2029. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2030. }
  2031. catch (Exception ex)
  2032. {
  2033. return Ok(JsonView(false, ex.Message));
  2034. throw;
  2035. }
  2036. }
  2037. /// <summary>
  2038. /// 团组清单 Excel
  2039. /// </summary>
  2040. /// <param name="beginDt">开始时间 EG:“2024-01-01”</param>
  2041. /// <param name="endDt">结束时间 EG;“2024-12-31”</param>
  2042. /// <returns></returns>
  2043. [HttpGet]
  2044. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2045. public async Task<IActionResult> GroupListFile([FromQuery] string beginDt, [FromQuery] string endDt)
  2046. {
  2047. bool beginBool = DateTime.TryParse($"{beginDt} 00:00:00", out DateTime _beginDt),
  2048. endBool = DateTime.TryParse($"{endDt} 23:59:59", out DateTime _endDt);
  2049. if (!beginBool && !endBool)
  2050. {
  2051. return Ok(JsonView(false, "开始或结束时间不正确!"));
  2052. }
  2053. string sql = string.Format(@"
  2054. SELECT
  2055. ROW_NUMBER,
  2056. Id,
  2057. SalesQuoteNo,
  2058. TourCode,
  2059. TeamTypeId,
  2060. TeamType,
  2061. TeamLevId,
  2062. TeamLev,
  2063. TeamName,
  2064. ClientName,
  2065. ClientUnit,
  2066. VisitDate,
  2067. VisitDays,
  2068. VisitPNumber,
  2069. JietuanOperatorId,
  2070. JietuanOperator,
  2071. IsSure,
  2072. CreateUserName,
  2073. IsBid
  2074. FROM
  2075. (
  2076. SELECT
  2077. ROW_NUMBER() OVER(
  2078. ORDER BY
  2079. gdi.VisitDate Desc
  2080. ) AS ROW_NUMBER,
  2081. gdi.Id,
  2082. SalesQuoteNo,
  2083. TourCode,
  2084. ssd.Id TeamTypeId,
  2085. ssd.Name TeamType,
  2086. ssd1.Id TeamLevId,
  2087. ssd1.Name TeamLev,
  2088. TeamName,
  2089. ClientName,
  2090. ClientUnit,
  2091. VisitDate,
  2092. VisitDays,
  2093. VisitPNumber,
  2094. JietuanOperator JietuanOperatorId,
  2095. su.CnName JietuanOperator,
  2096. IsSure,
  2097. gdi.CreateTime,
  2098. su1.CnName As CreateUserName,
  2099. gdi.IsBid
  2100. FROM
  2101. Grp_DelegationInfo gdi
  2102. LEFT JOIN Sys_SetData ssd ON gdi.TeamDid = ssd.Id
  2103. LEFT JOIN Sys_SetData ssd1 ON gdi.TeamLevSId = ssd1.Id
  2104. LEFT JOIN Sys_Users su ON gdi.JietuanOperator = su.Id
  2105. LEFT JOIN Sys_Users su1 ON gdi.CreateUserId = su1.Id
  2106. WHERE
  2107. gdi.IsDel = 0
  2108. AND gdi.IsBid = 0
  2109. AND gdi.VisitDate BETWEEN '{0}' AND '{1}'
  2110. ) temp", _beginDt.ToString("yyyy-MM-dd HH:mm:ss"), _endDt.ToString("yyyy-MM-dd HH:mm:ss"));
  2111. var groupList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToListAsync();
  2112. #region 处理所属部门
  2113. /*
  2114. * 1.sq 和 gyy 等显示 市场部
  2115. * 2.王鸽和主管及张总还有管理员号统一国交部
  2116. * 2-1. 4 管理员 ,21 张海麟
  2117. */
  2118. var userIds = groupList.Select(it => it.JietuanOperatorId).ToList();
  2119. var userIds1 = new List<int>() { 4, 21 };
  2120. var userDepDatas = await _sqlSugar.Queryable<Sys_Users>()
  2121. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  2122. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  2123. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  2124. .ToListAsync();
  2125. var droupIds = groupList.Select(it => it.Id).ToList();
  2126. var deleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  2127. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  2128. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  2129. .Where((tcl, dc, cc) => tcl.IsDel == 0 && droupIds.Contains(tcl.DiId))
  2130. .Select((tcl, dc, cc) => new ClientInfoInfo_Group
  2131. {
  2132. DiId = tcl.DiId,
  2133. LastName = dc.LastName,
  2134. FirstName = dc.FirstName,
  2135. Sex = dc.Sex,
  2136. Birthday = dc.BirthDay,
  2137. Company = cc.CompanyFullName,
  2138. Job = dc.Job,
  2139. CreateTime = tcl.CreateTime,
  2140. })
  2141. .ToList();
  2142. foreach (var item in groupList)
  2143. {
  2144. item.Department = userDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  2145. string groupFirstName = "";
  2146. var currDatas = deleClientList.Where(x => x.DiId == item.Id).ToList();
  2147. if (currDatas.Any())
  2148. {
  2149. groupFirstName = AesEncryptionHelper.Decrypt(currDatas[0].LastName) + AesEncryptionHelper.Decrypt(currDatas[0].FirstName);
  2150. }
  2151. item.GroupFirst = groupFirstName;
  2152. }
  2153. #endregion
  2154. #region Excel
  2155. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  2156. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  2157. var savePath = AppSettingsHelper.Get("GrpListFileBasePath");
  2158. var ftpPath = AppSettingsHelper.Get("GrpListFileFtpPath");
  2159. var fileName = $"团组清单({beginDt}~{endDt}){DateTime.Now:yyyyMMddHHmmss}.xlsx";
  2160. //载入模板
  2161. var designer = new WorkbookDesigner
  2162. {
  2163. Workbook = new Workbook($"{tempPath}团组清单模板.xlsx")
  2164. };
  2165. designer.SetDataSource("Titel", $"团组清单({beginDt}~{endDt})");
  2166. DataTable dt = CommonFun.GetDataTableFromIList<DelegationListView>(groupList); ;
  2167. dt.TableName = "GroupList";
  2168. designer.SetDataSource(dt);
  2169. designer.Process();
  2170. if (!Directory.Exists(savePath))
  2171. {
  2172. Directory.CreateDirectory(savePath);
  2173. }
  2174. string serverPath = $"{savePath}{fileName}";
  2175. designer.Workbook.Save(serverPath);
  2176. string rst = $"{servicePath}{ftpPath}{fileName}";
  2177. #endregion
  2178. return Ok(JsonView(true, "操作成功!", rst));
  2179. }
  2180. /// <summary>
  2181. /// 团组合同下载(1.付款80% 2.付全款)
  2182. /// </summary>
  2183. /// <param name="dto"></param>
  2184. /// <returns></returns>
  2185. /// <exception cref="Exception"></exception>
  2186. [HttpPost]
  2187. public async Task<IActionResult> DownGroupContractFile(DownGroupContractFileDto dto)
  2188. {
  2189. var jw = JsonView(false);
  2190. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  2191. .FirstAsync(x => x.Id == dto.GroupId && x.IsDel == 0);
  2192. if (di == null)
  2193. {
  2194. jw.Msg = "团组Id有误!";
  2195. return Ok(jw);
  2196. }
  2197. #region 权限校验
  2198. var allDownFile = new List<int>() { 21 };
  2199. try
  2200. {
  2201. var setting = _sqlSugar.Queryable<Sys_SetData>()
  2202. .First(x => x.Id == 1418 && x.IsDel == 0);
  2203. allDownFile.AddRange(JsonConvert.DeserializeObject<List<int>>(setting.Remark));
  2204. }
  2205. catch (Exception)
  2206. { }
  2207. var guojiaoDownFile = new List<int>() { 330, 383 };
  2208. var shichangDownFile = new List<int>() { 95 };
  2209. if (allDownFile.Contains(dto.UserId))
  2210. {
  2211. }
  2212. else if (guojiaoDownFile.Contains(dto.UserId))
  2213. {
  2214. var guojiaobuDi = new List<int>() { 4, 21 };
  2215. var departmentStr = _sqlSugar.Queryable<Sys_Department>()
  2216. .LeftJoin<Sys_Users>((d, u) => d.Id == u.DepId && u.IsDel == 0)
  2217. .Where((d, u) => u.Id == di.JietuanOperator)
  2218. .Select((d, u) => d.DepName)
  2219. .First();
  2220. if (!guojiaobuDi.Contains(di.JietuanOperator) && departmentStr != "策划部" && departmentStr != "国交部")
  2221. {
  2222. jw.Msg = "暂无下载权限!";
  2223. return Ok(jw);
  2224. }
  2225. }
  2226. else if (shichangDownFile.Contains(dto.UserId))
  2227. {
  2228. var dic = new Dictionary<int, int[]>()
  2229. {
  2230. { 95, new int []{ 95 , 337 , 302, 350, 355, 357, 353 , 359 , 361, 368, 364, 366, 369} }
  2231. };
  2232. try
  2233. {
  2234. var sqSetting = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1417);
  2235. if (sqSetting != null)
  2236. {
  2237. Dictionary<int, int[]> result = JsonConvert.DeserializeObject<Dictionary<int, int[]>>(sqSetting.Remark);
  2238. foreach (var item in result.Keys)
  2239. {
  2240. if (dic.ContainsKey(item))
  2241. {
  2242. int[] dilatation = new int[dic[item].Length + result[item].Length];
  2243. Array.Copy(dic[item], dilatation, dic[item].Length);
  2244. Array.Copy(result[item], 0, dilatation, dic[item].Length, result[item].Length);
  2245. dic[item] = dilatation;
  2246. }
  2247. else
  2248. {
  2249. dic.Add(item, result[item]);
  2250. }
  2251. }
  2252. }
  2253. if (!dic[95].Contains(di.CreateUserId))
  2254. {
  2255. jw.Msg = "暂无下载权限!";
  2256. return Ok(jw);
  2257. }
  2258. }
  2259. catch (Exception)
  2260. { }
  2261. }
  2262. else if (dto.UserId == di.CreateUserId)
  2263. {
  2264. }
  2265. else
  2266. {
  2267. jw.Msg = "暂无下载权限!";
  2268. return Ok(jw);
  2269. }
  2270. #endregion
  2271. var blackCodeList = await _sqlSugar.Queryable<Air_TicketBlackCode>()
  2272. .Where(x => x.DiId == dto.GroupId && x.IsDel == 0)
  2273. .ToListAsync();
  2274. if (!blackCodeList.Any())
  2275. {
  2276. jw.Msg = "该团无机票行程代码!";
  2277. return Ok(jw);
  2278. }
  2279. var groupEnterExitCost = await _sqlSugar.Queryable<Grp_EnterExitCost>()
  2280. .FirstAsync(x => x.DiId == dto.GroupId && x.IsDel == 0);
  2281. if (groupEnterExitCost == null)
  2282. {
  2283. jw.Msg = "暂无三公费用信息!";
  2284. return Ok(jw);
  2285. }
  2286. var rateList = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(groupEnterExitCost.CurrencyRemark);
  2287. rateList ??= new List<CurrencyInfo>();
  2288. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == di.Id).ToList();
  2289. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  2290. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  2291. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  2292. .Where((x, a, b) => x.IsDel == 0 && x.Diid == di.Id)
  2293. .Select((x, a, b) => new
  2294. {
  2295. x.Index,
  2296. itemName = a.Name,
  2297. CurrencyStr = b.Name,
  2298. x.Cost,
  2299. x.SubTotal,
  2300. x.Remark
  2301. })
  2302. .OrderBy((x) => x.Index)
  2303. .ToList();
  2304. decimal stayFeeTotal = groupEnterExitCost.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  2305. decimal mealsFeeTotal = groupEnterExitCost.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  2306. decimal miscellaneousFeeTotal = groupEnterExitCost.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  2307. decimal tainFeeTotal = groupEnterExitCost.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  2308. decimal otherPriceTotal = groupEnterExitCost.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  2309. decimal insidePayTotal = groupEnterExitCost.ChoiceOne == 1 ? groupEnterExitCost.InsidePay : 0.00M;
  2310. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  2311. decimal subJJC = 0.00M,
  2312. subGWC = 0.00M,
  2313. subTDC = 0.00M;
  2314. //经济舱
  2315. if (groupEnterExitCost.SumJJC == 1)
  2316. {
  2317. subJJC = otherFeeTotal + groupEnterExitCost.OutsideJJPay;
  2318. }
  2319. //公务舱
  2320. if (groupEnterExitCost.SumGWC == 1)
  2321. {
  2322. subGWC = otherFeeTotal + groupEnterExitCost.OutsideGWPay;
  2323. }
  2324. //头等舱
  2325. if (groupEnterExitCost.SumTDC == 1)
  2326. {
  2327. subTDC = otherFeeTotal + groupEnterExitCost.OutsideTDPay;
  2328. }
  2329. var groupClints = await _sqlSugar.Queryable<Grp_TourClientList>()
  2330. .LeftJoin<Sys_SetData>((x, s) => s.Id == x.ShippingSpaceTypeId && s.IsDel == 0)
  2331. .LeftJoin<Crm_DeleClient>((x, s, dc) => x.ClientId == dc.Id && dc.IsDel == 0)
  2332. .LeftJoin<Crm_CustomerCompany>((x, s, dc, cc) => dc.CrmCompanyId == cc.Id && cc.IsDel == 0)
  2333. .Where((x, s, dc, cc) => x.DiId == dto.GroupId && x.IsDel == 0)
  2334. .Select((x, s, dc, cc) => new GroupClints
  2335. {
  2336. Id = x.Id,
  2337. Name = s.Name,
  2338. IsAccompany = x.IsAccompany,
  2339. CompanyFullName = cc.CompanyFullName
  2340. })
  2341. .ToListAsync();
  2342. groupClints.ForEach(x => x.CompanyFullName = AesEncryptionHelper.Decrypt(x.CompanyFullName));
  2343. //获取舱位人数
  2344. var cabinCount = groupClints.Where(x => x.IsAccompany != 2 && !x.CompanyFullName.Contains("泛美国际"))
  2345. .GroupBy(x => x.Name)
  2346. .Select(x => new { Cabin = x.Key, Count = x.Count() })
  2347. .ToList();
  2348. string cityPath = string.Empty;
  2349. string startCity = string.Empty;
  2350. string endCity = string.Empty;
  2351. foreach (var item in blackCodeList)
  2352. {
  2353. string city = GeneralMethod.GetGroupCityLine(item, "-");
  2354. cityPath += city + "\r\n";
  2355. if (item.Equals(blackCodeList.First()))
  2356. {
  2357. var sp = city.Split('-');
  2358. startCity = sp[0];
  2359. endCity = sp[^1];
  2360. }
  2361. }
  2362. di.VisitCountry = Regex.Replace(di.VisitCountry, @"[|-]", "、");
  2363. var bookMarkDic = new Dictionary<string, string>
  2364. {
  2365. { "ClientUnit", di.ClientUnit },
  2366. { "VisitCountry", di.VisitCountry },
  2367. { "VisitDate", di.VisitDate.ToString("yyyy年MM月dd日") },
  2368. { "VisitPNumber", di.VisitPNumber.ToString() },
  2369. { "CityPath", cityPath },
  2370. { "StartCity", startCity },
  2371. { "EndCity", endCity },
  2372. { "StayDays", $"{di.VisitDays}天{di.VisitDays - 1}晚" }
  2373. };
  2374. Document doc = null;
  2375. var percentage = 0.8M;
  2376. var fileNameadd = "预付";
  2377. if (dto.FileType == 1)
  2378. {
  2379. doc = new Document($"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Template/团组合同bookmarkFormat.doc");
  2380. }
  2381. else if (dto.FileType == 2)
  2382. {
  2383. doc = new Document($"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Template/团组合同全款无表格.doc");
  2384. percentage = 1;
  2385. fileNameadd = "全款";
  2386. }
  2387. else
  2388. {
  2389. throw new Exception("FileType有误!");
  2390. }
  2391. var builder = new DocumentBuilder(doc);
  2392. decimal totalPrice = 0.00M;
  2393. Table firstTable = (Table)doc.GetChild(NodeType.Table, 0, true);
  2394. if (firstTable != null)
  2395. {
  2396. // 遍历表格的行和单元格
  2397. foreach (Aspose.Words.Tables.Row row in firstTable.Rows)
  2398. {
  2399. for (int i = 0; i < row.Cells.Count; i++)
  2400. {
  2401. var cell = row.Cells[i];
  2402. // 读取单元格内容
  2403. string cellTextFirst = row.Cells[0].FirstParagraph.ToString(Aspose.Words.SaveFormat.Text).Trim();
  2404. if (cellTextFirst.Contains("舱位"))
  2405. {
  2406. break;
  2407. }
  2408. if (cellTextFirst == "经济舱" || cellTextFirst == "公务舱")
  2409. {
  2410. if (i == 2)
  2411. {
  2412. if (cellTextFirst == "经济舱")
  2413. {
  2414. // 设置单元格内容
  2415. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2416. cell.FirstParagraph.AppendChild(new Run(doc, subJJC.ToString())); // 添加
  2417. }
  2418. else
  2419. {
  2420. // 设置单元格内容
  2421. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2422. cell.FirstParagraph.AppendChild(new Run(doc, subGWC.ToString())); // 添加
  2423. }
  2424. }
  2425. if (i == 3)
  2426. {
  2427. var count = cabinCount.Find(x => x.Cabin == cellTextFirst)?.Count;
  2428. if (count != null)
  2429. {
  2430. // 设置单元格内容
  2431. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2432. cell.FirstParagraph.AppendChild(new Run(doc, count.ToString())); // 添加
  2433. }
  2434. }
  2435. if (i == 4)
  2436. {
  2437. var rowPrice = 0.00M;
  2438. var count = cabinCount.Find(x => x.Cabin == cellTextFirst)?.Count;
  2439. count ??= 0;
  2440. if (cellTextFirst == "经济舱")
  2441. {
  2442. rowPrice = subJJC * (int)count;
  2443. }
  2444. else
  2445. {
  2446. rowPrice = subGWC * (int)count;
  2447. }
  2448. totalPrice += rowPrice;
  2449. // 设置单元格内容
  2450. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2451. cell.FirstParagraph.AppendChild(new Run(doc, rowPrice.ToString())); // 添加
  2452. }
  2453. }
  2454. }
  2455. }
  2456. }
  2457. bookMarkDic.Add("TotalPrice", (totalPrice).ToString("#0.00"));
  2458. bookMarkDic.Add("TotalPrice1", (totalPrice * percentage).ToString("#0.00"));
  2459. bookMarkDic.Add("TotalPriceChinese", decimal.Parse((totalPrice * percentage).ToString("#0.00")).ConvertCNYUpper());
  2460. //--合同表格部分
  2461. bookMarkDic.Add("TimeNowDate", DateTime.Now.ToString("yyyy年MM月dd日"));
  2462. bookMarkDic.Add("ClientUnit1", di.ClientUnit);
  2463. bookMarkDic.Add("VisitCountry1", di.VisitCountry);
  2464. bookMarkDic.Add("DayCount", di.VisitDays.ToString());
  2465. bookMarkDic.Add("VisitingArea", di.VisitDate.ToString("yyyy年MM月dd日") + "-" + di.VisitEndDate.ToString("yyyy年MM月dd日"));
  2466. bookMarkDic.Add("CityPath1", cityPath);
  2467. bookMarkDic.Add("CityPath2", cityPath);
  2468. Table contractTable = (Table)doc.GetChild(NodeType.Table, 1, true);
  2469. if (contractTable != null)
  2470. {
  2471. //数据源
  2472. var _DayAndCostsAndCity = _sqlSugar.Queryable<Grp_DayAndCost>()
  2473. .LeftJoin<Grp_NationalTravelFee>((it, y) => it.NationalTravelFeeId == y.Id && y.IsDel == 0)
  2474. .LeftJoin<Sys_SetData>((it, y, s) => s.IsDel == 0 && s.Id == it.Currency)
  2475. .Where((it, y, s) => it.IsDel == 0 && it.DiId == di.Id)
  2476. .Select((it, y, s) => new
  2477. {
  2478. it.Cost,
  2479. it.SubTotal,
  2480. it.Type,
  2481. y.Id,
  2482. y.City,
  2483. s.Name,
  2484. CurrencyCodeCn = s.Remark
  2485. })
  2486. .ToList()
  2487. .Select(x => new
  2488. {
  2489. CurrencyCode = x.Name,
  2490. CityId = x.Id,
  2491. x.City,
  2492. di.VisitPNumber,
  2493. x.Type,
  2494. x.Cost,
  2495. x.SubTotal,
  2496. rateList.Find(y => y.CurrencyCode == x.Name)?.Rate,
  2497. x.CurrencyCodeCn,
  2498. });
  2499. var dac1 = _DayAndCostsAndCity.Where(it => it.Type == 1).GroupBy(x => x.CityId).ToList(); //住宿费
  2500. var dac2 = _DayAndCostsAndCity.Where(it => it.Type == 2).GroupBy(x => x.CityId).ToList(); //伙食费
  2501. var dac3 = _DayAndCostsAndCity.Where(it => it.Type == 3).GroupBy(x => x.CityId).ToList(); //公杂费
  2502. var dac4 = _DayAndCostsAndCity.Where(it => it.Type == 4).GroupBy(x => x.CityId).ToList(); //培训费
  2503. var tableSettings = new List<tableSetting>()
  2504. {
  2505. new(){ Index = 1 , Property = "City"},
  2506. new(){ Index = 2 , Property = "CurrencyCodeCn"},
  2507. new(){ Index = 3 , Property = "Cost"},
  2508. new(){ Index = 4 , Property = "VisitPNumber"},
  2509. //new tableSetting{ Index = 5 , Property = ""},
  2510. //new tableSetting{ Index = 6 , Property = ""},
  2511. new(){ Index = 7 , Property = "Rate"},
  2512. //new tableSetting{ Index = 8 , Property = ""},
  2513. };
  2514. //1.住宿费
  2515. int cloneRow = 8;
  2516. int startDayPrice = 8; //写入index
  2517. decimal ZSPriceSum = 0.00M, HSPriceSum = 0.00M, GZPriceSum = 0.00M;
  2518. foreach (var dac in dac1)
  2519. {
  2520. var first = dac.First();
  2521. var dayCount = dac.Count();
  2522. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2523. for (int i = 1; i < row.Cells.Count; i++)
  2524. {
  2525. var cell = row.Cells[i];
  2526. var findProperty = tableSettings.Find(x => x.Index == i);
  2527. if (findProperty != null)
  2528. {
  2529. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2530. // 设置单元格内容
  2531. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2532. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2533. }
  2534. else
  2535. {
  2536. switch (i)
  2537. {
  2538. case 5:
  2539. cell.FirstParagraph.Runs.Clear();
  2540. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2541. break;
  2542. case 6:
  2543. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2544. cell.FirstParagraph.Runs.Clear();
  2545. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2546. break;
  2547. case 8:
  2548. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2549. cell.FirstParagraph.Runs.Clear();
  2550. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2551. ZSPriceSum += xiaojiRMB;
  2552. break;
  2553. default:
  2554. break;
  2555. }
  2556. }
  2557. }
  2558. startDayPrice++;
  2559. if (!dac1.Last().Equals(dac))
  2560. {
  2561. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2562. // 将克隆的行追加到原行后面
  2563. contractTable.Rows.Insert(startDayPrice, newRow);
  2564. }
  2565. else
  2566. {
  2567. cloneRow += dac1.Count + 1;
  2568. startDayPrice = cloneRow;
  2569. }
  2570. }
  2571. //2.伙食费
  2572. foreach (var dac in dac2)
  2573. {
  2574. var first = dac.First();
  2575. var dayCount = dac.Count();
  2576. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2577. for (int i = 1; i < row.Cells.Count; i++)
  2578. {
  2579. var cell = row.Cells[i];
  2580. var findProperty = tableSettings.Find(x => x.Index == i);
  2581. if (findProperty != null)
  2582. {
  2583. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2584. // 设置单元格内容
  2585. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2586. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2587. }
  2588. else
  2589. {
  2590. switch (i)
  2591. {
  2592. case 5:
  2593. cell.FirstParagraph.Runs.Clear();
  2594. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2595. break;
  2596. case 6:
  2597. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2598. cell.FirstParagraph.Runs.Clear();
  2599. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2600. break;
  2601. case 8:
  2602. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2603. cell.FirstParagraph.Runs.Clear();
  2604. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2605. HSPriceSum += xiaojiRMB;
  2606. break;
  2607. default:
  2608. break;
  2609. }
  2610. }
  2611. }
  2612. startDayPrice++;
  2613. if (!dac2.Last().Equals(dac))
  2614. {
  2615. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2616. // 将克隆的行追加到原行后面
  2617. contractTable.Rows.Insert(startDayPrice, newRow);
  2618. }
  2619. else
  2620. {
  2621. cloneRow += dac2.Count + 1;
  2622. startDayPrice = cloneRow;
  2623. }
  2624. }
  2625. //3.公杂费
  2626. foreach (var dac in dac3)
  2627. {
  2628. var first = dac.First();
  2629. var dayCount = dac.Count();
  2630. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2631. for (int i = 1; i < row.Cells.Count; i++)
  2632. {
  2633. var cell = row.Cells[i];
  2634. var findProperty = tableSettings.Find(x => x.Index == i);
  2635. if (findProperty != null)
  2636. {
  2637. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2638. // 设置单元格内容
  2639. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2640. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2641. }
  2642. else
  2643. {
  2644. switch (i)
  2645. {
  2646. case 5:
  2647. cell.FirstParagraph.Runs.Clear();
  2648. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2649. break;
  2650. case 6:
  2651. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2652. cell.FirstParagraph.Runs.Clear();
  2653. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2654. break;
  2655. case 8:
  2656. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2657. cell.FirstParagraph.Runs.Clear();
  2658. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2659. GZPriceSum += xiaojiRMB;
  2660. break;
  2661. default:
  2662. break;
  2663. }
  2664. }
  2665. }
  2666. startDayPrice++;
  2667. if (!dac3.Last().Equals(dac))
  2668. {
  2669. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2670. // 将克隆的行追加到原行后面
  2671. contractTable.Rows.Insert(startDayPrice, newRow);
  2672. }
  2673. else
  2674. {
  2675. cloneRow += dac3.Count + 1;
  2676. startDayPrice = cloneRow;
  2677. }
  2678. }
  2679. //合并单元格
  2680. for (int i = 8; i < contractTable.Rows.Count - 1; i++)
  2681. {
  2682. var currentRow = contractTable.Rows[i];
  2683. var nextRow = contractTable.Rows[i + 1];
  2684. // 获取当前行和下一行的第一个单元格
  2685. Cell currentCell = currentRow.Cells[0];
  2686. Cell nextCell = nextRow.Cells[0];
  2687. // 检查单元格内容是否一致(去除尾部的换行符)
  2688. string currentText = currentCell.GetText().Trim();
  2689. string nextText = nextCell.GetText().Trim();
  2690. if (currentText == nextText)
  2691. {
  2692. // 如果当前单元格已经被合并,找到合并的起始单元格
  2693. if (currentCell.CellFormat.VerticalMerge == CellMerge.Previous)
  2694. {
  2695. // 找到合并的起始单元格
  2696. int mergeStartIndex = FindMergeStartRowIndex(contractTable, i);
  2697. // 将下一行的单元格设置为合并的后续单元格
  2698. nextCell.CellFormat.VerticalMerge = CellMerge.Previous;
  2699. }
  2700. else
  2701. {
  2702. // 如果当前单元格是合并的起始单元格
  2703. currentCell.CellFormat.VerticalMerge = CellMerge.First;
  2704. // 将下一行的单元格设置为合并的后续单元格
  2705. nextCell.CellFormat.VerticalMerge = CellMerge.Previous;
  2706. }
  2707. }
  2708. else
  2709. {
  2710. // 如果内容不一致,重置当前单元格的合并属性
  2711. if (currentCell.CellFormat.VerticalMerge == CellMerge.Previous)
  2712. {
  2713. // 如果当前单元格是合并的后续单元格,找到合并的起始单元格并重置
  2714. int mergeStartIndex = FindMergeStartRowIndex(contractTable, i);
  2715. contractTable.Rows[mergeStartIndex].Cells[0].CellFormat.VerticalMerge = CellMerge.First;
  2716. }
  2717. else
  2718. {
  2719. currentCell.CellFormat.VerticalMerge = CellMerge.None;
  2720. }
  2721. }
  2722. }
  2723. bookMarkDic.Add("ZSPriceSum", ZSPriceSum.ToString("F2"));
  2724. bookMarkDic.Add("HSPriceSum", HSPriceSum.ToString("F2"));
  2725. bookMarkDic.Add("GZPriceSum", GZPriceSum.ToString("F2"));
  2726. }
  2727. foreach (var bookmarkName in bookMarkDic.Keys)
  2728. {
  2729. Bookmark bookmark = doc.Range.Bookmarks[bookmarkName];
  2730. if (bookmark != null)
  2731. {
  2732. if (bookmarkName == "ClientUnit")
  2733. {
  2734. // 移动到书签位置
  2735. builder.MoveTo(bookmark.BookmarkStart);
  2736. // 设置字体样式为下划线
  2737. builder.Font.Underline = Aspose.Words.Underline.Single;
  2738. // 插入书签值
  2739. builder.Write(bookMarkDic[bookmarkName]);
  2740. // 清除字体格式,避免影响后续文本
  2741. builder.Font.ClearFormatting();
  2742. }
  2743. else
  2744. {
  2745. builder.MoveToBookmark(bookmarkName);
  2746. builder.Write(bookMarkDic[bookmarkName]);
  2747. }
  2748. }
  2749. }
  2750. string savePaht = $"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Export/{di.TeamName}_{fileNameadd}版本合同文件.doc";
  2751. doc.Save(savePaht);
  2752. jw.Msg = "生成成功!";
  2753. jw.Code = 200;
  2754. jw.Data = new { Url = AppSettingsHelper.Get("WordBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("WordBasePath"), AppSettingsHelper.Get("WordFtpPath")) };
  2755. return Ok(jw);
  2756. }
  2757. static int FindMergeStartRowIndex(Table table, int rowIndex)
  2758. {
  2759. int index = rowIndex;
  2760. while (index > 0 && table.Rows[index].Cells[0].CellFormat.VerticalMerge == CellMerge.Previous)
  2761. {
  2762. index--;
  2763. }
  2764. return index;
  2765. }
  2766. /// <summary>
  2767. /// 报批完成企微通知
  2768. /// </summary>
  2769. /// <param name="dto"></param>
  2770. /// <returns></returns>
  2771. [HttpPost]
  2772. public async Task<IActionResult> EnterpriseWeChatNotificationAsyncBaoPi(EnterpriseWeChatNotificationAsyncBaoPiDto dto)
  2773. {
  2774. int currUserId = dto.currUserId;
  2775. int diid = dto.diid;
  2776. var jw = JsonView(true);
  2777. var users = new List<string>();
  2778. var ssd = _sqlSugar.Queryable<Sys_SetData>()
  2779. .First(x => x.Id == 1460);
  2780. try
  2781. {
  2782. users = JsonConvert.DeserializeObject<List<string>>(ssd.Remark);
  2783. var groupModuleOperators = GeneralMethod.GetGroupModuleOperators(dto.diid);
  2784. //添加分配人员
  2785. // 79 车/导游地接
  2786. // 80 签证
  2787. // 81 邀请/公务活动
  2788. var setdataids = new List<int>() { 79, 81 };
  2789. foreach (var groupModule in groupModuleOperators)
  2790. {
  2791. if (setdataids.Contains(groupModule.CTableId))
  2792. {
  2793. users.AddRange(groupModule.OperationUsers.Select(x => x.UserId.ToString()));
  2794. }
  2795. }
  2796. var res = await AppNoticeLibrary.SendUserMsg_BaoPi_ToUser(users, diid);
  2797. //消息通知成功 更改团组step、记录日志
  2798. if (res)
  2799. {
  2800. var groupStep = 0; //0-新建 1-企微消息通知
  2801. //更改团组step
  2802. var updStatus = await _sqlSugar.Updateable<Grp_DelegationInfo>()
  2803. .SetColumns(x => new Grp_DelegationInfo()
  2804. {
  2805. Step = 2
  2806. })
  2807. .Where(x => x.Id == diid && x.IsDel == 0)
  2808. .ExecuteCommandAsync();
  2809. if (updStatus > 0) groupStep = 2;
  2810. string groupStepLabel = groupStep switch
  2811. {
  2812. 1 => "新建",
  2813. 2 => "企微消息通知(报批)",
  2814. _ => "未设置"
  2815. };
  2816. //记录日志
  2817. var teamName = _sqlSugar.Queryable<Grp_DelegationInfo>()
  2818. .Where(x => x.Id == diid && x.IsDel == 0)
  2819. .Select(x => x.TeamName)
  2820. .First() ?? "-";
  2821. var operationName = _sqlSugar.Queryable<Sys_Users>()
  2822. .Where(x => x.Id == currUserId && x.IsDel == 0)
  2823. .Select(x => x.CnName)
  2824. .First() ?? "-";
  2825. _groupTextLogger.LogInformation("团组:【{teamName}({groupId})】 操作人:【{operationName}】 操作时间:【{operationTime}】{logContent}", teamName, diid, operationName, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), groupStepLabel);
  2826. //设置 签证流程初始值
  2827. await _visaProcessRep.UpdateBatchTop4Step(dto.diid, dto.currUserId);
  2828. }
  2829. }
  2830. catch (Exception ex)
  2831. {
  2832. return Ok(JsonView(false, ex.Message));
  2833. }
  2834. return Ok(jw);
  2835. }
  2836. #endregion
  2837. #region 团组&签证
  2838. #region 团组&签证 New
  2839. /// <summary>
  2840. /// 团组&签证 New
  2841. /// DeepSeek API:测试API连通性
  2842. /// </summary>
  2843. /// <param name="file">请求dto</param>
  2844. /// <returns></returns>
  2845. [HttpPost]
  2846. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2847. public async Task<IActionResult> TestDeepSeekApiConnectivityAsync()
  2848. {
  2849. return Ok(JsonView(await _deepSeekService.TestApiConnectivityAsync()));
  2850. }
  2851. /// <summary>
  2852. /// 团组&签证 New
  2853. /// DeepSeek API:检查可用端点
  2854. /// </summary>
  2855. /// <param name="file">请求dto</param>
  2856. /// <returns></returns>
  2857. [HttpPost]
  2858. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2859. public async Task<IActionResult> DiscoverAvailableEndpointsAsync()
  2860. {
  2861. return Ok(JsonView(await _deepSeekService.DiscoverAvailableEndpointsAsync()));
  2862. }
  2863. /// <summary>
  2864. /// 团组&签证 New
  2865. /// 上传签证文件(客户填写签证文件),新增或更新 签证信息
  2866. /// </summary>
  2867. /// <param name="visaFile">文件</param>
  2868. /// <param name="fileTypeId">
  2869. /// 1. 澳新签证个人申请表
  2870. /// 2. 出国个人申请表
  2871. /// 3. 美国签证个人申请表格
  2872. /// 4. 沙特个人信息表格
  2873. /// 5. 申根签证个人资料表
  2874. /// 6. 中文个人简历模板
  2875. /// </param>
  2876. /// <returns></returns>
  2877. [HttpPost]
  2878. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2879. public async Task<IActionResult> VisaFileUploadAndUpdate(IFormFile visaFile, int fileTypeId)
  2880. {
  2881. //文件验证
  2882. if (visaFile.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  2883. //var visaFiles = new VisaUploadFileTypeView();
  2884. //var filetypes = VisaUploadFileTypeView.GetVisaUploadFileTypeViewItemInit();
  2885. //if (!filetypes.Any(x => x.FileId == fileTypeId)) return Ok(JsonView(false, "请选择文件类型!"));
  2886. //服务器存储文件
  2887. var fileServerPath = $"D:/FTP/File/OA2023/Office/Word/VisaClientData/Uploads";
  2888. if (!Directory.Exists(fileServerPath)) Directory.CreateDirectory(fileServerPath);
  2889. var filePath = Path.Combine(fileServerPath, visaFile.FileName);
  2890. using (var stream = new FileStream(filePath, FileMode.Create))
  2891. {
  2892. await visaFile.CopyToAsync(stream);
  2893. }
  2894. //日志记录-上传文件
  2895. _logger.LogInformation("【签证上传文件操作信息】签证文件存储成功!路径:{fileServerPath} 文件名称:{fileName}", fileServerPath, visaFile.FileName);
  2896. #region 上传文件到DeepSeekAPI
  2897. //IFormFile localFile = null;
  2898. ////获取项目中的cs文件
  2899. //try
  2900. //{
  2901. // _logger.LogInformation("读取并上传项目文件请求");
  2902. // // 1. 读取项目文件
  2903. // var readResponse = await _deepSeekService.ReadProjectFilesAsync(new List<string>() { @"OASystem.Domain\ViewModels\VisaFormDetails\AusNewVisaApplicationForm.cs" });
  2904. // if (readResponse.SuccessCount == 0)
  2905. // {
  2906. // return Ok(JsonView(false, "读取项目文件失败"));
  2907. // }
  2908. // localFile = readResponse.FileInfos.FirstOrDefault().FormFile;
  2909. //}
  2910. //catch (Exception ex)
  2911. //{
  2912. // _logger.LogError(ex, "读取项目文件失败");
  2913. // return Ok(JsonView(false, "读取项目文件失败"));
  2914. //}
  2915. //if (localFile == null)
  2916. //{
  2917. // return Ok(JsonView(false, "读取项目文件失败"));
  2918. //}
  2919. //var fileReq = new DeepSeekFileUploadRequest()
  2920. //{
  2921. // Files = new List<IFormFile> { localFile, visaFile },
  2922. //};
  2923. //var filesResult = new List<FileUploadResult>();
  2924. //try
  2925. //{
  2926. // _logger.LogInformation("开始上传 {FileCount} 个文件到DeepSeek API", fileReq.Files.Count);
  2927. // filesResult = await _deepSeekService.UploadFilesAsync(fileReq.Files, fileReq.Purpose);
  2928. // // 需要等待处理完成
  2929. // if (fileReq.WaitForProcessing)
  2930. // {
  2931. // foreach (var result in filesResult)
  2932. // {
  2933. // if (result.Success)
  2934. // {
  2935. // try
  2936. // {
  2937. // var processedFile = await _deepSeekService.WaitForFileProcessingAsync(result.FileId);
  2938. // result.Status = processedFile.Status;
  2939. // }
  2940. // catch (Exception ex)
  2941. // {
  2942. // _logger.LogError(ex, "DeepSeek API文件上传失败");
  2943. // return Ok(JsonView(false, $"DeepSeek API文件上传处理失败: {ex.Message}"));
  2944. // }
  2945. // }
  2946. // }
  2947. // }
  2948. //}
  2949. //catch (Exception ex)
  2950. //{
  2951. // _logger.LogError(ex, "DeepSeek API文件上传失败");
  2952. // return Ok(JsonView(false, $"DeepSeek API文件上传处理失败: {ex.Message}"));
  2953. //}
  2954. //#endregion
  2955. //if (filesResult == null || filesResult.Count < 1)
  2956. //{
  2957. // return Ok(JsonView(false, $"DeepSeek API文件上传处理失败"));
  2958. //}
  2959. ////
  2960. //try
  2961. //{
  2962. // var fileIds = filesResult.Where(x => x.Success).Select(x => x.FileId).ToList();
  2963. // _logger.LogInformation("使用 {FileCount} 个文件进行聊天", fileIds.Count);
  2964. // string question = string.Format("将上传的文件内容按照识别为JSON格式,并按照 AusNewVisaApplicationForm 指定的实体类结构进行映射。确保字段和值对应、文档中数据的完整性、复选框选择打勾后的文本。第一项从不识别\"比如美国(2024年7月29日)\"相关文字。");
  2965. // var response = await _deepSeekService.ChatWithFilesAsync(fileIds, question);
  2966. // return Ok(response);
  2967. //}
  2968. //catch (Exception ex)
  2969. //{
  2970. // _logger.LogError(ex, "使用文件聊天失败");
  2971. // return Ok(JsonView(false, $"聊天失败: {ex.Message}"));
  2972. //}
  2973. #endregion
  2974. #region kimi API
  2975. //加载文件OpCarTouristGuideGroundContent
  2976. //kimi AI 识别文档返回json结果
  2977. int kimiAI_API_Index = 0; //KIMI-AI-API 访问计次
  2978. var KiMiApi = new KiMiApiClient();
  2979. var files = new List<IFormFile>() { visaFile };
  2980. var seedConter = await KiMiApi.UploadFilesAsync(files);
  2981. if (seedConter.Count == 0) return Ok(JsonView(false, "Kimi AI 文件上传结果为空!"));
  2982. //var seedMessage = filetypes.Where(x => x.FileId == fileTypeId).FirstOrDefault()?.KimiAITips;
  2983. var seedMessage = string.Format(@"你是领事馆电子材料审核员,只关注 Word 里的表格,正文、页眉页脚、水印、批注全部忽略。
  2984. 任务:把表格里的每个可填字段转换成“标题:值”的键值对,标题用原文,值用原文,不翻译。
  2985. 规则如下:
  2986. 1. 行列对齐:先按视觉补齐所有合并单元格——纵向合并则重复上方单元格内容,横向合并则留空字符串;无线表按对齐虚拟列线。
  2987. 2. 单格内出现多个“□”时,把被勾选(☑、√、×、■)的选项原文输出;若没有任何勾选,该字段输出 null。
  2988. 3. 所有日期统一转 yyyy-mm-dd,原格式“1990年1月1日”→1990-01-01;若缺日/月,用-01补位。
  2989. 4. 电话、传真、手机号:输出连续数字,遇到“(0 )”或“-”一律删除,只保留 7~15 位数字;若缺区号,原样保留。
  2990. 5. 金额:保留原数字,如“3000”。
  2991. 6. 地址:省、市、区、街道、门牌、邮编用空格分隔,不省略。
  2992. 7. 若同一张表出现“现住址”“家庭地址”“单位地址”等多列,依次编号 address_home / address_unit / address_legal。
  2993. 8. 输出顺序:按表格从左到右、从上到下逐行扫描,字段名重复时加序号,如 child_name_1、child_name_2。
  2994. 9. 结果格式:每行一个键值对,字段名与值之间用英文冒号+空格分隔,不要表格 Markdown,不要多余说明。
  2995. 10. 文件命名空间:每份表的最前面加一行 filename 作为起始标记(例:出国个人申请表.doc)。
  2996. 11. 内容为空的字段,显示标题,记空值。
  2997. 12. 只返回json结果,不需要其他内容;json内容去掉换行。");
  2998. var messages = new List<SeedMessages>
  2999. {
  3000. new() { Role = KimiRole.system, Content = "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长识别文件为Json格式的对话。你会为用户提供安全,有帮助,准确的回答。同时,你会拒绝一切涉及恐怖主义,种族歧视,黄色暴力等问题的回答。Moonshot AI 为专有名词,不可翻译成其他语言。" },
  3001. new() { Role = KimiRole.user, Content = seedMessage }
  3002. };
  3003. messages.InsertRange(1, seedConter);
  3004. string jsonString = string.Empty;
  3005. object jsonData = null;
  3006. bool isJson = false; // 是否是json格式 不是json格式继续访问AI
  3007. while (!isJson)
  3008. {
  3009. kimiAI_API_Index++;
  3010. var kimiApiResult = await KiMiApi.SeedMessage(messages);
  3011. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  3012. jsonString += kimiApiResult_JObject["content"].ToString();
  3013. string startStr = "```json", endStr = "```";
  3014. // 判断并清除开头部分
  3015. if (jsonString.StartsWith(startStr))
  3016. {
  3017. jsonString = jsonString.Replace(startStr, "");
  3018. }
  3019. // 判断并清除结尾部分
  3020. if (jsonString.EndsWith(endStr))
  3021. {
  3022. jsonString = jsonString.Replace(endStr, "");
  3023. }
  3024. //验证json格式是否正确
  3025. try
  3026. {
  3027. jsonData = JsonDocument.Parse(jsonString);
  3028. isJson = true; // 如果解析成功,则是json格式
  3029. }
  3030. catch (Exception)
  3031. {
  3032. //messages = new List<SeedMessages>() { new() { Role = KimiRole.user, Content = "接着说" } };
  3033. messages.Add(new() { Role = KimiRole.user, Content = "接着上一个话题继续完成未完成的内容。" });
  3034. }
  3035. }
  3036. if (jsonData == null)
  3037. {
  3038. return Ok(JsonView(false, "kimi识别json转换失败。"));
  3039. }
  3040. var visaDetails = new VisaDetailsView();
  3041. //按照表格类型分别进行参数处理
  3042. // 1. 澳新签证个人申请表
  3043. // 2. 出国个人申请表
  3044. // 3. 美国签证个人申请表格
  3045. // 4. 沙特个人信息表格
  3046. // 5. 申根签证个人资料表
  3047. // 6. 中文个人简历模板
  3048. switch (fileTypeId)
  3049. {
  3050. //澳新签证个人申请表
  3051. case 1:
  3052. _logger.LogInformation("【签证上传文件操作信息】【澳新签证个人申请表】【KIMI-AI-API访问计次】{count} 次", kimiAI_API_Index);
  3053. VisaApplication resInfo = System.Text.Json.JsonSerializer.Deserialize<VisaApplication>(jsonString);
  3054. break;
  3055. //美国签证个人申请表格
  3056. case 3:
  3057. _logger.LogInformation("【签证上传文件操作信息】【美国签证个人申请表格】【KIMI-AI-API访问计次】{count} 次", kimiAI_API_Index);
  3058. string name = (string)jsonData.GetType().GetProperty("姓名")!.GetValue(jsonData)!;
  3059. string passportNo = (string)jsonData.GetType().GetProperty("护照号码")!.GetValue(jsonData)!;
  3060. string passportPlace = (string)jsonData.GetType().GetProperty("护照签发地")!.GetValue(jsonData)!;
  3061. string idNo = (string)jsonData.GetType().GetProperty("身份证号码")!.GetValue(jsonData)!;
  3062. string maritalStatusText = (string)jsonData.GetType().GetProperty("婚姻状况")!.GetValue(jsonData)!;
  3063. int maritalStatus = maritalStatusText switch
  3064. {
  3065. "未设置" => 0,
  3066. "未婚" => 1,
  3067. "已婚" => 2,
  3068. "离异" => 3,
  3069. "丧偶" => 4,
  3070. _ => -1
  3071. };
  3072. string birthDay = (string)jsonData.GetType().GetProperty("出生日期")!.GetValue(jsonData)!;
  3073. DateTime.TryParse(birthDay, out DateTime birthDayDt);
  3074. string birthPlace = (string)jsonData.GetType().GetProperty("出生地点")!.GetValue(jsonData)!;
  3075. var birthDay1 = CommonFun.SplitProvinceCity(birthPlace);
  3076. string birthDay_mate = (string)jsonData.GetType().GetProperty("配偶出生日期")!.GetValue(jsonData)!;
  3077. DateTime.TryParse(birthDay_mate, out DateTime birthDayDt_mate);
  3078. string birthPlace_mate = (string)jsonData.GetType().GetProperty("配偶出生地")!.GetValue(jsonData)!;
  3079. var birthDay1_mate = CommonFun.SplitProvinceCity(birthPlace_mate);
  3080. var addressText = (string)jsonData.GetType().GetProperty("家庭地址")!.GetValue(jsonData)!;
  3081. var address = SplitAddressZip(addressText);
  3082. //美国驾照信息
  3083. string driveText = (string)jsonData.GetType().GetProperty("是否有美国驾照")!.GetValue(jsonData)!;
  3084. var driveInfo = LicenseParser(driveText);
  3085. //美国社会安全号或者纳税ID号
  3086. string ssnText = (string)jsonData.GetType().GetProperty("是否有美国社会安全号或者纳税ID号")!.GetValue(jsonData)!;
  3087. //单位信息
  3088. string clientName = (string)jsonData.GetType().GetProperty("目前就职单位或就读学校")!.GetValue(jsonData)!;
  3089. string clientAddr = (string)jsonData.GetType().GetProperty("目前就职单位或就读学校地址")!.GetValue(jsonData)!;//
  3090. var (hasSsnItin, number) = SsnItinParser(ssnText);
  3091. //婚姻相关
  3092. var WeddingText = (string)jsonData.GetType().GetProperty("若离婚,婚姻起止时间")!.GetValue(jsonData)!;
  3093. var (f, t) = WeddingParser(WeddingText);
  3094. //美国联系人电话和邮箱
  3095. var peText = (string)jsonData.GetType().GetProperty("联系人电话及邮箱")!.GetValue(jsonData)!;
  3096. var usa_phone = Regex.Match(peText ?? "", @"[\d-]+").Value; // 数字和中横线
  3097. var usa_email = Regex.Match(peText ?? "", @"[^@\s]+@[^@\s]+\.[^@\s]+").Value;
  3098. //赴美时间、停留时间处理
  3099. var usa_dateText = (string)jsonData.GetType().GetProperty("联系人电话及邮箱")!.GetValue(jsonData)!;
  3100. var (usa_d, usa_days) = TravelParser(usa_dateText);
  3101. //赴美同行人
  3102. string usaCmpNameText = (string)jsonData.GetType().GetProperty("赴美同行人")!.GetValue(jsonData)!;
  3103. string usaCmpName = string.Empty;
  3104. if (usaCmpNameText.Contains("是"))
  3105. {
  3106. var usaCmpNameTextSplit = usaCmpNameText.Replace(":", "-").Replace("", "-").Split("-");
  3107. if (usaCmpNameTextSplit.Length > 1)
  3108. {
  3109. usaCmpName = usaCmpNameTextSplit[1];
  3110. }
  3111. }
  3112. //是否丢失过护照
  3113. string loseCodeText = (string)jsonData.GetType().GetProperty("是否丢失过护照")!.GetValue(jsonData)!;
  3114. string loseCode = string.Empty;
  3115. if (loseCodeText.Contains("是"))
  3116. {
  3117. var loseCodeTextSplit = loseCodeText.Replace(":", "-").Replace("", "-").Split("-");
  3118. if (loseCodeTextSplit.Length > 1)
  3119. {
  3120. usaCmpName = loseCodeTextSplit[1];
  3121. }
  3122. }
  3123. //是否获得过美国签证
  3124. string usaVisaText = (string)jsonData.GetType().GetProperty("是否丢失过护照")!.GetValue(jsonData)!;
  3125. string usaVisaDateText = (string)jsonData.GetType().GetProperty("获得日期")!.GetValue(jsonData)!;
  3126. //DateTime usaVisaDate;
  3127. if (!string.IsNullOrEmpty(usaVisaDateText))
  3128. {
  3129. if (DateTime.TryParse(usaVisaDateText, out DateTime usaVisaDate))
  3130. {
  3131. visaDetails.ClientInfo.GetUSAVisaDate = usaVisaDate;
  3132. }
  3133. }
  3134. string usaFingerText = (string)jsonData.GetType().GetProperty("是否留过十指指纹")!.GetValue(jsonData)!;
  3135. int usaFinger = 0;
  3136. if (usaFingerText.Contains('是')) usaFinger = 1;
  3137. string usaLoseText = (string)jsonData.GetType().GetProperty("签证是否曾遗失")!.GetValue(jsonData)!;
  3138. int usaLose = 0;
  3139. if (usaLoseText.Contains("是")) usaLose = 1;
  3140. //是否曾抵达过美国
  3141. string usaHadArrival‌Text = (string)jsonData.GetType().GetProperty("是否曾抵达过美国")!.GetValue(jsonData)!;
  3142. var (usaHadArrivalf, usaHadArrivalD, usaHadArrivalDays) = TravelHadFlagParser(usaHadArrival‌Text);
  3143. //是否有被美国拒发签证的经历
  3144. string usaRejecteVisaTest = (string)jsonData.GetType().GetProperty("是否有被美国拒发签证的经历")!.GetValue(jsonData)!;
  3145. var (denied, rejectedDate, rejectedPlace, rejectedType) = VisaDenialParser(usaRejecteVisaTest);
  3146. if (denied)
  3147. {
  3148. visaDetails.ClientInfo.RejectedDate = rejectedDate;
  3149. visaDetails.ClientInfo.RejectedPlace = rejectedPlace;
  3150. visaDetails.ClientInfo.RejectedVisa = rejectedType;
  3151. }
  3152. //是否在申请或曾经申请过美国移民签证
  3153. string usaImmVisaText‌ = (string)jsonData.GetType().GetProperty("是否在申请或曾经申请过美国移民签证")!.GetValue(jsonData)!;
  3154. var (immDenied, immDate, immPlace, immType) = VisaDenialParser(usaImmVisaText‌);
  3155. if (immDenied)
  3156. {
  3157. visaDetails.ClientInfo.USAImmVisa‌Date = immDate;
  3158. visaDetails.ClientInfo.USAImmVisa‌Place = immPlace;
  3159. visaDetails.ClientInfo.USAImmVisa‌ = immType;
  3160. }
  3161. //在美直系
  3162. string usaImmedText‌ = (string)jsonData.GetType().GetProperty("是否有直系亲属在美国")!.GetValue(jsonData)!;
  3163. var (immedDenied, immedName, immedRel, immedStat) = FourFieldParser(usaImmedText‌);
  3164. if (immedDenied)
  3165. {
  3166. visaDetails.ClientInfo.USAImmedFamName = immedName;
  3167. visaDetails.ClientInfo.USAImmedFamRel = immedRel;
  3168. visaDetails.ClientInfo.USAImmedFamStat = immedStat;
  3169. }
  3170. //在美旁系
  3171. string usaUncleText‌ = (string)jsonData.GetType().GetProperty("是否有旁系亲属在美国")!.GetValue(jsonData)!;
  3172. var (uncleDenied, uncleName, uncleRel, uncleStat) = FourFieldParser(usaUncleText‌);
  3173. if (immedDenied)
  3174. {
  3175. visaDetails.ClientInfo.USAUncleFamName = uncleName;
  3176. visaDetails.ClientInfo.USAUncleFamRel = uncleName;
  3177. visaDetails.ClientInfo.USAUncleFamStat = uncleStat;
  3178. }
  3179. //服役时间 MilitaryParser
  3180. string militaryText‌ = (string)jsonData.GetType().GetProperty("是否曾参过军")!.GetValue(jsonData)!;
  3181. var (militaryH, militaryB, militaryR, militaryS, (militaryStart, militaryEnd)) = MilitaryParser(militaryText‌);
  3182. var militarys = new List<MilitaryInfo>();
  3183. if (militaryH)
  3184. {
  3185. militarys.Add(new()
  3186. {
  3187. MilBranch = militaryB,
  3188. MilRank = militaryR,
  3189. MilSkill = militaryS,
  3190. ServeTimeBegin = militaryStart,
  3191. ServeTimeEnd = militaryEnd,
  3192. });
  3193. }
  3194. //申请人父母信息 ParentParser
  3195. string fthMthText‌ = (string)jsonData.GetType().GetProperty("申请人父母信息")!.GetValue(jsonData)!;
  3196. if (!string.IsNullOrEmpty(fthMthText‌))
  3197. {
  3198. var (fName, fDob, mName, mDob) = ParentParser(fthMthText‌);
  3199. visaDetails.ClientInfo.FthName = fName;
  3200. visaDetails.ClientInfo.FthBirth = fDob;
  3201. visaDetails.ClientInfo.MthName = mName;
  3202. visaDetails.ClientInfo.MthBirth = mDob;
  3203. }
  3204. visaDetails.ClientInfo = new()
  3205. {
  3206. LastName = name.GetLastName(),
  3207. FirstName = name.GetFirstName(),
  3208. Sex = (string)jsonData.GetType().GetProperty("性别")!.GetValue(jsonData)! == "男" ? 0 : 1,
  3209. OldName = (string)jsonData.GetType().GetProperty("曾用名")!.GetValue(jsonData)!,
  3210. BirthDay = birthDayDt,
  3211. BirthProvince = birthDay1.province,
  3212. BirthCity = birthDay1.city,
  3213. Address = address.address,
  3214. PostCodes = address.zipCode,
  3215. Marriage = maritalStatus,
  3216. MateName = (string)jsonData.GetType().GetProperty("配偶姓名")!.GetValue(jsonData)!,
  3217. MateBirthDay = birthDayDt_mate,
  3218. MateBirthCountry = birthDay1_mate.province,
  3219. MateBirthCity = birthDay1_mate.city,
  3220. USA_DLNo = driveInfo.number,
  3221. USA_DLPlace = driveInfo.place,
  3222. USA_SSNOrITIN = number,
  3223. Resident = CleanPrefix((string)jsonData.GetType().GetProperty("是否是其他国家的永久居民")!.GetValue(jsonData)!),
  3224. HasSocialAcc‌ = CleanPrefix((string)jsonData.GetType().GetProperty("近五年内是否使用过任何社交账号")!.GetValue(jsonData)!),
  3225. WeddingDate = f,
  3226. DivorceDate = t,
  3227. DivorceRsn = (string)jsonData.GetType().GetProperty("离婚原因")!.GetValue(jsonData)!,
  3228. Job = (string)jsonData.GetType().GetProperty("职务")!.GetValue(jsonData)!,
  3229. Wage = (string)jsonData.GetType().GetProperty("月薪")!.GetValue(jsonData)!,
  3230. WorkState = (string)jsonData.GetType().GetProperty("工作职责")!.GetValue(jsonData)!,
  3231. WorkDate = (string)jsonData.GetType().GetProperty("入职/入学时间(详细到月)")!.GetValue(jsonData)!,
  3232. USAAddress = (string)jsonData.GetType().GetProperty("请提供美国详细住址")!.GetValue(jsonData)!,
  3233. USAPurpose = (string)jsonData.GetType().GetProperty("赴美目的")!.GetValue(jsonData)!,
  3234. CostBearers = (string)jsonData.GetType().GetProperty("费用谁付")!.GetValue(jsonData)!,
  3235. USAContact = (string)jsonData.GetType().GetProperty("美国联系人或组织")!.GetValue(jsonData)!,
  3236. USAContactTel = usa_phone,
  3237. USAContactEmail = usa_email,
  3238. USADate = usa_d,
  3239. USADays = usa_days,
  3240. USAArrivalCity‌ = (string)jsonData.GetType().GetProperty("赴美的到达城市")!.GetValue(jsonData)!,
  3241. USADepartCity‌ = (string)jsonData.GetType().GetProperty("赴美的离开城市")!.GetValue(jsonData)!,
  3242. USAVisitSites‌ = (string)jsonData.GetType().GetProperty("计划在美国访问的景点")!.GetValue(jsonData)!,
  3243. USACmpName = usaCmpName,
  3244. USACmpRelation = (string)jsonData.GetType().GetProperty("同行人关系")!.GetValue(jsonData)!,
  3245. Tel = (string)jsonData.GetType().GetProperty("家庭电话")!.GetValue(jsonData)!,
  3246. ClientPhone = (string)jsonData.GetType().GetProperty("单位电话")!.GetValue(jsonData)!,
  3247. Phone = (string)jsonData.GetType().GetProperty("移动电话")!.GetValue(jsonData)!,
  3248. Cntry5Y‌ = (string)jsonData.GetType().GetProperty("过去5年内到过的国家")!.GetValue(jsonData)!,
  3249. LangSkill‌ = (string)jsonData.GetType().GetProperty("面签时能流利交流的语言")!.GetValue(jsonData)!,
  3250. LoseCode = loseCode,
  3251. DenyNationRsn = (string)jsonData.GetType().GetProperty("曾被哪些国家拒签/拒签原因")!.GetValue(jsonData)!,
  3252. USAVisaCode = (string)jsonData.GetType().GetProperty("签证号码")!.GetValue(jsonData)!,
  3253. USAVisaCate = (string)jsonData.GetType().GetProperty("获签类型")!.GetValue(jsonData)!,
  3254. //GetUSAVisaDate = usaVisaDate,
  3255. USAFinger = usaFinger,
  3256. IsLose = usaLose,
  3257. USAHadArrival = usaHadArrivalD,
  3258. USAHadDays = usaHadArrivalDays,
  3259. ArmyState = JsonConvert.SerializeObject(militarys)
  3260. };
  3261. visaDetails.ClientCerts = new() {
  3262. new(){ SdId = 74,CertNo = passportNo,IDCardAddress = passportPlace },
  3263. new(){ SdId = 73,CertNo = idNo},
  3264. };
  3265. visaDetails.ClientCompany = new() { CompanyFullName = clientName, Address = clientAddr };
  3266. break;
  3267. //中文个人简历模板
  3268. case 6:
  3269. _logger.LogInformation("【签证上传文件操作信息】【中文个人简历模板】【KIMI-AI-API访问计次】{count} 次", kimiAI_API_Index);
  3270. visaDetails.ClientInfo.LastName = (string)jsonData.GetType().GetProperty("姓名(中英文拼音)")!.GetValue(jsonData)!;
  3271. visaDetails.ClientInfo.Sex = (string)jsonData.GetType().GetProperty("性别")!.GetValue(jsonData)! == "男" ? 0 : 1;
  3272. DateTime.TryParse((string)jsonData.GetType().GetProperty("出生日期")!.GetValue(jsonData)!, out DateTime birthDay11);
  3273. visaDetails.ClientInfo.BirthDay = birthDay11;
  3274. visaDetails.ClientInfo.BirthProvince = (string)jsonData.GetType().GetProperty("出生地")!.GetValue(jsonData)!;
  3275. visaDetails.ClientInfo.Address = (string)jsonData.GetType().GetProperty("家庭地址")!.GetValue(jsonData)!;
  3276. visaDetails.ClientInfo.Tel = (string)jsonData.GetType().GetProperty("家庭电话")!.GetValue(jsonData)!;
  3277. visaDetails.ClientInfo.TableOpTel = (string)jsonData.GetType().GetProperty("工作电话")!.GetValue(jsonData)!;
  3278. visaDetails.ClientInfo.Phone = (string)jsonData.GetType().GetProperty("移动电话")!.GetValue(jsonData)!;
  3279. visaDetails.ClientInfo.Email = (string)jsonData.GetType().GetProperty("电子邮件")!.GetValue(jsonData)!;
  3280. //学校信息
  3281. visaDetails.ClientSchools.Add(new()
  3282. {
  3283. School = (string)jsonData.GetType().GetProperty("教育学校名称")!.GetValue(jsonData)!,
  3284. Education = (string)jsonData.GetType().GetProperty("教育学位")!.GetValue(jsonData)!,
  3285. Subject = (string)jsonData.GetType().GetProperty("教育专业")!.GetValue(jsonData)!,
  3286. Remark = (string)jsonData.GetType().GetProperty("教育论文题目/研究重点(硕士、博士)")!.GetValue(jsonData)!,
  3287. });
  3288. //工作信息
  3289. visaDetails.ClientCompany = new()
  3290. {
  3291. CompanyFullName = (string)jsonData.GetType().GetProperty("工作经历雇主")!.GetValue(jsonData)!,
  3292. };
  3293. visaDetails.ClientInfo.Job = (string)jsonData.GetType().GetProperty("工作经历职位或头衔职责")!.GetValue(jsonData)!;
  3294. break;
  3295. default:
  3296. break;
  3297. }
  3298. //数据提交
  3299. #region 数据提交
  3300. _sqlSugar.BeginTran();
  3301. // 客户公司表
  3302. var compId = UpsertReturnId<Crm_CustomerCompany>(visaDetails.ClientCompany, o => o.CompanyFullName);
  3303. if (compId < 1)
  3304. {
  3305. _sqlSugar.RollbackTran();
  3306. return Ok(JsonView(false, "公司信息更新失败!"));
  3307. }
  3308. visaDetails.ClientInfo.CrmCompanyId = compId;
  3309. // 客户资料表
  3310. var clientId = UpsertReturnId<Crm_DeleClient>(visaDetails.ClientInfo, o => new { o.LastName, o.FirstName });
  3311. if (clientId < 1)
  3312. {
  3313. _sqlSugar.RollbackTran();
  3314. return Ok(JsonView(false, "客户信息更新失败!"));
  3315. }
  3316. for (int i = 0; i < visaDetails.ClientFamilys.Count(); i++)
  3317. {
  3318. visaDetails.ClientFamilys[i].DcId = clientId;
  3319. }
  3320. for (int i = 0; i < visaDetails.ClientCerts.Count(); i++)
  3321. {
  3322. visaDetails.ClientCerts[i].DcId = clientId;
  3323. }
  3324. for (int i = 0; i < visaDetails.ClientSchools.Count(); i++)
  3325. {
  3326. visaDetails.ClientSchools[i].DcId = clientId;
  3327. }
  3328. // 客户家庭表
  3329. foreach (var item in visaDetails.ClientFamilys)
  3330. {
  3331. var famId = UpsertReturnId<Crm_VisaCustomerFamily>(item, o => o.Name);
  3332. if (famId < 1)
  3333. {
  3334. _sqlSugar.RollbackTran();
  3335. return Ok(JsonView(false, "客户家庭信息更新失败!"));
  3336. }
  3337. }
  3338. // 客户证件表
  3339. foreach (var item in visaDetails.ClientCerts)
  3340. {
  3341. var certId = UpsertReturnId<Crm_CustomerCert>(item, o => o.CertNo);
  3342. if (certId < 1)
  3343. {
  3344. _sqlSugar.RollbackTran();
  3345. return Ok(JsonView(false, "客户证件信息更新失败!"));
  3346. }
  3347. }
  3348. // 客户学历表
  3349. foreach (var item in visaDetails.ClientSchools)
  3350. {
  3351. var schoolId = UpsertReturnId<Crm_VisaCustomerSchool>(item, o => o.School);
  3352. if (schoolId < 1)
  3353. {
  3354. _sqlSugar.RollbackTran();
  3355. return Ok(JsonView(false, "客户证件信息更新失败!"));
  3356. }
  3357. }
  3358. _sqlSugar.CommitTran();
  3359. #endregion
  3360. #endregion
  3361. return Ok(JsonView(true, jsonString));
  3362. }
  3363. #region 扩展处理
  3364. // 从 Expression<Func<T,object>> 里取出属性名
  3365. static string GetPropName<T>(Expression<Func<T, object>> expr)
  3366. {
  3367. if (expr.Body is UnaryExpression ue) expr = Expression.Lambda<Func<T, object>>(ue.Operand, expr.Parameters);
  3368. return ((MemberExpression)expr.Body).Member.Name;
  3369. }
  3370. /// <summary>
  3371. /// 5.1.4.193 可用:存在更新(非NULL非空串),不存在插入,返回主键ID
  3372. /// </summary>
  3373. public int UpsertReturnId<T>(T entity, Expression<Func<T, object>> whereExpr) where T : class, new()
  3374. {
  3375. // 1. 空字符串→NULL,让后续忽略
  3376. foreach (var pi in typeof(T).GetProperties())
  3377. if (pi.PropertyType == typeof(string) &&
  3378. pi.GetValue(entity) is string s &&
  3379. string.IsNullOrWhiteSpace(s))
  3380. pi.SetValue(entity, null);
  3381. // 2. 从表达式里拿属性名
  3382. string propName = GetPropName(whereExpr);
  3383. var propValue = typeof(T).GetProperty(propName)?.GetValue(entity);
  3384. // 3. 判断存在
  3385. bool exists = _sqlSugar.Queryable<T>().Where(propName, propValue).Any();
  3386. // 4. 执行 Upsert
  3387. if (exists)
  3388. {
  3389. _sqlSugar.Updateable(entity)
  3390. .WhereColumns(propName) // 指定条件列
  3391. .IgnoreColumns(ignoreAllNullColumns: true) // 忽略 NULL
  3392. .ExecuteCommand();
  3393. }
  3394. else
  3395. {
  3396. _sqlSugar.Insertable(entity).ExecuteReturnIdentity();
  3397. }
  3398. // 5. 返回主键值(自增/雪花已回填)
  3399. var idProp = typeof(T).GetProperties()
  3400. .First(p => p.GetCustomAttributes<SugarColumn>()
  3401. .Any(a => a.IsPrimaryKey));
  3402. return (int)idProp.GetValue(entity)!;
  3403. }
  3404. /// <summary>
  3405. /// 地址喊邮编 相关处理
  3406. /// </summary>
  3407. public static (string address, string zipCode) SplitAddressZip(string? s)
  3408. {
  3409. if (string.IsNullOrWhiteSpace(s))
  3410. return ("", "");
  3411. ReadOnlySpan<char> src = s.AsSpan();
  3412. int i = src.IndexOf("邮编".AsSpan());
  3413. if (i < 0) // 没有“邮编”字样
  3414. return (src.Trim().ToString(), "");
  3415. ReadOnlySpan<char> addr = src[..i].TrimEnd();
  3416. ReadOnlySpan<char> zip = src[(i + 3)..].Trim(); // 跳过“邮编:”
  3417. // 可能只有“邮编:”而没有数字
  3418. return (addr.IsEmpty ? "" : addr.ToString(),
  3419. zip.IsEmpty ? "" : zip.ToString());
  3420. }
  3421. /// <summary>
  3422. /// 驾照相 关处理
  3423. /// </summary>
  3424. /// <param name="raw"></param>
  3425. /// <returns></returns>
  3426. public static (bool hasLicense, string number, string place) LicenseParser(string? raw)
  3427. {
  3428. if (string.IsNullOrWhiteSpace(raw))
  3429. return (false, "", "");
  3430. // 1. 是否持有
  3431. bool has = raw.StartsWith("是", System.StringComparison.OrdinalIgnoreCase) ||
  3432. raw.StartsWith("Y", System.StringComparison.OrdinalIgnoreCase);
  3433. // 2. 去掉前缀,按空格切
  3434. ReadOnlySpan<char> s = raw.AsSpan();
  3435. int colon = s.IndexOf(':');
  3436. ReadOnlySpan<char> after = colon < 0 ? s : s[(colon + 1)..];
  3437. after = after.Trim();
  3438. int space = after.IndexOf(' ');
  3439. ReadOnlySpan<char> num = space < 0 ? after : after[..space];
  3440. ReadOnlySpan<char> st = space < 0 ? ReadOnlySpan<char>.Empty : after[(space + 1)..];
  3441. return (has, num.ToString().Trim(), st.ToString().Trim());
  3442. }
  3443. /// <summary>
  3444. /// 美国社会安全号或者纳税ID号 相关处理
  3445. /// </summary>
  3446. /// <param name="raw"></param>
  3447. /// <returns></returns>
  3448. public static (bool hasSsnItin, string number) SsnItinParser(string? raw)
  3449. {
  3450. if (string.IsNullOrWhiteSpace(raw))
  3451. return (false, "");
  3452. ReadOnlySpan<char> s = raw.AsSpan();
  3453. // 1. 是否持有
  3454. bool has = s.StartsWith("是", System.StringComparison.Ordinal) ||
  3455. s.StartsWith("Y", System.StringComparison.OrdinalIgnoreCase);
  3456. // 2. 取号码(去掉前缀和空格)
  3457. int colon = s.IndexOf(':');
  3458. ReadOnlySpan<char> num = colon < 0
  3459. ? ReadOnlySpan<char>.Empty
  3460. : s[(colon + 1)..].Trim();
  3461. return (has, num.ToString());
  3462. }
  3463. /// <summary>
  3464. /// 取消开始的“是:”或者“是”或者“ :”
  3465. /// </summary>
  3466. /// <param name="raw"></param>
  3467. /// <returns></returns>
  3468. public static string CleanPrefix(string? raw)
  3469. {
  3470. if (string.IsNullOrWhiteSpace(raw)) return "";
  3471. // 跳过第一个“是”或“Y”
  3472. ReadOnlySpan<char> s = raw.AsSpan();
  3473. int start = 0;
  3474. if (s.StartsWith("是") || s.StartsWith("Y", StringComparison.OrdinalIgnoreCase))
  3475. start = 1;
  3476. // 跳过连续 : 或空格
  3477. while (start < s.Length && (s[start] == ':' || s[start] == ' '))
  3478. start++;
  3479. return s[start..].Trim().ToString();
  3480. }
  3481. /// <summary>
  3482. /// 婚姻起止时间处理
  3483. /// </summary>
  3484. /// <param name="raw"></param>
  3485. /// <returns></returns>
  3486. public static (DateTime? fromDate, DateTime? toDate) WeddingParser(string? raw)
  3487. {
  3488. if (string.IsNullOrWhiteSpace(raw)) return (null, null);
  3489. Regex _clean = new(@"[\s~至]+", RegexOptions.Compiled);
  3490. // 1. 把所有“空格~至”统一成 '-'
  3491. string normalized = _clean.Replace(raw, "-");
  3492. // 2. 切两段
  3493. string[] parts = normalized.Split('-', StringSplitOptions.RemoveEmptyEntries);
  3494. if (parts.Length != 2) return (null, null);
  3495. // 3. 解析
  3496. bool ff = DateTime.TryParse(parts[0].Trim(), out var from);
  3497. bool tf = DateTime.TryParse(parts[1].Trim(), out var to);
  3498. return (tf ? from : null, tf ? to : null);
  3499. }
  3500. /// <summary>
  3501. /// 出行日期和天数处理
  3502. /// </summary>
  3503. /// <param name="raw"></param>
  3504. /// <returns></returns>
  3505. public static (DateTime? travelDate, int? days) TravelParser(string? raw)
  3506. {
  3507. if (string.IsNullOrWhiteSpace(raw)) return (null, null);
  3508. // 切成两段:第一段日期,第二段天数
  3509. Regex sep = new(@"[^0-9./-]+", RegexOptions.Compiled);
  3510. string[] parts = sep.Split(raw.Trim());
  3511. if (parts.Length < 2) return (null, null);
  3512. bool okDate = DateTime.TryParse(parts[0], out DateTime date);
  3513. bool okDays = int.TryParse(parts[1], out int days) && days > 0;
  3514. return (okDate ? date : null, okDays ? days : null);
  3515. }
  3516. /// <summary>
  3517. /// 是否曾抵达过美国
  3518. /// </summary>
  3519. /// <param name="raw"></param>
  3520. /// <returns></returns>
  3521. public static (bool hasTravel, string date, string days) TravelHadFlagParser(string? raw)
  3522. {
  3523. if (string.IsNullOrWhiteSpace(raw)) return (false, string.Empty, string.Empty);
  3524. Regex sep = new(@"[^0-9./-]+", RegexOptions.Compiled);
  3525. // 1. 是否持有
  3526. bool has = raw.AsSpan().TrimStart().StartsWith("是") ||
  3527. raw.AsSpan().TrimStart().StartsWith("Y", StringComparison.OrdinalIgnoreCase);
  3528. // 2. 用非数字分隔符切成三段:第一段空,第二段日期,第三段天数
  3529. string[] parts = sep.Split(raw.Trim());
  3530. if (parts.Length < 3) return (has, string.Empty, string.Empty);
  3531. return (has, parts[1], parts[2]);
  3532. }
  3533. /// <summary>
  3534. /// 是否有被美国拒发签证的经历
  3535. /// </summary>
  3536. /// <param name="raw"></param>
  3537. /// <returns></returns>
  3538. public static (bool wasDenied, DateTime? date, string place, string visaType) VisaDenialParser(string? raw)
  3539. {
  3540. if (string.IsNullOrWhiteSpace(raw)) return (false, null, "", "");
  3541. bool denied = raw.AsSpan().TrimStart().StartsWith("有") ||
  3542. raw.AsSpan().TrimStart().StartsWith("Y", StringComparison.OrdinalIgnoreCase);
  3543. var parts = Regex.Split(raw.Trim(), @"[^0-9A-Za-z-]+");
  3544. if (parts.Length < 4) return (denied, null, "", "");
  3545. DateTime.TryParse(parts[1], out var dt); // ← 这里改为 DateTime
  3546. return (denied, dt, parts[2], parts[3]);
  3547. }
  3548. /// <summary>
  3549. /// 在美直系、旁系 处理
  3550. /// </summary>
  3551. /// <param name="raw"></param>
  3552. /// <returns></returns>
  3553. public static (bool flag, string name, string rel, string stat) FourFieldParser(string? raw)
  3554. {
  3555. if (string.IsNullOrWhiteSpace(raw)) return (false, "", "", "");
  3556. var parts = raw.Split((char[]?)null, StringSplitOptions.RemoveEmptyEntries);
  3557. if (parts.Length < 4) return (false, "", "", "");
  3558. bool flag = parts[0] is "有" or "是" or "Y" or "Yes";
  3559. string name = parts[1];
  3560. string rel = parts[2];
  3561. string stat = parts[3];
  3562. return (flag, name, rel, stat);
  3563. }
  3564. /// <summary>
  3565. /// 服役时间处理
  3566. /// </summary>
  3567. /// <param name="raw"></param>
  3568. /// <returns></returns>
  3569. public static (bool hasService, string branch, string rank, string specialty, (DateTime? start, DateTime? end) period) MilitaryParser(string? raw)
  3570. {
  3571. const string fmt = "yyyy年MM月dd日";
  3572. if (string.IsNullOrWhiteSpace(raw))
  3573. return (false, "", "", "", (null, null));
  3574. var parts = raw.Split((char[]?)null, StringSplitOptions.RemoveEmptyEntries);
  3575. if (parts.Length < 5) return (false, "", "", "", (null, null));
  3576. bool has = parts[0] is "是" or "Y" or "Yes";
  3577. string branch = parts[1];
  3578. string rank = parts[2];
  3579. string specialty = parts[3];
  3580. // 拼回时间字符串
  3581. string periodRaw = string.Join(" ", parts[4..]);
  3582. var span = periodRaw.AsSpan();
  3583. int zhi = span.IndexOf("至");
  3584. if (zhi < 0) return (has, branch, rank, specialty, (null, null));
  3585. var startStr = span.Slice(0, zhi).Trim();
  3586. var endStr = span.Slice(zhi + 1).Trim();
  3587. bool okStart = DateTime.TryParseExact(startStr.ToString(), fmt, null, DateTimeStyles.None, out var start);
  3588. bool okEnd = DateTime.TryParseExact(endStr.ToString(), fmt, null, DateTimeStyles.None, out var end);
  3589. return (has, branch, rank, specialty, (okStart ? start : null, okEnd ? end : null));
  3590. }
  3591. /// <summary>
  3592. /// 申请人父母信息
  3593. /// </summary>
  3594. /// <param name="raw"></param>
  3595. /// <returns></returns>
  3596. public static (string fatherName, DateTime? fatherDob, string motherName, DateTime? motherDob) ParentParser(string? raw)
  3597. {
  3598. const string fmt = "yyyy年MM月dd日";
  3599. if (string.IsNullOrWhiteSpace(raw)) return ("", null, "", null);
  3600. // 按空格切,去掉空元素
  3601. var parts = raw.Split((char[]?)null, StringSplitOptions.RemoveEmptyEntries);
  3602. if (parts.Length < 4) return ("", null, "", null);
  3603. // 父亲
  3604. string fName = parts[0];
  3605. DateTime.TryParseExact(parts[1], fmt, null, DateTimeStyles.None, out var fDob);
  3606. // 母亲
  3607. string mName = parts[2];
  3608. DateTime.TryParseExact(parts[3], fmt, null, DateTimeStyles.None, out var mDob);
  3609. return (fName, fDob, mName, mDob);
  3610. }
  3611. public class VisaDetailsView
  3612. {
  3613. /// <summary>
  3614. /// 客户资料表
  3615. /// </summary>
  3616. public Crm_DeleClient ClientInfo { get; set; }
  3617. /// <summary>
  3618. /// 客户家庭表
  3619. /// </summary>
  3620. public List<Crm_VisaCustomerFamily> ClientFamilys { get; set; }
  3621. /// <summary>
  3622. /// 客户公司表
  3623. /// </summary>
  3624. public Crm_CustomerCompany ClientCompany { get; set; }
  3625. /// <summary>
  3626. /// 客户证件表
  3627. /// </summary>
  3628. public List<Crm_CustomerCert> ClientCerts { get; set; }
  3629. /// <summary>
  3630. /// 客户学历表
  3631. /// </summary>
  3632. public List<Crm_VisaCustomerSchool> ClientSchools { get; set; }
  3633. }
  3634. private int GetSuccessCount(List<FileUploadResult> results)
  3635. {
  3636. var count = 0;
  3637. foreach (var result in results)
  3638. {
  3639. if (result.Success) count++;
  3640. }
  3641. return count;
  3642. }
  3643. #endregion
  3644. /// <summary>
  3645. /// 根据团组Id获取签证客户信息List
  3646. /// </summary>
  3647. /// <param name="dto">请求dto</param>
  3648. /// <returns></returns>
  3649. [HttpPost]
  3650. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3651. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  3652. {
  3653. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  3654. if (groupData.Code != 0)
  3655. {
  3656. return Ok(JsonView(false, groupData.Msg));
  3657. }
  3658. return Ok(JsonView(groupData.Data));
  3659. }
  3660. /// <summary>
  3661. /// IOS获取团组签证拍照上传进度01(团组列表)
  3662. /// </summary>
  3663. /// <param name="dto">请求dto</param>
  3664. /// <returns></returns>
  3665. [HttpPost]
  3666. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3667. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  3668. {
  3669. if (dto == null)
  3670. {
  3671. return Ok(JsonView(false, "参数为空"));
  3672. }
  3673. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  3674. return Ok(JsonView(visaList));
  3675. }
  3676. /// <summary>
  3677. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  3678. /// </summary>
  3679. /// <returns></returns>
  3680. [HttpPost]
  3681. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3682. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  3683. {
  3684. if (dto == null)
  3685. {
  3686. return Ok(JsonView(false, "请求错误:"));
  3687. }
  3688. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  3689. return Ok(JsonView(list));
  3690. }
  3691. /// <summary>
  3692. /// IOS获取团组签证拍照上传进度03(相册)
  3693. /// </summary>
  3694. /// <returns></returns>
  3695. [HttpPost]
  3696. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3697. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  3698. {
  3699. if (dto == null)
  3700. {
  3701. return Ok(JsonView(false, "请求错误:"));
  3702. }
  3703. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  3704. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  3705. list.ForEach(s => s.url = url);
  3706. return Ok(JsonView(list));
  3707. }
  3708. /// <summary>
  3709. /// IOS获取团组签证拍照上传进度04(图片上传)
  3710. /// </summary>
  3711. /// <param name="dto"></param>
  3712. /// <returns></returns>
  3713. [HttpPost]
  3714. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3715. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  3716. {
  3717. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  3718. //if (!string.IsNullOrEmpty(result))
  3719. //{
  3720. //}
  3721. //else {
  3722. // return Ok(JsonView(false, "上传失败"));
  3723. //}
  3724. var dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  3725. int sucNum = 0;
  3726. try
  3727. {
  3728. foreach (var item in dto.base64DataList)
  3729. {
  3730. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  3731. string result = DecodeBase64ToImage(item, imageName);
  3732. if (!string.IsNullOrEmpty(result))
  3733. {
  3734. var pic = new Grp_VisaProgressCustomerPicture
  3735. {
  3736. CreateUserId = dto.CreateUserId,
  3737. PicName = imageName,
  3738. PicPath = result,
  3739. VisaProgressCustomerId = dto.visaProgressCustomerId
  3740. };
  3741. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  3742. if (insertResult > 0)
  3743. {
  3744. sucNum++;
  3745. }
  3746. }
  3747. }
  3748. }
  3749. catch (Exception ex)
  3750. {
  3751. return Ok(JsonView(false, ex.Message));
  3752. }
  3753. string msg = string.Format(@"成功上传{0}张", sucNum);
  3754. return Ok(JsonView(true, msg));
  3755. }
  3756. private string DecodeBase64ToImage(string base64DataURL, string imgName)
  3757. {
  3758. string filename = "";//声明一个string类型的相对路径
  3759. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  3760. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  3761. try//会有异常抛出,try,catch一下
  3762. {
  3763. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  3764. var ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  3765. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  3766. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  3767. //文件名称
  3768. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  3769. //上传的文件的路径
  3770. string filePath = "";
  3771. if (!Directory.Exists(fileDir))
  3772. {
  3773. Directory.CreateDirectory(fileDir);
  3774. }
  3775. //上传的文件的路径
  3776. filePath = fileDir + filename;
  3777. //string url = HttpRuntime.AppDomainAppPath.ToString();
  3778. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  3779. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  3780. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  3781. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  3782. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  3783. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  3784. ms.Close();//关闭当前流,并释放所有与之关联的资源
  3785. bitmap.Dispose();
  3786. }
  3787. catch (Exception e)
  3788. {
  3789. string massage = e.Message;
  3790. Logs("IOS图片上传Error:" + massage);
  3791. //filename = e.Message;
  3792. }
  3793. return filename;//返回相对路径
  3794. }
  3795. /// <summary>
  3796. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  3797. /// </summary>
  3798. /// <param name="dto"></param>
  3799. /// <returns></returns>
  3800. [HttpPost]
  3801. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3802. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  3803. {
  3804. if (dto == null)
  3805. {
  3806. return Ok(JsonView(false, "请求错误:"));
  3807. }
  3808. string msg = "参数错误";
  3809. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  3810. {
  3811. try
  3812. {
  3813. //_delegationVisaRep.BeginTran();
  3814. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  3815. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  3816. .Where(s => s.Id == dto.visaProgressCustomerId)
  3817. .ExecuteCommandAsync();
  3818. if (updCount > 0 && dto.publishCode == 1)
  3819. {
  3820. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  3821. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  3822. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  3823. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  3824. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  3825. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  3826. if (groupData == null)
  3827. {
  3828. _delegationVisaRep.RollbackTran();
  3829. }
  3830. string title = string.Format(@"[签证进度更新]");
  3831. string content = string.Format(@"测试文本");
  3832. bool rst = await _message.AddMsg(new MessageDto()
  3833. {
  3834. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  3835. IssuerId = dto.publisher,
  3836. Title = title,
  3837. Content = content,
  3838. ReleaseTime = DateTime.Now,
  3839. UIdList = new List<int> {
  3840. 234
  3841. }
  3842. });
  3843. if (rst)
  3844. {
  3845. return Ok(JsonView(true, "发送通知成功"));
  3846. }
  3847. }
  3848. //_delegationVisaRep.CommitTran();
  3849. }
  3850. catch (Exception)
  3851. {
  3852. //_delegationVisaRep.RollbackTran();
  3853. }
  3854. }
  3855. return Ok(JsonView(true, msg));
  3856. }
  3857. #endregion
  3858. #endregion
  3859. #region 团组任务分配
  3860. /// <summary>
  3861. /// 团组任务分配初始化
  3862. /// </summary>
  3863. /// <returns></returns>
  3864. [HttpPost]
  3865. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3866. public async Task<IActionResult> GetTaskAssignmen()
  3867. {
  3868. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  3869. if (groupData.Code != 0)
  3870. {
  3871. return Ok(JsonView(false, groupData.Msg));
  3872. }
  3873. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3874. }
  3875. /// <summary>
  3876. /// 团组任务分配查询
  3877. /// </summary>
  3878. /// <param name="dto"></param>
  3879. /// <returns></returns>
  3880. [HttpPost]
  3881. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3882. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  3883. {
  3884. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  3885. if (groupData.Code != 0)
  3886. {
  3887. return Ok(JsonView(false, groupData.Msg));
  3888. }
  3889. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3890. }
  3891. /// <summary>
  3892. /// 团组任务分配操作
  3893. /// </summary>
  3894. /// <param name="dto"></param>
  3895. /// <returns></returns>
  3896. [HttpPost]
  3897. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3898. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  3899. {
  3900. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  3901. if (groupData.Code != 0)
  3902. {
  3903. return Ok(JsonView(false, groupData.Msg));
  3904. }
  3905. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3906. }
  3907. /// <summary>
  3908. /// 团组任务分配
  3909. /// 批量分配
  3910. /// 查询团组
  3911. /// </summary>
  3912. /// <param name="dto"></param>
  3913. /// <returns></returns>
  3914. [HttpPost]
  3915. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3916. public async Task<IActionResult> TaskAllocationGroupSelect(TaskAllocationGroupSelectDto dto)
  3917. {
  3918. //参数验证
  3919. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  3920. if (!DateTime.TryParse(dto.VisitBeginDt, out _) || !DateTime.TryParse(dto.VisitEndDt, out _))
  3921. return Ok(JsonView(false, "团组出访开始/结束日期格式不正确!"));
  3922. return Ok(await _taskAssignmentRep.TaskAllocationGroupSelect(dto));
  3923. }
  3924. /// <summary>
  3925. /// 团组任务分配
  3926. /// 批量分配
  3927. /// </summary>
  3928. /// <param name="dto"></param>
  3929. /// <returns></returns>
  3930. [HttpPost]
  3931. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3932. public async Task<IActionResult> TaskAllocationBulkAdd(TaskAllocationBulkAddDto dto)
  3933. {
  3934. //参数验证
  3935. if (dto.UserIds.Length < 1) return Ok(JsonView(false, $"请选择分配人员!"));
  3936. if (dto.PermissionTypeIds.Length < 1) return Ok(JsonView(false, $"请选择分配类型!"));
  3937. if (dto.GroupIds.Length < 1) return Ok(JsonView(false, "请选择分配团组Id"));
  3938. if (dto.CurrUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId数组参数"));
  3939. return Ok(await _taskAssignmentRep.TaskAllocationBulkAdd(dto));
  3940. }
  3941. #endregion
  3942. #region 团组费用审核
  3943. /// <summary>
  3944. /// 费用审核
  3945. /// 团组列表 Page
  3946. /// </summary>
  3947. /// <param name="_dto">团组列表请求dto</param>
  3948. /// <returns></returns>
  3949. [HttpPost]
  3950. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3951. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  3952. {
  3953. #region 参数验证
  3954. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  3955. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  3956. #region 页面操作权限验证
  3957. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  3958. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  3959. #endregion
  3960. #endregion
  3961. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  3962. {
  3963. string sqlWhere = string.Empty;
  3964. if (_dto.IsSure == 0) //未完成
  3965. {
  3966. sqlWhere += string.Format(@" And IsSure = 0");
  3967. }
  3968. else if (_dto.IsSure == 1) //已完成
  3969. {
  3970. sqlWhere += string.Format(@" And IsSure = 1");
  3971. }
  3972. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  3973. {
  3974. string tj = _dto.SearchCriteria;
  3975. 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}%')",
  3976. tj, tj, tj, tj, tj);
  3977. }
  3978. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  3979. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  3980. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  3981. From (
  3982. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  3983. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  3984. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  3985. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  3986. From Grp_DelegationInfo gdi
  3987. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  3988. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  3989. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  3990. Where gdi.IsDel = 0 {0}
  3991. ) temp ", sqlWhere);
  3992. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  3993. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  3994. var _view = new
  3995. {
  3996. PageFuncAuth = pageFunAuthView,
  3997. Data = _DelegationList
  3998. };
  3999. return Ok(JsonView(true, "查询成功!", _view, total));
  4000. }
  4001. else
  4002. {
  4003. return Ok(JsonView(false, "查询失败"));
  4004. }
  4005. }
  4006. /// <summary>
  4007. /// 获取团组费用审核
  4008. /// </summary>
  4009. /// <param name="_dto"></param>
  4010. /// <returns></returns>
  4011. [HttpPost]
  4012. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4013. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  4014. {
  4015. try
  4016. {
  4017. #region 参数验证
  4018. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  4019. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  4020. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  4021. #region 页面操作权限验证
  4022. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  4023. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  4024. #endregion
  4025. #endregion
  4026. var _view = new Grp_CreditCardPaymentView();
  4027. var clientNameList = GetSimplClientList(_dto.DiId);
  4028. #region 费用清单
  4029. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  4030. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  4031. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  4032. var entityList = _groupRepository.Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0).Where(exp.ToExpression()).ToList();
  4033. var detailList = new List<Grp_CreditCardPaymentDetailView>();
  4034. var ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  4035. /*
  4036. * 76://酒店预订
  4037. */
  4038. var _HotelReservations = await _groupRepository.Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  4039. var _HotelReservationsContents = await _groupRepository.Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  4040. /*
  4041. * 79://车/导游地接
  4042. */
  4043. var _CarTouristGuideGroundReservations = await _groupRepository.Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  4044. var _CarTouristGuideGroundReservationsContent = await _groupRepository.Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  4045. /*
  4046. * 80: //签证
  4047. */
  4048. var _VisaInfos = await _groupRepository.Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  4049. /*
  4050. *81: //邀请/公务活动
  4051. */
  4052. var _InvitationOfficialActivities = await _groupRepository.Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  4053. /*
  4054. * 82: //团组客户保险
  4055. */
  4056. var _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  4057. /*
  4058. * Lable = 85 机票预订
  4059. */
  4060. var p_AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  4061. /*
  4062. * 85 机票预定
  4063. */
  4064. var _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  4065. /*
  4066. * 98 其他款项
  4067. */
  4068. var _DecreasePayments = await _groupRepository.Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  4069. /*
  4070. * 285:收款退还
  4071. */
  4072. var _PaymentRefundAndOtherMoneys = await _groupRepository.Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  4073. /*
  4074. * 1015: //超支费用
  4075. */
  4076. var _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  4077. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  4078. /*
  4079. * 币种信息
  4080. */
  4081. var currencyItems = initDatas.Where(s => s.STid == 66).ToList();
  4082. /*
  4083. * 车/导游地接 费用类型
  4084. */
  4085. var carFeeTypeItems = initDatas.Where(s => s.STid == 17).ToList();
  4086. /*
  4087. * 车/导游地接 费用类型
  4088. */
  4089. var carFeeItems = initDatas.Where(s => s.STid == 83).ToList();
  4090. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  4091. /*
  4092. * 用户信息
  4093. */
  4094. var userItems = await _groupRepository._sqlSugar.Queryable<Sys_Users>().ToListAsync();
  4095. /*
  4096. * 费用模块
  4097. */
  4098. var sdPriceName = initDatas.Where(s => s.Id == _dto.Label).First();
  4099. string priceModule = string.Empty;
  4100. if (sdPriceName != null)
  4101. {
  4102. priceModule = sdPriceName.Name;
  4103. }
  4104. /*
  4105. * 成本信息
  4106. */
  4107. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  4108. decimal _groupRate = 0.0000M;
  4109. string _groupCurrencyCode = "-";
  4110. if (groupCost != null)
  4111. {
  4112. _groupRate = groupCost.Rate;
  4113. if (int.TryParse(groupCost.Currency, out int _currency))
  4114. {
  4115. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  4116. }
  4117. else _groupCurrencyCode = groupCost.Currency;
  4118. }
  4119. string costContentSql = $"Select * From Grp_GroupCost";
  4120. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  4121. //处理日期为空的天数
  4122. for (int i = 0; i < groupCostDetails.Count; i++)
  4123. if (i != 0)
  4124. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  4125. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  4126. /*
  4127. * 处理详情数据
  4128. */
  4129. foreach (var entity in entityList)
  4130. {
  4131. var _detail = new Grp_CreditCardPaymentDetailView
  4132. {
  4133. Id = entity.Id,
  4134. PriceName = priceModule,
  4135. PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-"
  4136. };
  4137. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  4138. else _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  4139. //处理金额
  4140. if (entity.CTable == 1015)
  4141. {
  4142. var czInfo = _GroupExtraCosts.Find(x => entity.CId == x.Id);
  4143. if (czInfo != null)
  4144. {
  4145. entity.PayMoney = czInfo.Price * czInfo.PriceCount;
  4146. entity.RMBPrice = czInfo.Price * czInfo.PriceCount * entity.DayRate;
  4147. }
  4148. }
  4149. /*
  4150. * 应付款金额
  4151. */
  4152. var sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  4153. string PaymentCurrency_WaitPay = "Unknown";
  4154. string hotelCurrncyCode = "Unknown";
  4155. string hotelCurrncyName = "Unknown";
  4156. if (sdPaymentCurrency_WaitPay != null)
  4157. {
  4158. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  4159. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  4160. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  4161. if (hotelCurrncyCode.Equals("CNY"))
  4162. {
  4163. entity.DayRate = 1.0000M;
  4164. }
  4165. }
  4166. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  4167. /*
  4168. * 此次付款金额
  4169. */
  4170. decimal CurrPayStr = 0.00M,
  4171. OriginalCurrPay = 0.00M;
  4172. if (entity.PayPercentage == 0)
  4173. {
  4174. if (entity.PayThenMoney != 0)
  4175. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  4176. }
  4177. else
  4178. {
  4179. if (entity.PayMoney != 0)
  4180. {
  4181. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  4182. }
  4183. }
  4184. //if (_dto.Label == 79)
  4185. //{
  4186. // string original = string.Empty;
  4187. // if (hotelCurrncyCode.Equals("CNY"))
  4188. // {
  4189. // OriginalCurrPay = CurrPayStr;
  4190. // _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  4191. // }
  4192. // else
  4193. // {
  4194. // OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  4195. // //760 EUR(7600.00 CNY)
  4196. // _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  4197. // }
  4198. //}
  4199. //else _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  4200. string original = string.Empty;
  4201. if (hotelCurrncyCode.Equals("CNY"))
  4202. {
  4203. OriginalCurrPay = CurrPayStr;
  4204. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  4205. }
  4206. else
  4207. {
  4208. OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  4209. //760 EUR(7600.00 CNY)
  4210. _detail.CurrPay = $"{OriginalCurrPay:#0.00} {hotelCurrncyCode}({CurrPayStr:#0.00} CNY)";
  4211. }
  4212. /*
  4213. * 剩余尾款
  4214. */
  4215. decimal BalanceStr = 0;
  4216. if (CurrPayStr != 0)
  4217. {
  4218. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  4219. BalanceStr = 0;
  4220. else
  4221. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  4222. }
  4223. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  4224. /*
  4225. * Bus名称
  4226. */
  4227. _detail.BusName = "待增加";
  4228. /*
  4229. *费用所属
  4230. */
  4231. switch (entity.CTable)
  4232. {
  4233. case 76://酒店预订
  4234. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  4235. if (hotelReservations != null)
  4236. {
  4237. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  4238. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  4239. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  4240. string roomFeeStr = "", roomFeestr1 = "";
  4241. //是否比较房型价格
  4242. //bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  4243. //roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  4244. roomFeeStr += $"<br/>";
  4245. var roomTotal = 0.00M;
  4246. if (hotelReservations.SingleRoomPrice > 0)
  4247. {
  4248. var fee = hotelReservations.SingleRoomPrice * hotelReservations.SingleRoomCount * hotel_days;
  4249. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice:#0.00} * {hotelReservations.SingleRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  4250. //__isSingle = true;
  4251. roomTotal += fee;
  4252. }
  4253. if (hotelReservations.DoubleRoomPrice > 0)
  4254. {
  4255. var fee = hotelReservations.DoubleRoomPrice * hotelReservations.DoubleRoomCount * hotel_days;
  4256. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice:#0.00} * {hotelReservations.DoubleRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  4257. // __isDouble = true;
  4258. roomTotal += fee;
  4259. }
  4260. if (hotelReservations.SuiteRoomPrice > 0)
  4261. {
  4262. var fee = hotelReservations.SuiteRoomPrice * hotelReservations.SuiteRoomCount * hotel_days;
  4263. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice:#0.00} * {hotelReservations.SuiteRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  4264. //__isSuite = true;
  4265. roomTotal += fee;
  4266. }
  4267. if (hotelReservations.OtherRoomPrice > 0)
  4268. {
  4269. var fee = hotelReservations.OtherRoomPrice * hotelReservations.OtherRoomCount * hotel_days;
  4270. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice:#0.00} * {hotelReservations.OtherRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  4271. //__isOther = true;
  4272. roomTotal += fee;
  4273. }
  4274. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1 + $"<span style='width:70px;display: inline-block;'></span>房费总金额:{roomTotal:#0.00}";
  4275. else roomFeeStr += " 0.00 * 0";
  4276. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  4277. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  4278. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  4279. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  4280. /*
  4281. * 费用类型
  4282. * 1:房费
  4283. * 2:早餐
  4284. * 3:地税
  4285. * 4:城市税
  4286. * </summary>
  4287. */
  4288. //地税
  4289. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  4290. if (governmentRentData != null)
  4291. {
  4292. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  4293. governmentRentFee = governmentRentData.Price;
  4294. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  4295. if (governmentRentCurrData != null)
  4296. {
  4297. governmentRentCode = governmentRentCurrData.Name;
  4298. governmentRentName = $"({governmentRentCurrData.Remark})";
  4299. }
  4300. }
  4301. //城市税
  4302. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  4303. if (cityTaxData != null)
  4304. {
  4305. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  4306. cityTaxFee = cityTaxData.Price;
  4307. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  4308. if (cityTaxCurrData != null)
  4309. {
  4310. cityTaxCode = cityTaxCurrData.Name;
  4311. cityTaxName = $"({cityTaxCurrData.Remark})";
  4312. }
  4313. }
  4314. //酒店早餐
  4315. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  4316. if (breakfastData != null)
  4317. {
  4318. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  4319. breakfastFee = breakfastData.Price;
  4320. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  4321. if (breakfastCurrData != null)
  4322. {
  4323. breakfastCode = breakfastCurrData.Name;
  4324. breakfastName = $"({breakfastCurrData.Remark})";
  4325. }
  4326. }
  4327. //房间费用
  4328. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  4329. if (roomData != null)
  4330. {
  4331. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  4332. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  4333. else _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  4334. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  4335. roomFee = roomData.Price;
  4336. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  4337. if (roomCurrData != null)
  4338. {
  4339. roomCode = roomCurrData.Name;
  4340. roomName = $"({roomCurrData.Remark})";
  4341. }
  4342. }
  4343. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  4344. string hotelCostStr = "";
  4345. decimal hotelCsotTotal = 0.00M;
  4346. if (groupCost != null)
  4347. {
  4348. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  4349. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate:#0.0000})<br/>";
  4350. }
  4351. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  4352. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  4353. string hotelCost_day = "";
  4354. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  4355. foreach (var item in hotelCostDetails1)
  4356. {
  4357. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  4358. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  4359. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee):#0.00}";
  4360. //else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  4361. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee):#0.00}";
  4362. //else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  4363. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee):#0.00}";
  4364. //else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  4365. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee):#0.00}";
  4366. //else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  4367. hotelCost_day += @$"<br/>";
  4368. }
  4369. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  4370. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee:#0.00} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate:#0.0000} <br/>是否由地接或其他人代付:{breakfastBool}<br/><br/>";
  4371. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee:#0.00} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate:#0.0000} <br/>是否由地接或其他人代付:{governmentRentBool}<br/><br/>";
  4372. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee:#0.00} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate:#0.0000)} <br/>是否由地接或其他人代付:{cityTaxBool}<br/>";
  4373. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  4374. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  4375. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  4376. $"酒店费用总额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  4377. $"房间说明: {hotelReservations.Remark} <br/>" +
  4378. $"房间费用: {roomCode} {roomName} 当时汇率:{roomData?.Rate.ToString("#0.0000")}{roomFeeStr} <br/>是否由地接或其他人代付:{roomBool}<br/><br/>" +
  4379. $"{hotelBreakfastStr}" +
  4380. $"{hotelGovernmentRentStr}" +
  4381. $"{hotelCityTaxStr}";
  4382. _detail.PriceNameContent = hotelReservations.HotelName;
  4383. }
  4384. break;
  4385. case 79://车/导游地接
  4386. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  4387. if (touristGuideGroundReservations != null)
  4388. {
  4389. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  4390. {
  4391. _detail.BusName = touristGuideGroundReservations.BusName;
  4392. }
  4393. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  4394. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  4395. //if (isInt)
  4396. //{
  4397. // var cityInfo = cityData.Find(it => it.Id == cityId);
  4398. // if (cityInfo != null)
  4399. // {
  4400. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  4401. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  4402. // if (carFeeItem != null)
  4403. // {
  4404. // nameContent += $@"({carFeeItem.Name})";
  4405. // }
  4406. // _detail.PriceNameContent = nameContent;
  4407. // }
  4408. //}
  4409. //else
  4410. //{
  4411. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  4412. //}
  4413. var touristGuideGroundReservationsContents =
  4414. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  4415. var opContent_sb = new StringBuilder();
  4416. string contetTitle = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  4417. opContent_sb.AppendLine(contetTitle);
  4418. foreach (var item in touristGuideGroundReservationsContents)
  4419. {
  4420. string typeName = "Unknown";
  4421. string carCurrencyCode = "Unknown";
  4422. string carCurrencyName = "Unknown";
  4423. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  4424. if (carTypeData != null) typeName = carTypeData.Name;
  4425. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  4426. if (currencyData != null)
  4427. {
  4428. carCurrencyCode = currencyData.Name;
  4429. carCurrencyName = currencyData.Remark;
  4430. }
  4431. //op、成本 币种是否一致 (币种一致只比较金额:2025-04-18)
  4432. bool IsCurrencyAgreement = false;
  4433. if (carCurrencyCode.Equals(_groupCurrencyCode)) IsCurrencyAgreement = true;
  4434. string opCostStr = string.Empty;
  4435. decimal opCostTypePrice = 0.00M;
  4436. #region 处理成本各项费用
  4437. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  4438. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  4439. decimal aduitOPFeeCNY = 0.00M, //费用审核 op费用
  4440. costOPFeeCNY = 0.00M, //团组成本 op费用
  4441. opPayPercentage = entity.PayPercentage == 0.00M ? 1.00M : entity.PayPercentage / 100M; //费用审核 op付款百分比
  4442. if (opCost.Count > 0)
  4443. {
  4444. switch (item.SId)
  4445. {
  4446. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  4447. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  4448. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  4449. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  4450. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  4451. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  4452. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  4453. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  4454. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  4455. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  4456. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  4457. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  4458. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  4459. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  4460. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  4461. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  4462. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  4463. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  4464. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  4465. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  4466. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  4467. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  4468. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  4469. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  4470. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  4471. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  4472. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  4473. }
  4474. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice:#0.00} {_groupCurrencyCode}(汇率:{_groupRate:#0.0000})";
  4475. costOPFeeCNY = opCostTypePrice * _groupRate;
  4476. if (!IsCurrencyAgreement) opCostStr += $" ≈ {costOPFeeCNY:#0.00} CNY";
  4477. }
  4478. #endregion
  4479. string opTypeStr = $"{typeName}:{item.Price:#0.00} {carCurrencyCode}(汇率:{entity.DayRate:#0.0000})";
  4480. aduitOPFeeCNY = item.Price * entity.DayRate;
  4481. if (!IsCurrencyAgreement) opTypeStr += $" ≈ {aduitOPFeeCNY:#0.0000} CNY";
  4482. var opContent = $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  4483. $"{opTypeStr} {opCostStr}<br/>" +
  4484. $"明细:{item.PriceContent ?? "-"}<br/>" +
  4485. $"备注:{item.Remark ?? "-"}<br/><br/>";
  4486. if (entity.IsAuditGM != 3) //状态 != 自动审核
  4487. {
  4488. if (IsCurrencyAgreement)
  4489. {
  4490. if (item.Price > opCostTypePrice)
  4491. {
  4492. opContent_sb.Append("<span style='color:red;'>");
  4493. opContent_sb.Append(opContent);
  4494. opContent_sb.Append("</span>");
  4495. opContent_sb.AppendLine();
  4496. }
  4497. else
  4498. {
  4499. opContent_sb.Append(opContent);
  4500. opContent_sb.AppendLine();
  4501. }
  4502. }
  4503. else
  4504. {
  4505. //验证是否超成本 按付款比例计算
  4506. if (aduitOPFeeCNY * opPayPercentage > costOPFeeCNY * opPayPercentage)
  4507. {
  4508. opContent_sb.Append("<span style='color:red;'>");
  4509. opContent_sb.Append(opContent);
  4510. opContent_sb.Append("</span>");
  4511. opContent_sb.AppendLine();
  4512. }
  4513. else
  4514. {
  4515. opContent_sb.Append(opContent);
  4516. opContent_sb.AppendLine();
  4517. }
  4518. }
  4519. }
  4520. else
  4521. {
  4522. opContent_sb.Append(opContent);
  4523. opContent_sb.AppendLine();
  4524. }
  4525. }
  4526. _detail.PriceMsgContent = opContent_sb.ToString();
  4527. }
  4528. break;
  4529. case 80: //签证
  4530. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  4531. if (visaInfo != null)
  4532. {
  4533. string visaName = GetClientNameStr1(clientNameList, visaInfo.VisaClient);
  4534. _detail.PriceNameContent = visaInfo.VisaDescription;
  4535. _detail.PriceMsgContent = $"签证描述:{visaName}<br/> 备注:{visaInfo.Remark}";
  4536. }
  4537. break;
  4538. case 81: //邀请/公务活动
  4539. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  4540. if (_ioa != null)
  4541. {
  4542. string inviteCurrName = "Unknown", //邀请费用币种 Name
  4543. inviteCurrCode = "Unknown", //邀请费用币种 Code
  4544. sendCurrName = "Unknown", //快递费用币种 Name
  4545. sendCurrCode = "Unknown", //快递费用币种 Code
  4546. eventsCurrName = "Unknown", //公务活动费币种 Name
  4547. eventsCurrCode = "Unknown", //公务活动费币种 Code
  4548. translateCurrName = "Unknown", //公务翻译费 Name
  4549. translateCurrCode = "Unknown"; //公务翻译费 Code
  4550. #region 处理费用币种
  4551. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  4552. if (inviteCurrData != null)
  4553. {
  4554. inviteCurrName = inviteCurrData.Remark;
  4555. inviteCurrCode = inviteCurrData.Name;
  4556. }
  4557. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  4558. if (sendCurrData != null)
  4559. {
  4560. sendCurrName = sendCurrData.Remark;
  4561. sendCurrCode = sendCurrData.Name;
  4562. }
  4563. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  4564. if (eventsCurrData != null)
  4565. {
  4566. eventsCurrName = eventsCurrData.Remark;
  4567. eventsCurrCode = eventsCurrData.Name;
  4568. }
  4569. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  4570. if (translateCurrData != null)
  4571. {
  4572. translateCurrName = translateCurrData.Remark;
  4573. translateCurrCode = translateCurrData.Name;
  4574. }
  4575. #endregion
  4576. _detail.PriceNameContent = _ioa.InviterArea;
  4577. //2025-09-08 商邀费用名称更改:单项费用不等于0,则在名称后面最加费用类型名称。
  4578. List<string> priceExpNames = new List<string>();
  4579. if (_ioa.InviteCost != 0.00M) priceExpNames.Add("邀请费");
  4580. if (_ioa.SendCost != 0.00M) priceExpNames.Add("快递费");
  4581. if (_ioa.EventsCost != 0.00M) priceExpNames.Add("公务活动费");
  4582. if (_ioa.TranslateCost != 0.00M) priceExpNames.Add("公务翻译费");
  4583. if (priceExpNames != null && priceExpNames.Count > 0)
  4584. {
  4585. _detail.PriceNameContent += $"({string.Join("+", priceExpNames)})";
  4586. }
  4587. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost:#0.00} {inviteCurrCode}({inviteCurrName})<br/>" +
  4588. $@"快递费用:{_ioa.SendCost:#0.00} {sendCurrCode}({sendCurrName})<br/>" +
  4589. $@"公务活动费:{_ioa.EventsCost:#0.00} {eventsCurrCode}({eventsCurrName})<br/>" +
  4590. $@"公务翻译费:{_ioa.TranslateCost:#0.00} {translateCurrCode}({translateCurrName})<br/>" +
  4591. $@"备注:" + _ioa.Remark + "<br/>";
  4592. }
  4593. break;
  4594. case 82: //团组客户保险
  4595. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  4596. if (customers != null)
  4597. {
  4598. _detail.PriceNameContent = GetClientNameStr(clientNameList, customers.ClientName);
  4599. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  4600. }
  4601. break;
  4602. case 85: //机票预订
  4603. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  4604. if (jpRes != null)
  4605. {
  4606. string FlightsDescription = jpRes.FlightsDescription;
  4607. string PriceDescription = jpRes.PriceDescription;
  4608. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  4609. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  4610. }
  4611. break;
  4612. case 98://其他款项
  4613. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  4614. if (gdpRes != null)
  4615. {
  4616. //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/";
  4617. //if (!string.IsNullOrEmpty(gdpRes.FilePath))
  4618. //{
  4619. // _detail.FileUrl = $"{urlBase}{gdpRes.FilePath}";
  4620. //}
  4621. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  4622. _detail.PriceNameContent = gdpRes.PriceName;
  4623. }
  4624. break;
  4625. case 285://收款退还
  4626. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  4627. if (refundAndOtherMoney != null)
  4628. {
  4629. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  4630. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  4631. }
  4632. break;
  4633. case 751://酒店早餐
  4634. break;
  4635. case 1015://超支费用
  4636. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  4637. if (groupExtraCost != null)
  4638. {
  4639. _detail.PriceNameContent = groupExtraCost.PriceName;
  4640. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  4641. }
  4642. break;
  4643. default:
  4644. break;
  4645. }
  4646. /*
  4647. * 申请人
  4648. */
  4649. string operatorName = " - ";
  4650. var _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  4651. if (_opUser != null)
  4652. {
  4653. operatorName = _opUser.CnName;
  4654. }
  4655. _detail.OperatorName = operatorName;
  4656. /*
  4657. * 审核人
  4658. */
  4659. string auditOperatorName = " - ";
  4660. if (entity.IsAuditGM != 0)
  4661. {
  4662. if (entity.AuditGMOperate == 0) auditOperatorName = " - ";
  4663. else if (entity.AuditGMOperate == 4) auditOperatorName = "自动审核";
  4664. else
  4665. {
  4666. var _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  4667. if (_adUser != null)
  4668. {
  4669. auditOperatorName = _adUser.CnName;
  4670. }
  4671. }
  4672. }
  4673. _detail.AuditOperatorName = auditOperatorName;
  4674. /*
  4675. * 超预算比例
  4676. */
  4677. string overBudgetStr = "";
  4678. if (entity.ExceedBudget == -1) overBudgetStr = sdPriceName.Name + "尚无预算";
  4679. else if (entity.ExceedBudget == 0)
  4680. {
  4681. if (entity.CTable == 76 || entity.CTable == 79)
  4682. {
  4683. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  4684. else overBudgetStr = _feeAuditRep.IsOverBudget(entity.CTable, entity.DIId, entity.CId);
  4685. }
  4686. else
  4687. {
  4688. overBudgetStr = "未超预算";
  4689. }
  4690. }
  4691. else overBudgetStr = entity.ExceedBudget.ToString("P");
  4692. _detail.OverBudget = overBudgetStr;
  4693. decimal auditFee = 0.00M; //已审核金额 人名币
  4694. decimal auditedFeeOriginal = 0.00M; ////已审核金额 原始
  4695. decimal unAuditFeeCNY = 0.00M; //未审核款项 原始
  4696. decimal unAuditFeeOriginal = 0.00M; //未审核款项 人名币
  4697. if (entity.IsAuditGM == 1 || entity.IsAuditGM == 3)
  4698. {
  4699. auditedFeeOriginal = entity.PayMoney;
  4700. auditFee = CurrPayStr;
  4701. }
  4702. else if (entity.IsAuditGM == 0)
  4703. {
  4704. unAuditFeeCNY = CurrPayStr;
  4705. unAuditFeeOriginal = OriginalCurrPay;
  4706. OriginalCurrPay = 0.00M;
  4707. }
  4708. /*
  4709. * 费用总计
  4710. */
  4711. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  4712. {
  4713. CurrencyId = entity.PaymentCurrency,
  4714. CurrencyName = PaymentCurrency_WaitPay,
  4715. AmountPayable = entity.PayMoney,
  4716. ThisPayment = OriginalCurrPay,
  4717. BalancePayment = BalanceStr,
  4718. AuditedFunds = auditFee,
  4719. AuditedFundsOriginal = auditedFeeOriginal,
  4720. UnAuditFundsCNY = unAuditFeeCNY,
  4721. UnAuditFundsOriginal = unAuditFeeOriginal
  4722. });
  4723. _detail.IsAuditGM = entity.IsAuditGM;
  4724. detailList.Add(_detail);
  4725. }
  4726. #endregion
  4727. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  4728. /*
  4729. * 下方描述处理
  4730. */
  4731. var nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  4732. var ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  4733. if (ccpCurrencyPrice != null)
  4734. {
  4735. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  4736. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  4737. }
  4738. else
  4739. {
  4740. nonDuplicat = nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  4741. }
  4742. string amountPayableStr = string.Format(@"应付款总金额: ");
  4743. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  4744. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  4745. string auditedFundsStr = string.Format(@"已审费用总额: ");
  4746. string unAuditedFundsStr = string.Format(@"未审费用总额: ");
  4747. foreach (var item in nonDuplicat)
  4748. {
  4749. var currencyName = item.CurrencyName;
  4750. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  4751. if (strs.Count > 0)
  4752. {
  4753. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  4754. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  4755. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  4756. amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), currencyName);
  4757. //单独处理此次付款金额
  4758. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  4759. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), currencyName);
  4760. //单独处理已审核费用
  4761. //if (item.CurrencyId == 836) //人民币
  4762. //{
  4763. // decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  4764. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), currencyName);
  4765. //}
  4766. //else
  4767. //{
  4768. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.AmountPayable), currencyName);
  4769. //}
  4770. if (currencyName.Equals("CNY"))
  4771. {
  4772. //已审核费用
  4773. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  4774. //未审核费用
  4775. unAuditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.UnAuditFundsOriginal).ToString("#0.00"), currencyName);
  4776. }
  4777. else
  4778. {
  4779. //已审核费用
  4780. 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"));
  4781. //未审核费用
  4782. 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"));
  4783. }
  4784. }
  4785. }
  4786. _view.TotalStr1 = amountPayableStr[..^1];
  4787. _view.TotalStr2 = thisPaymentStr[..^1];
  4788. _view.TotalStr3 = balancePaymentStr[..^1];
  4789. _view.TotalStr4 = $"{auditedFundsStr[..^1]}<br/>{unAuditedFundsStr[..^1]}";
  4790. //_view.TotalStr5 = unAuditedFundsStr.Substring(0, unAuditedFundsStr.Length - 1);
  4791. var _view1 = new
  4792. {
  4793. PageFuncAuth = pageFunAuthView,
  4794. Data = _view
  4795. };
  4796. return Ok(JsonView(_view1));
  4797. }
  4798. catch (Exception ex)
  4799. {
  4800. return Ok(JsonView(false, ex.Message));
  4801. }
  4802. }
  4803. /// <summary>
  4804. /// 费用审核
  4805. /// 修改团组费用审核状态
  4806. /// </summary>
  4807. /// <param name="_dto">参数Json字符串</param>
  4808. /// <returns></returns>
  4809. [HttpPost]
  4810. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4811. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  4812. {
  4813. #region 参数验证
  4814. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  4815. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  4816. #endregion
  4817. #region 页面操作权限验证
  4818. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  4819. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  4820. #endregion
  4821. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  4822. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  4823. DateTime dtNow = DateTime.Now;
  4824. _groupRepository.BeginTran();
  4825. int rst = 0;
  4826. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  4827. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  4828. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  4829. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  4830. var msgDatas = new List<dynamic>();
  4831. var dic_ccp_user = new Dictionary<int, int>() { };
  4832. foreach (var item in idList)
  4833. {
  4834. int CreditId = int.Parse(item);
  4835. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  4836. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  4837. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  4838. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  4839. .Where(s => s.Id == CreditId)
  4840. .ExecuteCommandAsync();
  4841. if (result < 1)
  4842. {
  4843. rst = -1;
  4844. _groupRepository.RollbackTran();
  4845. return Ok(JsonView(false, "操作失败并回滚!"));
  4846. }
  4847. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  4848. if (creditData != null)
  4849. {
  4850. #region 应用通知配置
  4851. try
  4852. {
  4853. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  4854. }
  4855. catch (Exception ex)
  4856. {
  4857. }
  4858. #endregion
  4859. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  4860. string groupNameStr = string.Empty;
  4861. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  4862. if (groupData != null) groupNameStr = groupData.TeamName;
  4863. string creditTypeStr = string.Empty;
  4864. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  4865. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  4866. string creditCurrency = string.Empty;
  4867. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  4868. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  4869. if (creditCurrency.Equals("CNY"))
  4870. {
  4871. creditData.DayRate = 1.0000M;
  4872. }
  4873. if (creditData.PayPercentage == 0.00M)
  4874. {
  4875. creditData.PayPercentage = 100M;
  4876. }
  4877. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  4878. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  4879. string msgContent = "";
  4880. if (creditCurrency.Equals("CNY"))
  4881. {
  4882. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice:0.00} CNY) {auditStr}!";
  4883. }
  4884. else
  4885. {
  4886. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice:0.00} CNY({creditData.PayMoney:0.00} {creditCurrency})) {auditStr}!";
  4887. }
  4888. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  4889. }
  4890. }
  4891. if (rst == 0)
  4892. {
  4893. _groupRepository.CommitTran();
  4894. foreach (var item in msgDatas)
  4895. {
  4896. //发送消息
  4897. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  4898. }
  4899. #region 应用推送
  4900. try
  4901. {
  4902. foreach (var ccpId in dic_ccp_user.Keys)
  4903. {
  4904. var templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  4905. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  4906. }
  4907. }
  4908. catch (Exception)
  4909. {
  4910. }
  4911. #endregion
  4912. return Ok(JsonView(true, "操作成功!"));
  4913. }
  4914. return Ok(JsonView(false, "操作失败!"));
  4915. }
  4916. /// <summary>
  4917. /// 费用审核
  4918. /// 其他款项 文件下载
  4919. /// </summary>
  4920. /// <param name="id">其他款项 主键编号</param>
  4921. /// <returns></returns>
  4922. [HttpGet("{id}")]
  4923. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4924. public async Task<IActionResult> FeeAuditOtherFileDownlaod([Range(1, int.MaxValue, ErrorMessage = "请传入有效的ID")] int id)
  4925. {
  4926. //网站域名
  4927. 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/";
  4928. var otherInfo = await _decreasePaymentsRep._sqlSugar
  4929. .Queryable<Grp_DecreasePayments>()
  4930. .InnerJoin<Grp_CreditCardPayment>((x, y) => x.Id == y.CId && y.Id == id)
  4931. .Where(((x, y) => x.IsDel == 0 && y.IsDel == 0))
  4932. .Select((x, y) => new
  4933. {
  4934. x.Id,
  4935. x.FilePath
  4936. })
  4937. .FirstAsync();
  4938. if (otherInfo != null && !string.IsNullOrEmpty(otherInfo.FilePath.Trim()))
  4939. {
  4940. var url = $"{baseUrl}{otherInfo.FilePath}";
  4941. return Ok(JsonView(true, "操作成功!", url));
  4942. }
  4943. return Ok(JsonView(false, "暂无附件"));
  4944. }
  4945. #endregion
  4946. #region 机票费用录入
  4947. /// <summary>
  4948. /// 机票录入当前登录人可操作团组
  4949. /// </summary>
  4950. /// <param name="dto"></param>
  4951. /// <returns></returns>
  4952. [HttpPost]
  4953. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4954. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  4955. {
  4956. try
  4957. {
  4958. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  4959. if (groupData.Code != 0)
  4960. {
  4961. return Ok(JsonView(false, groupData.Msg));
  4962. }
  4963. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4964. }
  4965. catch (Exception ex)
  4966. {
  4967. return Ok(JsonView(false, ex.Message));
  4968. }
  4969. }
  4970. /// <summary>
  4971. /// 机票费用录入列表
  4972. /// </summary>
  4973. /// <param name="dto"></param>
  4974. /// <returns></returns>
  4975. [HttpPost]
  4976. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4977. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  4978. {
  4979. try
  4980. {
  4981. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  4982. if (groupData.Code != 0)
  4983. {
  4984. return Ok(JsonView(false, groupData.Msg));
  4985. }
  4986. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4987. }
  4988. catch (Exception ex)
  4989. {
  4990. return Ok(JsonView(false, ex.Message));
  4991. throw;
  4992. }
  4993. }
  4994. /// <summary>
  4995. /// 根据id查询费用录入信息
  4996. /// </summary>
  4997. /// <param name="dto"></param>
  4998. /// <returns></returns>
  4999. [HttpPost]
  5000. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5001. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  5002. {
  5003. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  5004. if (groupData.Code != 0)
  5005. {
  5006. return Ok(JsonView(false, groupData.Msg));
  5007. }
  5008. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5009. }
  5010. /// <summary>
  5011. /// 机票费用录入操作(Status:1.新增,2.修改)
  5012. /// </summary>
  5013. /// <param name="dto"></param>
  5014. /// <returns></returns>
  5015. [HttpPost]
  5016. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5017. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  5018. {
  5019. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  5020. if (groupData.Code != 0)
  5021. {
  5022. return Ok(JsonView(false, groupData.Msg));
  5023. }
  5024. #region 应用推送
  5025. try
  5026. {
  5027. var diId = dto.AirTicketResOpData.DiId;
  5028. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  5029. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  5030. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  5031. //自动审核
  5032. //var autoAdit1 = await _feeAuditRep.FeeAutomaticAudit(5, diId, dataId); //机票费用合计方式
  5033. (bool status, string auditMsg) = await AirTicketResAutoAudit(diId, dataId); //KIMI-AI识别INIT方式
  5034. _logger.LogInformation("【机票费用自动审核(KIMI-AI识别INIT)】请求参数:{RequstData} 返回结果:是否执行:{IsExecute}; 结果消息:{ResponseMsg};",
  5035. $"GroupId:{diId};airId:{dataId};",
  5036. status,
  5037. auditMsg);
  5038. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  5039. //2024-10-21 新增LZ UID
  5040. var userIds = new List<int>() { 21 };
  5041. string title = $"系统通知";
  5042. string content = "";
  5043. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  5044. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  5045. if (dto.Status == 1) content = $"[新增-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  5046. else if (dto.Status == 2) content = $"[更新-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  5047. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  5048. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "85" };
  5049. await APNsTools.iOS_PushNotifications1("051", $"机票费用审核", "", content, true, "ExpenseAuditWebView", h5);
  5050. }
  5051. catch (Exception ex)
  5052. {
  5053. }
  5054. #endregion
  5055. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5056. }
  5057. /// <summary>
  5058. /// 机票费用自动审核 AI识别方式
  5059. /// </summary>
  5060. /// <returns></returns>
  5061. private async Task<(bool, string)> AirTicketResAutoAudit(int diId, int dataId)
  5062. {
  5063. var ecoTypeIds = new List<int>() {
  5064. 459, //超经舱
  5065. 460, //经济舱
  5066. 1430, //公务舱(实际经济舱)
  5067. 1432, //头等舱(实际经济舱)
  5068. };
  5069. var bizTypeIds = new List<int>() {
  5070. 457, //头等舱
  5071. 458, //公务舱
  5072. 1431, //头等舱(实际公务舱)
  5073. };
  5074. var auditFeeTypeIds = new List<int>() { };
  5075. auditFeeTypeIds.AddRange(ecoTypeIds);
  5076. auditFeeTypeIds.AddRange(bizTypeIds);
  5077. int currModule = 85;
  5078. var airInfo = await _sqlSugar.Queryable<Grp_AirTicketReservations>()
  5079. .InnerJoin<Grp_CreditCardPayment>((x, y) => x.Id == y.CId && y.CTable == currModule && y.IsDel == 0)
  5080. .Where((x, y) => x.Id == dataId && x.IsDel == 0 && auditFeeTypeIds.Contains(x.CType))
  5081. .Select((x, y) => new
  5082. {
  5083. x.Id,
  5084. CcpId = y.Id,
  5085. x.FlightsDate,
  5086. x.PrePrice,
  5087. x.CType,
  5088. x.ClientNum,
  5089. x.DIId
  5090. })
  5091. .FirstAsync();
  5092. if (airInfo == null) return (false, "机票信息为空或费用类型不在自动审核范围内,不可自动审核!");
  5093. var groupDetails = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.IsDel == 0 && x.Id == diId);
  5094. if (groupDetails == null) return (false, "团组信息为空,不可自动审核!");
  5095. var groupCostInfo = await _sqlSugar.Queryable<Grp_GroupCostParameter>().FirstAsync(x => x.IsDel == 0 && x.DiId == diId);
  5096. if (groupCostInfo == null) return (false, "团组成本信息未填写!");
  5097. var groupCostContents = await _sqlSugar
  5098. .SqlQueryable<GroupCostAuditView>($"Select * From Grp_GroupCost")
  5099. .Where(x => x.IsDel == 0 && x.Diid == diId)
  5100. .ToListAsync();
  5101. if (groupCostContents.Count < 1) return (false, "团组成本信息未填写!");
  5102. //处理 成本详细信息日期为空 填装费用信息
  5103. var airFeeLabel = new StringBuilder();
  5104. airFeeLabel.AppendLine("费用成本:");
  5105. for (int i = 0; i < groupCostContents.Count; i++)
  5106. {
  5107. if (string.IsNullOrEmpty(groupCostContents[i].Date))
  5108. {
  5109. int index = i - 1;
  5110. if (index >= 0)
  5111. {
  5112. groupCostContents[i].Date = groupCostContents[index].Date;
  5113. var dtBool = DateTime.TryParse(groupCostContents[i].Date, out DateTime _dateTime);
  5114. if (dtBool) groupCostContents[i].CurrTime = _dateTime;
  5115. }
  5116. }
  5117. else
  5118. {
  5119. var dtBool = DateTime.TryParse(groupCostContents[i].Date, out DateTime _dateTime);
  5120. if (dtBool) groupCostContents[i].CurrTime = _dateTime;
  5121. }
  5122. var item = groupCostContents[i];
  5123. airFeeLabel.AppendLine($"{item.Date}");
  5124. airFeeLabel.AppendLine($"{item.ITIN.Replace("\n", " ")}");
  5125. }
  5126. airFeeLabel.AppendLine($"注:费用:位置:航班号或者航班时间后面; 组成:经济舱/公务舱;");
  5127. airFeeLabel.AppendLine($"取出“{airInfo.FlightsDate}”费用金额,按照经济舱/公务舱格式返回,如果不存在的话则返回0.00/0.00,只返回金额格式文本;不需要其他文字描述;");
  5128. //访问Kimi AI 返回价格结果
  5129. var msgs = new List<SeedMessages>()
  5130. {
  5131. new ()
  5132. {
  5133. Role = KimiRole.user,
  5134. Content = airFeeLabel.ToString()
  5135. }
  5136. };
  5137. var client = new KiMiApiClient();
  5138. var kimiApiResult = await client.SeedMessage(msgs);
  5139. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  5140. string clients = kimiApiResult_JObject["content"].ToString();
  5141. decimal ecoPri_kimiAI = 0.00M,
  5142. bizPri_kimiAI = 0.00M;
  5143. //单个价格: 经济舱价格
  5144. if (decimal.TryParse(clients, out ecoPri_kimiAI)) { }
  5145. //价格文本包含/:/前经济舱价格 /后公务舱价格
  5146. if (clients.Contains('/'))
  5147. {
  5148. var priArray = clients.Split('/');
  5149. decimal.TryParse(priArray[0], out ecoPri_kimiAI); //
  5150. decimal.TryParse(priArray[1], out bizPri_kimiAI); //经济舱价格
  5151. }
  5152. else return (false, "价格文本不存在价格或KIMI-AI未识别出价格,不可自动审核!");
  5153. var isAutoAudit = false;
  5154. //价格验证处理
  5155. //经济舱
  5156. if (ecoTypeIds.Contains(airInfo.CType))
  5157. {
  5158. if (airInfo.PrePrice <= ecoPri_kimiAI) isAutoAudit = true;
  5159. }
  5160. //公务舱
  5161. else if (bizTypeIds.Contains(airInfo.CType))
  5162. {
  5163. if (airInfo.PrePrice <= bizPri_kimiAI) isAutoAudit = true;
  5164. }
  5165. else return (false, "该舱位类型不在自动审核范围内,不可自动审核!");
  5166. //是否执行自动审核
  5167. if (isAutoAudit)
  5168. {
  5169. var auditStatus = await _sqlSugar.Updateable<Grp_CreditCardPayment>()
  5170. .SetColumns(x => x.IsAuditGM == 3)
  5171. .SetColumns(x => x.AuditGMOperate == 4)
  5172. .SetColumns(x => x.AuditGMDate == DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
  5173. .Where(x => x.Id == airInfo.CcpId)
  5174. .ExecuteCommandAsync();
  5175. if (auditStatus > 0) return (true, "机票自动审核(KIMI-AI识别方式)执行成功!");
  5176. }
  5177. return (false, "当前费用超过成本费用,不可自动审核!");
  5178. }
  5179. /// <summary>
  5180. /// 机票费用录入
  5181. /// 自动审核测试 - AI 识别
  5182. /// </summary>
  5183. /// <param name="groupId"></param>
  5184. /// <param name="Id"></param>
  5185. /// <returns></returns>
  5186. [HttpPost]
  5187. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5188. public async Task<IActionResult> AirTicketResAutoAuditTest(int groupId, int Id)
  5189. {
  5190. (bool status, string msg) = await AirTicketResAutoAudit(groupId, Id);
  5191. return Ok(JsonView(status, msg));
  5192. }
  5193. /// <summary>
  5194. /// 根据舱位类型查询接团客户名单信息
  5195. /// </summary>
  5196. /// <param name="dto"></param>
  5197. /// <returns></returns>
  5198. [HttpPost]
  5199. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5200. public async Task<IActionResult> TankType(AirTicketResByIdDto dto)
  5201. {
  5202. try
  5203. {
  5204. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  5205. if (crm_Groups.Count != 0)
  5206. {
  5207. var Customer = new List<dynamic>();
  5208. foreach (var item in crm_Groups)
  5209. {
  5210. var data = new
  5211. {
  5212. item.Id,
  5213. item.Pinyin,
  5214. Name = item.LastName + item.FirstName
  5215. };
  5216. Customer.Add(data);
  5217. }
  5218. return Ok(JsonView(true, "查询成功!", Customer));
  5219. }
  5220. return Ok(JsonView(true, "暂无数据", crm_Groups));
  5221. }
  5222. catch (Exception ex)
  5223. {
  5224. return Ok(JsonView(false, "程序错误!"));
  5225. throw;
  5226. }
  5227. }
  5228. /// <summary>
  5229. /// 根据团号获取客户信息
  5230. /// </summary>
  5231. /// <param name="dto"></param>
  5232. /// <returns></returns>
  5233. [HttpPost]
  5234. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5235. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  5236. {
  5237. var jw = JsonView(false);
  5238. if (dto.DIID < 1)
  5239. {
  5240. jw.Msg += "请输入正确的diid";
  5241. return Ok(jw);
  5242. }
  5243. var arr = GetSimplClientList(dto.DIID);
  5244. jw = JsonView(true, "获取成功!", arr);
  5245. return Ok(jw);
  5246. }
  5247. private List<SimplClientInfo> GetSimplClientList(int diId)
  5248. {
  5249. 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);
  5250. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  5251. foreach (var item in arr)
  5252. {
  5253. EncryptionProcessor.DecryptProperties(item);
  5254. }
  5255. return arr;
  5256. }
  5257. private static string GetClientNameStr(List<SimplClientInfo> list, string origin)
  5258. {
  5259. string result = origin;
  5260. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  5261. {
  5262. string[] temparr = origin.Split(',');
  5263. string fistrStr = temparr[0];
  5264. int count = temparr.Length;
  5265. bool success = int.TryParse(fistrStr, out int tempId);
  5266. if (success)
  5267. {
  5268. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  5269. if (tempInfo != null)
  5270. {
  5271. if (count > 1)
  5272. {
  5273. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  5274. }
  5275. else
  5276. {
  5277. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  5278. }
  5279. }
  5280. }
  5281. }
  5282. return result;
  5283. }
  5284. private static string GetClientNameStr1(List<SimplClientInfo> list, string origin)
  5285. {
  5286. string result = origin;
  5287. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  5288. {
  5289. string[] temparr = origin.Split(',');
  5290. result = "";
  5291. foreach (var item in temparr)
  5292. {
  5293. bool success = int.TryParse(item, out int tempId);
  5294. if (success)
  5295. {
  5296. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  5297. if (tempInfo != null)
  5298. {
  5299. result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
  5300. }
  5301. }
  5302. }
  5303. }
  5304. if (result.Length > 0) result = result.Substring(0, result.Length - 1);
  5305. return result;
  5306. }
  5307. /// <summary>
  5308. /// 机票费用录入,删除
  5309. /// </summary>
  5310. /// <param name="dto"></param>
  5311. /// <returns></returns>
  5312. [HttpPost]
  5313. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5314. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  5315. {
  5316. try
  5317. {
  5318. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  5319. if (res)
  5320. {
  5321. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  5322. {
  5323. IsDel = 1,
  5324. DeleteUserId = dto.DeleteUserId,
  5325. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5326. }).ExecuteCommandAsync();
  5327. return Ok(JsonView(true, "删除成功!"));
  5328. }
  5329. return Ok(JsonView(false, "删除失败!"));
  5330. }
  5331. catch (Exception ex)
  5332. {
  5333. return Ok(JsonView(false, "程序错误!"));
  5334. throw;
  5335. }
  5336. }
  5337. /// <summary>
  5338. /// 导出机票录入报表
  5339. /// </summary>
  5340. /// <param name="dto"></param>
  5341. /// <returns></returns>
  5342. [HttpPost]
  5343. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5344. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  5345. {
  5346. try
  5347. {
  5348. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  5349. if (groupData.Code != 0)
  5350. {
  5351. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  5352. }
  5353. else
  5354. {
  5355. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  5356. if (AirTicketReservations.Count != 0)
  5357. {
  5358. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  5359. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  5360. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  5361. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  5362. var designer = new WorkbookDesigner
  5363. {
  5364. Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx")
  5365. };
  5366. decimal countCost = 0;
  5367. foreach (var item in AirTicketReservations)
  5368. {
  5369. #region 处理客人姓名
  5370. string clientNames = _tourClientListRep.ResolveCustomerName(item.ClientName);
  5371. item.ClientName = clientNames;
  5372. #endregion
  5373. if (item.BankType == "其他")
  5374. {
  5375. item.BankNo = "--";
  5376. }
  5377. else
  5378. {
  5379. if (!string.IsNullOrEmpty(item.BankType))
  5380. {
  5381. item.BankNo = $"{item.BankType}:{item.BankNo?[..3]}";
  5382. }
  5383. }
  5384. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  5385. item.Price = System.Decimal.Round(item.Price, 2);
  5386. countCost += Convert.ToDecimal(item.Price);
  5387. }
  5388. designer.SetDataSource("Export", AirTicketReservations);
  5389. designer.SetDataSource("ExportDiCode", diCode);
  5390. designer.SetDataSource("ExportDiName", diName);
  5391. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  5392. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  5393. designer.Process();
  5394. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  5395. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  5396. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  5397. return Ok(JsonView(true, "成功", url = rst));
  5398. }
  5399. else
  5400. {
  5401. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  5402. }
  5403. }
  5404. }
  5405. catch (Exception ex)
  5406. {
  5407. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  5408. throw;
  5409. }
  5410. }
  5411. private Dictionary<string, string> transDic = new Dictionary<string, string>();
  5412. /// <summary>
  5413. /// 行程单导出
  5414. /// </summary>
  5415. /// <param name="dto"></param>
  5416. /// <returns></returns>
  5417. [HttpPost]
  5418. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5419. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  5420. {
  5421. try
  5422. {
  5423. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  5424. if (groupData.Code != 0)
  5425. {
  5426. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  5427. }
  5428. else
  5429. {
  5430. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  5431. if (dto.Language == "CN")
  5432. {
  5433. var doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  5434. var builder = new DocumentBuilder(doc);
  5435. int tableIndex = 0;//表格索引
  5436. //得到文档中的第一个表格
  5437. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  5438. foreach (var item in _AirTicketReservations)
  5439. {
  5440. #region 处理固定数据
  5441. string[] FlightsCode = item.FlightsCode.Split('/');
  5442. if (FlightsCode.Length != 0)
  5443. {
  5444. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  5445. if (_AirCompany != null)
  5446. {
  5447. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  5448. }
  5449. else
  5450. {
  5451. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  5452. }
  5453. }
  5454. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  5455. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  5456. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  5457. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  5458. string name = "";
  5459. foreach (string clientName in nameArray)
  5460. {
  5461. if (!name.Contains(clientName))
  5462. {
  5463. name += clientName + ",";
  5464. }
  5465. }
  5466. if (!string.IsNullOrWhiteSpace(name))
  5467. {
  5468. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  5469. }
  5470. else
  5471. {
  5472. table.Range.Bookmarks["ClientName"].Text = "--";
  5473. }
  5474. table.Range.Bookmarks["TicketNumber"].Text = "--";
  5475. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  5476. table.Range.Bookmarks["JointTicket"].Text = "--";
  5477. table.Range.Bookmarks["TimeIssue"].Text = "--";
  5478. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  5479. table.Range.Bookmarks["NavigationCode"].Text = "--";
  5480. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  5481. table.Range.Bookmarks["AgentPhone"].Text = "--";
  5482. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  5483. #endregion
  5484. #region 循环数据处理
  5485. var airs = new List<AirInfo>();
  5486. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  5487. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  5488. for (int i = 0; i < FlightsCode.Length; i++)
  5489. {
  5490. var air = new AirInfo();
  5491. string[] tempstr = DayArray[i]
  5492. .Replace("\r\n", string.Empty)
  5493. .Replace("\\r\\n", string.Empty)
  5494. .TrimStart().TrimEnd()
  5495. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  5496. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  5497. string starCity = "";
  5498. if (star_Three != null)
  5499. {
  5500. starCity = star_Three.AirPort;
  5501. }
  5502. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  5503. string EndCity = "";
  5504. if (End_Three != null)
  5505. {
  5506. EndCity = End_Three.AirPort;
  5507. }
  5508. air.Destination = starCity + "/" + EndCity;
  5509. air.Flight = FlightsCode[i];
  5510. air.SeatingClass = item.CTypeName;
  5511. string dateTime = tempstr[2];
  5512. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  5513. air.FlightDate = DateTemp;
  5514. air.DepartureTime = tempstr[5];
  5515. air.LandingTime = tempstr[6];
  5516. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  5517. air.TicketStatus = "--";
  5518. air.Luggage = "--";
  5519. air.DepartureTerminal = "--";
  5520. air.LandingTerminal = "--";
  5521. airs.Add(air);
  5522. }
  5523. int row = 13;
  5524. for (int i = 0; i < airs.Count; i++)
  5525. {
  5526. if (airs.Count > 2)
  5527. {
  5528. for (int j = 0; j < airs.Count - 2; j++)
  5529. {
  5530. var CopyRow = table.Rows[12].Clone(true);
  5531. table.Rows.Add(CopyRow);
  5532. }
  5533. }
  5534. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  5535. int index = 0;
  5536. foreach (PropertyInfo property in properties)
  5537. {
  5538. string value = property.GetValue(airs[i]).ToString();
  5539. Cell ishcel0 = table.Rows[row].Cells[index];
  5540. var p = new Paragraph(doc);
  5541. string s = value;
  5542. p.AppendChild(new Run(doc, s));
  5543. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  5544. ishcel0.AppendChild(p);
  5545. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  5546. index++;
  5547. }
  5548. row++;
  5549. }
  5550. #endregion
  5551. var lastParagraph = new Paragraph(doc);
  5552. //第一个表格末尾加段落
  5553. table.ParentNode.InsertAfter(lastParagraph, table);
  5554. //复制第一个表格
  5555. Table cloneTable = (Table)table.Clone(true);
  5556. //在文档末尾段落后面加入复制的表格
  5557. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  5558. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  5559. {
  5560. int rownewsIndex = 13;
  5561. for (int i = 0; i < 2; i++)
  5562. {
  5563. var CopyRow = table.Rows[12].Clone(true);
  5564. table.Rows.RemoveAt(13);
  5565. table.Rows.Add(CopyRow);
  5566. rownewsIndex++;
  5567. }
  5568. }
  5569. else
  5570. {
  5571. table.Rows.RemoveAt(12);
  5572. }
  5573. cloneTable.Rows.RemoveAt(12);
  5574. }
  5575. if (_AirTicketReservations.Count != 0)
  5576. {
  5577. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  5578. if (FlightsCode.Length != 0)
  5579. {
  5580. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  5581. if (_AirCompany != null)
  5582. {
  5583. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  5584. }
  5585. else
  5586. {
  5587. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  5588. }
  5589. }
  5590. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  5591. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  5592. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  5593. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  5594. string name = "";
  5595. foreach (string clientName in nameArray)
  5596. {
  5597. if (!name.Contains(clientName))
  5598. {
  5599. name += clientName + ",";
  5600. }
  5601. }
  5602. if (!string.IsNullOrWhiteSpace(name))
  5603. {
  5604. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  5605. }
  5606. else
  5607. {
  5608. table.Range.Bookmarks["ClientName"].Text = "--";
  5609. }
  5610. table.Range.Bookmarks["TicketNumber"].Text = "--";
  5611. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  5612. table.Range.Bookmarks["JointTicket"].Text = "--";
  5613. table.Range.Bookmarks["TimeIssue"].Text = "--";
  5614. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  5615. table.Range.Bookmarks["NavigationCode"].Text = "--";
  5616. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  5617. table.Range.Bookmarks["AgentPhone"].Text = "--";
  5618. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  5619. }
  5620. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  5621. //保存合并后的文档
  5622. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  5623. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  5624. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  5625. return Ok(JsonView(true, "成功!", rst));
  5626. }
  5627. else
  5628. {
  5629. var doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  5630. var builder = new DocumentBuilder(doc);
  5631. int tableIndex = 0;//表格索引
  5632. //得到文档中的第一个表格
  5633. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  5634. var texts = new List<string>();
  5635. foreach (var item in _AirTicketReservations)
  5636. {
  5637. string[] FlightsCode = item.FlightsCode.Split('/');
  5638. if (FlightsCode.Length != 0)
  5639. {
  5640. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  5641. if (_AirCompany != null)
  5642. {
  5643. if (!transDic.ContainsKey(_AirCompany.CnName))
  5644. {
  5645. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  5646. }
  5647. }
  5648. else
  5649. {
  5650. if (!transDic.ContainsKey("--"))
  5651. {
  5652. transDic.Add("--", "--");
  5653. }
  5654. }
  5655. }
  5656. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  5657. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  5658. string name = "";
  5659. foreach (string clientName in nameArray)
  5660. {
  5661. name += clientName + ",";
  5662. }
  5663. if (!texts.Contains(name))
  5664. {
  5665. texts.Add(name);
  5666. }
  5667. var airs = new List<AirInfo>();
  5668. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  5669. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  5670. for (int i = 0; i < FlightsCode.Length; i++)
  5671. {
  5672. var air = new AirInfo();
  5673. string[] tempstr = DayArray[i]
  5674. .Replace("\r\n", string.Empty)
  5675. .Replace("\\r\\n", string.Empty)
  5676. .TrimStart().TrimEnd()
  5677. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  5678. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  5679. if (star_Three != null)
  5680. {
  5681. if (!transDic.ContainsKey(star_Three.AirPort))
  5682. {
  5683. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  5684. }
  5685. }
  5686. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  5687. if (End_Three != null)
  5688. {
  5689. if (!transDic.ContainsKey(End_Three.AirPort))
  5690. {
  5691. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  5692. }
  5693. }
  5694. if (!texts.Contains(item.CTypeName))
  5695. {
  5696. texts.Add(item.CTypeName);
  5697. }
  5698. }
  5699. }
  5700. List<TranslateResult> transData = await _airTicketResRep.ReTransBatch(texts, "en");
  5701. if (transData.Count > 0)
  5702. {
  5703. foreach (TranslateResult item in transData)
  5704. {
  5705. if (!transDic.ContainsKey(item.Query))
  5706. {
  5707. transDic.Add(item.Query, item.Translation);
  5708. }
  5709. }
  5710. }
  5711. foreach (var item in _AirTicketReservations)
  5712. {
  5713. #region 处理固定数据
  5714. string[] FlightsCode = item.FlightsCode.Split('/');
  5715. if (FlightsCode.Length != 0)
  5716. {
  5717. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  5718. if (_AirCompany != null)
  5719. {
  5720. string str = "--";
  5721. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  5722. if (!string.IsNullOrEmpty(translateResult))
  5723. {
  5724. str = translateResult;
  5725. str = _airTicketResRep.Processing(str);
  5726. }
  5727. table.Range.Bookmarks["AirlineCompany"].Text = str;
  5728. }
  5729. else
  5730. {
  5731. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  5732. }
  5733. }
  5734. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  5735. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  5736. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  5737. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  5738. string names = "";
  5739. foreach (string clientName in nameArray)
  5740. {
  5741. names += clientName + ",";
  5742. }
  5743. if (!string.IsNullOrWhiteSpace(names))
  5744. {
  5745. string str = "--";
  5746. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  5747. if (!string.IsNullOrEmpty(translateResult))
  5748. {
  5749. str = translateResult;
  5750. str = _airTicketResRep.Processing(str);
  5751. }
  5752. table.Range.Bookmarks["ClientName"].Text = str;
  5753. }
  5754. else
  5755. {
  5756. table.Range.Bookmarks["ClientName"].Text = "--";
  5757. }
  5758. table.Range.Bookmarks["TicketNumber"].Text = "--";
  5759. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  5760. table.Range.Bookmarks["JointTicket"].Text = "--";
  5761. table.Range.Bookmarks["TimeIssue"].Text = "--";
  5762. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  5763. table.Range.Bookmarks["NavigationCode"].Text = "--";
  5764. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  5765. table.Range.Bookmarks["AgentPhone"].Text = "--";
  5766. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  5767. #endregion
  5768. #region 循环数据处理
  5769. var airs = new List<AirInfo>();
  5770. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  5771. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  5772. for (int i = 0; i < FlightsCode.Length; i++)
  5773. {
  5774. var air = new AirInfo();
  5775. string[] tempstr = DayArray[i]
  5776. .Replace("\r\n", string.Empty)
  5777. .Replace("\\r\\n", string.Empty)
  5778. .TrimStart().TrimEnd()
  5779. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  5780. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  5781. string starCity = "";
  5782. if (star_Three != null)
  5783. {
  5784. string str2 = "--";
  5785. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  5786. if (!string.IsNullOrEmpty(translateResult2))
  5787. {
  5788. str2 = translateResult2;
  5789. str2 = _airTicketResRep.Processing(str2);
  5790. }
  5791. starCity = str2;
  5792. }
  5793. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  5794. string EndCity = "";
  5795. if (End_Three != null)
  5796. {
  5797. string str1 = "--";
  5798. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  5799. if (!string.IsNullOrEmpty(translateResult1))
  5800. {
  5801. str1 = translateResult1;
  5802. str1 = _airTicketResRep.Processing(str1);
  5803. }
  5804. EndCity = str1;
  5805. }
  5806. air.Destination = starCity + "/" + EndCity;
  5807. air.Flight = FlightsCode[i];
  5808. string str = "--";
  5809. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  5810. if (!string.IsNullOrEmpty(translateResult))
  5811. {
  5812. str = translateResult;
  5813. str = _airTicketResRep.Processing(str);
  5814. }
  5815. air.SeatingClass = str;
  5816. string dateTime = tempstr[2];
  5817. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  5818. air.FlightDate = DateTemp;
  5819. air.DepartureTime = tempstr[5];
  5820. air.LandingTime = tempstr[6];
  5821. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  5822. air.TicketStatus = "--";
  5823. air.Luggage = "--";
  5824. air.DepartureTerminal = "--";
  5825. air.LandingTerminal = "--";
  5826. airs.Add(air);
  5827. }
  5828. int row = 13;
  5829. for (int i = 0; i < airs.Count; i++)
  5830. {
  5831. if (airs.Count > 2)
  5832. {
  5833. for (int j = 0; j < airs.Count - 2; j++)
  5834. {
  5835. var CopyRow = table.Rows[12].Clone(true);
  5836. table.Rows.Add(CopyRow);
  5837. }
  5838. }
  5839. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  5840. int index = 0;
  5841. foreach (PropertyInfo property in properties)
  5842. {
  5843. string value = property.GetValue(airs[i]).ToString();
  5844. Cell ishcel0 = table.Rows[row].Cells[index];
  5845. var p = new Paragraph(doc);
  5846. string s = value;
  5847. p.AppendChild(new Run(doc, s));
  5848. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  5849. ishcel0.AppendChild(p);
  5850. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  5851. //ishcel0.CellFormat.VerticalAlignment=
  5852. index++;
  5853. }
  5854. row++;
  5855. }
  5856. #endregion
  5857. var lastParagraph = new Paragraph(doc);
  5858. //第一个表格末尾加段落
  5859. table.ParentNode.InsertAfter(lastParagraph, table);
  5860. //复制第一个表格
  5861. Table cloneTable = (Table)table.Clone(true);
  5862. //在文档末尾段落后面加入复制的表格
  5863. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  5864. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  5865. {
  5866. int rownewsIndex = 13;
  5867. for (int i = 0; i < 2; i++)
  5868. {
  5869. var CopyRow = table.Rows[12].Clone(true);
  5870. table.Rows.RemoveAt(13);
  5871. table.Rows.Add(CopyRow);
  5872. rownewsIndex++;
  5873. }
  5874. }
  5875. else
  5876. {
  5877. table.Rows.RemoveAt(12);
  5878. }
  5879. cloneTable.Rows.RemoveAt(12);
  5880. }
  5881. if (_AirTicketReservations.Count != 0)
  5882. {
  5883. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  5884. if (FlightsCode.Length != 0)
  5885. {
  5886. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  5887. if (_AirCompany != null)
  5888. {
  5889. string str = "--";
  5890. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  5891. if (!string.IsNullOrEmpty(translateResult))
  5892. {
  5893. str = translateResult;
  5894. str = _airTicketResRep.Processing(str);
  5895. }
  5896. table.Range.Bookmarks["AirlineCompany"].Text = str;
  5897. }
  5898. else
  5899. {
  5900. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  5901. }
  5902. }
  5903. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  5904. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  5905. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  5906. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  5907. string names = "";
  5908. foreach (string clientName in nameArray)
  5909. {
  5910. names += clientName + ",";
  5911. }
  5912. if (!string.IsNullOrWhiteSpace(names))
  5913. {
  5914. string str = "--";
  5915. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  5916. if (!string.IsNullOrEmpty(translateResult))
  5917. {
  5918. str = translateResult;
  5919. str = _airTicketResRep.Processing(str);
  5920. }
  5921. table.Range.Bookmarks["ClientName"].Text = str;
  5922. }
  5923. else
  5924. {
  5925. table.Range.Bookmarks["ClientName"].Text = "--";
  5926. }
  5927. table.Range.Bookmarks["TicketNumber"].Text = "--";
  5928. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  5929. table.Range.Bookmarks["JointTicket"].Text = "--";
  5930. table.Range.Bookmarks["TimeIssue"].Text = "--";
  5931. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  5932. table.Range.Bookmarks["NavigationCode"].Text = "--";
  5933. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  5934. table.Range.Bookmarks["AgentPhone"].Text = "--";
  5935. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  5936. }
  5937. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  5938. //保存合并后的文档
  5939. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  5940. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  5941. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  5942. return Ok(JsonView(true, "成功!", rst));
  5943. }
  5944. }
  5945. }
  5946. catch (Exception ex)
  5947. {
  5948. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  5949. throw;
  5950. }
  5951. }
  5952. #endregion
  5953. #region 团组增减款项 --> 其他款项
  5954. /// <summary>
  5955. /// 团组增减款项下拉框绑定
  5956. /// </summary>
  5957. /// <param name="dto"></param>
  5958. /// <returns></returns>
  5959. [HttpPost]
  5960. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5961. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  5962. {
  5963. #region 参数验证
  5964. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  5965. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  5966. #endregion
  5967. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  5968. }
  5969. /// <summary>
  5970. /// 根据团组Id查询团组增减款项
  5971. /// </summary>
  5972. /// <param name="dto"></param>
  5973. /// <returns></returns>
  5974. [HttpPost]
  5975. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5976. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  5977. {
  5978. #region 参数验证
  5979. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  5980. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  5981. #endregion
  5982. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  5983. }
  5984. /// <summary>
  5985. /// 团组增减款项操作(Status:1.新增,2.修改)
  5986. /// </summary>
  5987. /// <param name="dto"></param>
  5988. /// <returns></returns>
  5989. [HttpPost]
  5990. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5991. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  5992. {
  5993. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  5994. if (groupData.Code != 200)
  5995. {
  5996. return Ok(JsonView(false, groupData.Msg));
  5997. }
  5998. #region 应用推送
  5999. //int otherId = (int)groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  6000. //int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  6001. //int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  6002. int otherId = Convert.ToInt32(groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null) ?? 0);
  6003. int ccpId = Convert.ToInt32(groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null) ?? 0);
  6004. int sign = Convert.ToInt32(groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null) ?? 0);
  6005. bool recheck = Convert.ToBoolean(groupData.Data.GetType().GetProperty("recheck").GetValue(groupData.Data, null) ?? "True");
  6006. if (recheck)
  6007. {
  6008. //自动审核
  6009. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(3, dto.DiId, otherId);
  6010. }
  6011. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  6012. //2024-10-21 新增LZ UID
  6013. var userIds = new List<int>() { 21 };
  6014. string title = $"系统通知";
  6015. string content = "";
  6016. var diId = dto.DiId;
  6017. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  6018. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  6019. if (dto.Status == 1) content = $"[新增-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  6020. else if (dto.Status == 2) content = $"[更新-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  6021. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  6022. //await APNsTools.iOS_PushNotifications1("051", $"其他款项费用审核", "", content);
  6023. #endregion
  6024. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6025. }
  6026. /// <summary>
  6027. /// 团组增减款项操作 删除
  6028. /// </summary>
  6029. /// <param name="dto"></param>
  6030. /// <returns></returns>
  6031. [HttpPost]
  6032. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6033. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  6034. {
  6035. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  6036. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  6037. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  6038. if (res.Code == 0) return Ok(JsonView(true, "删除成功!"));
  6039. return Ok(JsonView(false, res?.Msg ?? "删除失败!"));
  6040. }
  6041. /// <summary>
  6042. /// 根据团组增减款项Id查询
  6043. /// </summary>
  6044. /// <param name="dto"></param>
  6045. /// <returns></returns>
  6046. [HttpPost]
  6047. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6048. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  6049. {
  6050. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  6051. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  6052. }
  6053. /// <summary>
  6054. /// 查询供应商名称
  6055. /// </summary>
  6056. /// <param name="dto"></param>
  6057. /// <returns></returns>
  6058. [HttpPost]
  6059. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  6060. {
  6061. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  6062. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  6063. ?? new List<Grp_DecreasePayments>();
  6064. dbResult = dbResult.Distinct(new
  6065. ProductComparer()).ToList();
  6066. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  6067. {
  6068. x.Id,
  6069. x.SupplierAddress,
  6070. x.SupplierArea,
  6071. x.SupplierContact,
  6072. x.SupplierContactNumber,
  6073. x.SupplierEmail,
  6074. x.SupplierName,
  6075. x.SupplierSocialAccount,
  6076. x.SupplierTypeId,
  6077. }).ToList());
  6078. return Ok(jw);
  6079. }
  6080. /// <summary>
  6081. /// 团组增减款项 OTA匹配
  6082. /// </summary>
  6083. /// <param name="file"></param>
  6084. /// <returns></returns>
  6085. [HttpPost]
  6086. public async Task<IActionResult> DecreasePaymentsOTAMate(IFormFile file)
  6087. {
  6088. if (file.Length < 1) return Ok(JsonView(false, "请上传文件!"));
  6089. string fileName = file.FileName;
  6090. if (!fileName.EndsWith(".xlsx") && !fileName.EndsWith(".xls"))
  6091. {
  6092. return Ok(JsonView(false, "请上传Excel文件!"));
  6093. }
  6094. //D:\FTP\File\OA2023\Office\GrpFile\团组增减款项相关文件\团组其他款项(OTA)
  6095. var path = @$"{AppSettingsHelper.Get("GrpFileBasePath")}团组增减款项相关文件/团组其他款项(OTA)";
  6096. if (!Directory.Exists(path))
  6097. {
  6098. Directory.CreateDirectory(path);
  6099. }
  6100. var filePath = @$"{path}/{fileName}";
  6101. //保存文件
  6102. using (FileStream fs = System.IO.File.Create(filePath))
  6103. {
  6104. file.CopyTo(fs);
  6105. fs.Flush();
  6106. }
  6107. if (!System.IO.File.Exists(filePath)) return Ok(JsonView(false, "文件不存在!"));
  6108. //读取ExcelFile
  6109. DataTable dt = ConvertExcelToDataTable(filePath);
  6110. if (dt == null) return Ok(JsonView(false, $"您上传的Excel工作表没有内容,请检查!!!"));
  6111. dt.TableName = "TB";
  6112. //修改table列名
  6113. dt.Columns[0].ColumnName = "OrderNo"; // 订单号
  6114. dt.Columns[1].ColumnName = "OTAOrderNo"; // OTA订单号
  6115. dt.Columns[2].ColumnName = "PackageName"; // 套餐名
  6116. dt.Columns[3].ColumnName = "IsPay"; // 是否支付
  6117. dt.Columns[4].ColumnName = "IsShipments"; // 是否发货
  6118. dt.Columns[5].ColumnName = "IsSendBack"; // 是否寄回
  6119. dt.Columns[6].ColumnName = "OpUser"; // 使用人信息
  6120. dt.Columns[7].ColumnName = "OrderTime"; // 下单时间
  6121. dt.Columns[8].ColumnName = "UseTime"; // 使用时间
  6122. dt.Columns[9].ColumnName = "Quantity"; // 台数
  6123. dt.Columns[10].ColumnName = "Days"; // 租赁天数
  6124. dt.Columns[11].ColumnName = "QuantityShipped";// 发货数量
  6125. dt.Columns[12].ColumnName = "TotalPrice"; // 总金额
  6126. dt.Columns[13].ColumnName = "GroupName"; // 团组名称
  6127. dt.Columns[14].ColumnName = "OATotalPrice"; // OA金额
  6128. var otaOrderNos = new List<string>();
  6129. foreach (DataRow item in dt.Rows)
  6130. {
  6131. otaOrderNos.Add(item["OTAOrderNo"].ToString());
  6132. }
  6133. var oaDatas = await _sqlSugar.Queryable<Grp_DecreasePayments>()
  6134. .LeftJoin<Grp_DelegationInfo>((dp, di) => dp.DiId == di.Id)
  6135. .Where((dp, di) => dp.IsDel == 0 && dp.PriceName.Contains("wifi") || otaOrderNos.Contains(dp.OTAOrderNo))
  6136. .Select((dp, di) => new
  6137. {
  6138. dp.PriceName,
  6139. dp.OTAOrderNo,
  6140. dp.FeeTotal,
  6141. di.TeamName,
  6142. })
  6143. .ToListAsync();
  6144. foreach (DataRow item in dt.Rows)
  6145. {
  6146. var otaOrderNo = item["OTAOrderNo"].ToString();
  6147. var oaData = oaDatas.Find(x => !string.IsNullOrEmpty(x.OTAOrderNo) && x.OTAOrderNo.Contains(otaOrderNo));
  6148. if (oaData == null) continue;
  6149. item["GroupName"] = oaData.TeamName;
  6150. item["OATotalPrice"] = oaData.FeeTotal.ToString("#0.00");
  6151. }
  6152. string fileName1 = $"OTA_WIFI费用{DateTime.Now:yyyyMMddHHmmss}.xls";
  6153. var pairs = new Dictionary<string, object>();
  6154. var datas = new List<DataTable>
  6155. {
  6156. dt
  6157. };
  6158. url = AsposeHelper.ExpertExcelToModel("WIFI费用清单-模板.xlsx", $"GrpFile/团组增减款项相关文件/团组其他款项(OTA)", fileName1, pairs, datas);
  6159. return Ok(JsonView(true, "操作成功", new { url }));
  6160. }
  6161. #region
  6162. private static DataTable ConvertExcelToDataTable(string excelFilePath)
  6163. {
  6164. // 创建Workbook对象
  6165. var workbook = new Workbook(excelFilePath);
  6166. // 获取第一个工作表
  6167. var worksheet = workbook.Worksheets[0];
  6168. // 将工作表转换为DataTable
  6169. DataTable dataTable = worksheet.Cells.ExportDataTable(1, 0, worksheet.Cells.MaxDataRow + 1, worksheet.Cells.MaxDataColumn + 1);
  6170. return dataTable;
  6171. }
  6172. #endregion
  6173. /// <summary>
  6174. /// 世运会数据
  6175. /// </summary>
  6176. /// <returns></returns>
  6177. [HttpGet]
  6178. public IActionResult WorldGamesData()
  6179. {
  6180. var setData = _sqlSugar.Queryable<Grp_GamesBudgetMaster>().Where(x => x.IsDel == 0).ToList();
  6181. var groupMenu = setData.GroupBy(x => x.T0);
  6182. var resultArr = new List<DecreasePaymentsWorldGamesDataView>();
  6183. foreach (var item in groupMenu)
  6184. {
  6185. resultArr.Add(new DecreasePaymentsWorldGamesDataView
  6186. {
  6187. Data = new SetDataView
  6188. {
  6189. Name = item.Key
  6190. },
  6191. Child = item.Select(x => x.CalculationContent).ToList() ?? new List<string>()
  6192. });
  6193. }
  6194. return Ok(JsonView(true, "success", resultArr));
  6195. }
  6196. #endregion
  6197. #region 文件上传、删除
  6198. /// <summary>
  6199. /// region 文件上传 可以带参数
  6200. /// </summary>
  6201. /// <param name="file"></param>
  6202. /// <returns></returns>
  6203. [HttpPost]
  6204. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6205. public async Task<IActionResult> UploadProject(IFormFile file)
  6206. {
  6207. //var TypeName = Request.Headers["TypeName"].ToString();
  6208. //if (file == null) return Ok(JsonView(false, "文件不存在!"));
  6209. //var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  6210. ////文件名称
  6211. //string projectFileName = file.FileName;
  6212. ////上传的文件的路径
  6213. //string filePath = $"{fileDir}/{projectFileName}";
  6214. //if (TypeName == "A")//A代表团组增减款项
  6215. //{
  6216. // filePath = fileDir + $@"\团组增减款项相关文件";
  6217. // if (!Directory.Exists(filePath))
  6218. // {
  6219. // Directory.CreateDirectory(filePath);
  6220. // }
  6221. // //上传的文件的路径
  6222. // filePath += $@"\{projectFileName}";
  6223. //}
  6224. //else if (TypeName == "B")//B代表商邀相关文件
  6225. //{
  6226. // //上传的文件的路径
  6227. // filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  6228. // if (!Directory.Exists(filePath))
  6229. // {
  6230. // Directory.CreateDirectory(filePath);
  6231. // }
  6232. // //上传的文件的路径
  6233. // filePath = $@"\{projectFileName}";
  6234. //}
  6235. //try
  6236. //{
  6237. // using (FileStream fs = System.IO.File.Create(filePath))
  6238. // {
  6239. // file.CopyTo(fs);
  6240. // fs.Flush();
  6241. // }
  6242. //}
  6243. //catch (Exception ex)
  6244. //{
  6245. // return Ok(JsonView(false, $"文件上传失败! Error:{ex.Message}"));
  6246. //}
  6247. //return Ok(JsonView(true, "上传成功!", projectFileName));
  6248. try
  6249. {
  6250. var TypeName = Request.Headers["TypeName"].ToString();
  6251. if (file != null)
  6252. {
  6253. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  6254. //文件名称
  6255. string projectFileName = file.FileName;
  6256. //上传的文件的路径
  6257. string filePath = $"{fileDir}/{projectFileName}";
  6258. if (TypeName == "A")//A代表团组增减款项
  6259. {
  6260. if (!Directory.Exists(fileDir))
  6261. {
  6262. Directory.CreateDirectory(fileDir);
  6263. }
  6264. //上传的文件的路径
  6265. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  6266. }
  6267. else if (TypeName == "B")//B代表商邀相关文件
  6268. {
  6269. if (!Directory.Exists(fileDir))
  6270. {
  6271. Directory.CreateDirectory(fileDir);
  6272. }
  6273. //上传的文件的路径
  6274. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  6275. }
  6276. using (FileStream fs = System.IO.File.Create(filePath))
  6277. {
  6278. file.CopyTo(fs);
  6279. fs.Flush();
  6280. }
  6281. return Ok(JsonView(true, "上传成功!", projectFileName));
  6282. }
  6283. else
  6284. {
  6285. return Ok(JsonView(false, "上传失败!"));
  6286. }
  6287. }
  6288. catch (Exception ex)
  6289. {
  6290. return Ok(JsonView(false, ex.Message));
  6291. }
  6292. }
  6293. /// <summary>
  6294. /// 删除指定文件
  6295. /// </summary>
  6296. /// <param name="dto"></param>
  6297. /// <returns></returns>
  6298. [HttpPost]
  6299. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6300. public async Task<IActionResult> DelFile(DelFileDto dto)
  6301. {
  6302. try
  6303. {
  6304. var TypeName = Request.Headers["TypeName"].ToString();
  6305. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  6306. string filePath = "";
  6307. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  6308. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  6309. int id = 0;
  6310. if (TypeName == "A")
  6311. {
  6312. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  6313. // 删除该文件
  6314. System.IO.File.Delete(filePath);
  6315. id = await _sqlSugar.Updateable<Grp_DecreasePayments>()
  6316. .Where(a => a.Id == dto.Id)
  6317. .SetColumns(a => new Grp_DecreasePayments { FilePath = "" })
  6318. .ExecuteCommandAsync();
  6319. }
  6320. else if (TypeName == "B")
  6321. {
  6322. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  6323. // 删除该文件
  6324. System.IO.File.Delete(filePath);
  6325. var info = await _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.Id == dto.Id && x.IsDel == 0).FirstAsync();
  6326. if (info != null)
  6327. {
  6328. string[] files = Array.Empty<string>();
  6329. if (!string.IsNullOrEmpty(info.Attachment))
  6330. {
  6331. try
  6332. {
  6333. files = JsonConvert.DeserializeObject<string[]>(info.Attachment);
  6334. }
  6335. catch (Exception)
  6336. {
  6337. files = new List<string>() { info.Attachment }.ToArray();
  6338. }
  6339. }
  6340. if (files.Length > 0)
  6341. {
  6342. var files1 = files.Where(x => !x.Equals(dto.fileName)).ToArray();
  6343. string filePath2 = string.Empty;
  6344. if (files1.Length > 0)
  6345. {
  6346. filePath2 = JsonConvert.SerializeObject(files1);
  6347. }
  6348. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  6349. .Where(a => a.Id == dto.Id)
  6350. .SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = filePath2 })
  6351. .ExecuteCommandAsync();
  6352. }
  6353. }
  6354. }
  6355. if (id != 0)
  6356. {
  6357. return Ok(JsonView(true, "成功!"));
  6358. }
  6359. else
  6360. {
  6361. return Ok(JsonView(false, "失败!"));
  6362. }
  6363. }
  6364. catch (Exception ex)
  6365. {
  6366. return Ok(JsonView(false, "程序错误!"));
  6367. throw;
  6368. }
  6369. }
  6370. /// <summary>
  6371. /// 文件上传多个文件 可以带参数
  6372. /// </summary>
  6373. /// <param name="files"></param>
  6374. /// <returns></returns>
  6375. [HttpPost]
  6376. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6377. public async Task<IActionResult> UploadProjects(IFormFile[] files)
  6378. {
  6379. try
  6380. {
  6381. var TypeName = Request.Headers["TypeName"].ToString();
  6382. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  6383. if (files.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  6384. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  6385. var filePahts = new List<string>();
  6386. foreach (var file in files)
  6387. {
  6388. //文件名称
  6389. string projectFileName = file.FileName;
  6390. //上传的文件的路径
  6391. string filePath = $"{fileDir}/{projectFileName}";
  6392. if (TypeName == "A")//A代表团组增减款项
  6393. {
  6394. if (!Directory.Exists(fileDir))
  6395. {
  6396. Directory.CreateDirectory(fileDir);
  6397. }
  6398. //上传的文件的路径
  6399. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  6400. }
  6401. else if (TypeName == "B")//B代表商邀相关文件
  6402. {
  6403. if (!Directory.Exists(fileDir))
  6404. {
  6405. Directory.CreateDirectory(fileDir);
  6406. }
  6407. //上传的文件的路径
  6408. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  6409. }
  6410. using (FileStream fs = System.IO.File.Create(filePath))
  6411. {
  6412. file.CopyTo(fs);
  6413. fs.Flush();
  6414. }
  6415. filePahts.Add(projectFileName);
  6416. }
  6417. return Ok(JsonView(true, "上传成功!", filePahts));
  6418. }
  6419. catch (Exception ex)
  6420. {
  6421. return Ok(JsonView(false, ex.Message));
  6422. }
  6423. }
  6424. #endregion
  6425. #region 商邀费用录入
  6426. /// <summary>
  6427. /// 根据团组Id查询商邀费用列表
  6428. /// </summary>
  6429. /// <param name="dto"></param>
  6430. /// <returns></returns>
  6431. [HttpPost]
  6432. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6433. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  6434. {
  6435. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  6436. if (groupData.Code != 0)
  6437. {
  6438. return Ok(JsonView(false, groupData.Msg));
  6439. }
  6440. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6441. }
  6442. /// <summary>
  6443. /// 商邀费用列表
  6444. /// 下载文件
  6445. /// </summary>
  6446. /// <param name="id"></param>
  6447. /// <returns></returns>
  6448. [HttpGet("{id}")]
  6449. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6450. public async Task<IActionResult> InvitationOfficialActivitiesListDownFile(int id)
  6451. {
  6452. if (id < 1) return Ok(JsonView(false, "请传入有效的Id!"));
  6453. var info = await _InvitationOfficialActivitiesRep.Query(x => x.Id == id).FirstAsync();
  6454. if (info == null) return Ok(JsonView(false, "数据不存在!"));
  6455. if (string.IsNullOrEmpty(info.Attachment)) return Ok(JsonView(false, "文件不存在!"));
  6456. var filePaths = new List<string>();
  6457. var filePathBase = @$"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/";
  6458. try
  6459. {
  6460. filePaths = JsonConvert.DeserializeObject<List<string>>(info.Attachment);
  6461. }
  6462. catch (Exception ex)
  6463. {
  6464. filePaths.Add(info.Attachment);
  6465. }
  6466. if (filePaths != null && filePaths.Count < 1) return Ok(JsonView(false, "文件不存在!"));
  6467. for (int i = 0; i < filePaths.Count; i++)
  6468. {
  6469. filePaths[i] = $"{filePathBase}{filePaths[i]}";
  6470. }
  6471. var zipFilePathGuid = $"{Guid.NewGuid()}.zip";
  6472. var zipFilePath = $"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{zipFilePathGuid}";
  6473. using (var zipFileStream = new FileStream(zipFilePath, FileMode.Create))
  6474. {
  6475. using (var zipArchive = new ZipArchive(zipFileStream, ZipArchiveMode.Create))
  6476. {
  6477. foreach (string filePath in filePaths)
  6478. {
  6479. if (System.IO.File.Exists(filePath))
  6480. {
  6481. // 获取文件名
  6482. string fileName = Path.GetFileName(filePath);
  6483. // 将文件添加到ZIP归档中
  6484. zipArchive.CreateEntryFromFile(filePath, fileName);
  6485. }
  6486. }
  6487. }
  6488. }
  6489. return Ok(JsonView(new { url = @$"{AppSettingsHelper.Get("OfficeBaseUrl")}{AppSettingsHelper.Get("GrpFileFtpPath")}/商邀相关文件/{zipFilePathGuid}" }));
  6490. }
  6491. /// <summary>
  6492. /// 商邀费用 Info Page 基础数据源
  6493. /// </summary>
  6494. /// <returns></returns>
  6495. [HttpPost]
  6496. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6497. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  6498. {
  6499. try
  6500. {
  6501. Result groupData = await _InvitationOfficialActivitiesRep.InitBasicData();
  6502. if (groupData.Code != 0)
  6503. {
  6504. return Ok(JsonView(false, groupData.Msg));
  6505. }
  6506. return Ok(JsonView(true, "操作成功", groupData.Data));
  6507. }
  6508. catch (Exception ex)
  6509. {
  6510. return Ok(JsonView(false, ex.Message));
  6511. throw;
  6512. }
  6513. }
  6514. /// <summary>
  6515. /// 根据商邀费用ID查询C表和商邀费用数据
  6516. /// </summary>
  6517. /// <param name="dto"></param>
  6518. /// <returns></returns>
  6519. [HttpPost]
  6520. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6521. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  6522. {
  6523. try
  6524. {
  6525. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  6526. if (groupData.Code != 0)
  6527. {
  6528. return Ok(JsonView(false, groupData.Msg));
  6529. }
  6530. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6531. }
  6532. catch (Exception ex)
  6533. {
  6534. return Ok(JsonView(false, ex.Message));
  6535. throw;
  6536. }
  6537. }
  6538. /// <summary>
  6539. /// 商邀费用录入操作(Status:1.新增,2.修改)
  6540. /// </summary>
  6541. /// <param name="dto"></param>
  6542. /// <returns></returns>
  6543. [HttpPost]
  6544. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6545. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  6546. {
  6547. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  6548. if (groupData.Code != 0)
  6549. {
  6550. return Ok(JsonView(false, groupData.Msg));
  6551. }
  6552. #region 应用推送
  6553. try
  6554. {
  6555. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  6556. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  6557. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  6558. //2024-10-21 新增LZ UID
  6559. var userIds = new List<int>() { 21 };
  6560. string title = $"系统通知";
  6561. string content = "";
  6562. var diId = dto.DiId;
  6563. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  6564. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  6565. if (dto.Status == 1) content = $"[新增-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  6566. else if (dto.Status == 2) content = $"[更新-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  6567. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  6568. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "81" };
  6569. await APNsTools.iOS_PushNotifications1("051", $"商邀费用审核", "", content, true, "ExpenseAuditWebView", h5);
  6570. }
  6571. catch (Exception ex)
  6572. {
  6573. }
  6574. #endregion
  6575. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6576. }
  6577. /// <summary>
  6578. /// 商邀删除
  6579. /// </summary>
  6580. /// <param name="dto"></param>
  6581. /// <returns></returns>
  6582. [HttpPost]
  6583. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6584. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  6585. {
  6586. try
  6587. {
  6588. _sqlSugar.BeginTran();
  6589. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  6590. .SetColumns(it => new Grp_InvitationOfficialActivities()
  6591. {
  6592. IsDel = 1,
  6593. DeleteUserId = dto.DeleteUserId,
  6594. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6595. })
  6596. .Where(it => it.Id == dto.Id)
  6597. .ExecuteCommand();
  6598. if (res1 > 0)
  6599. {
  6600. int _diId = 0;
  6601. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  6602. if (_ioaInfo != null)
  6603. {
  6604. _diId = _ioaInfo.DiId;
  6605. }
  6606. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  6607. .SetColumns(a => new Grp_CreditCardPayment()
  6608. {
  6609. IsDel = 1,
  6610. DeleteUserId = dto.DeleteUserId,
  6611. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6612. })
  6613. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  6614. .ExecuteCommand();
  6615. if (res2 > 0)
  6616. {
  6617. _sqlSugar.CommitTran();
  6618. return Ok(JsonView(true, "删除成功!"));
  6619. }
  6620. }
  6621. _sqlSugar.RollbackTran();
  6622. return Ok(JsonView(false, "删除失败"));
  6623. }
  6624. catch (Exception ex)
  6625. {
  6626. _sqlSugar.RollbackTran();
  6627. return Ok(JsonView(false, ex.Message));
  6628. }
  6629. }
  6630. #endregion
  6631. #region 票据上传
  6632. /// <summary>
  6633. /// 团组模块文件上传
  6634. /// </summary>
  6635. /// <param name="dto"></param>
  6636. /// <returns></returns>
  6637. [HttpPost]
  6638. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  6639. {
  6640. var jw = JsonView(false);
  6641. long M = 1024 * 1024;
  6642. if (dto.Files == null || dto.Files.Count == 0)
  6643. {
  6644. jw.Msg = "无文件信息!";
  6645. return Ok(jw);
  6646. }
  6647. if (dto.Files.Sum(x => x.Length) > 20 * M)
  6648. {
  6649. jw.Msg = "文件大小超过20M!";
  6650. return Ok(jw);
  6651. }
  6652. //var nameSp = dto.File.FileName.Split(".");
  6653. //if (nameSp.Length < 2)
  6654. //{
  6655. // jw.Msg = "拓展名称有误!";
  6656. // return Ok(jw);
  6657. //}
  6658. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  6659. //if (!existsName.Contains(nameSp[1].ToUpper()))
  6660. //{
  6661. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  6662. // return Ok(jw);
  6663. //}
  6664. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  6665. if (Ctable == null)
  6666. {
  6667. jw.Msg = "Ctable指向有误!";
  6668. return Ok(jw);
  6669. }
  6670. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  6671. if (groupInfo == null)
  6672. {
  6673. jw.Msg = "团组信息不存在!";
  6674. return Ok(jw);
  6675. }
  6676. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  6677. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  6678. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  6679. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  6680. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  6681. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  6682. try
  6683. {
  6684. if (!Directory.Exists(fileBase))
  6685. {
  6686. Directory.CreateDirectory(fileBase);
  6687. }
  6688. var saveArr = new List<Grp_GroupModelFile>();
  6689. foreach (var fileStream in dto.Files)
  6690. {
  6691. var saveFilePath = fileBase + "\\" + fileStream.FileName;
  6692. var file = new Grp_GroupModelFile()
  6693. {
  6694. Cid = dto.Cid,
  6695. CreateTime = DateTime.Now,
  6696. CreateUserId = dto.Userid,
  6697. Ctable = dto.Ctable,
  6698. Diid = dto.Diid,
  6699. IsDel = 0,
  6700. FilePath = saveFilePath,
  6701. FileName = fileStream.FileName
  6702. };
  6703. using (FileStream fs = System.IO.File.Create(saveFilePath))
  6704. {
  6705. fileStream.CopyTo(fs);
  6706. fs.Flush();
  6707. }
  6708. saveArr.Add(file);
  6709. }
  6710. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  6711. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  6712. jw = JsonView(true, "保存成功!", new
  6713. {
  6714. count = addResult,
  6715. filesName = saveArr.Select(x => x.FileName)
  6716. });
  6717. }
  6718. catch (Exception ex)
  6719. {
  6720. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  6721. {
  6722. count = 0,
  6723. filesName = Array.Empty<string>(),
  6724. });
  6725. }
  6726. return Ok(jw);
  6727. }
  6728. /// <summary>
  6729. /// 查询各模块已保存文件
  6730. /// </summary>
  6731. /// <param name="dto"></param>
  6732. /// <returns></returns>
  6733. [HttpPost]
  6734. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  6735. {
  6736. var expression = Expressionable.Create<Grp_GroupModelFile>()
  6737. .AndIF(dto.UserId != -1, x => x.CreateUserId == dto.UserId);
  6738. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x => x.Id).ToList();
  6739. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  6740. {
  6741. expression = Expressionable.Create<Grp_GroupModelFile>()
  6742. .And(x => visaIds.Contains(x.CreateUserId));
  6743. }
  6744. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  6745. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  6746. .Where(expression.ToExpression())
  6747. .ToList();
  6748. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  6749. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  6750. {
  6751. x.FileName,
  6752. x.Id,
  6753. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  6754. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  6755. })));
  6756. }
  6757. /// <summary>
  6758. /// 下载该团组下的所有文件
  6759. /// </summary>
  6760. /// <param name="dto"></param>
  6761. /// <returns></returns>
  6762. [HttpPost]
  6763. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  6764. {
  6765. var jw = JsonView(false);
  6766. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  6767. if (groupInfo == null)
  6768. {
  6769. jw.Msg = "团组信息不存在!";
  6770. return Ok(jw);
  6771. }
  6772. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  6773. var isModule = Convert.ToBoolean(dto.isModule);
  6774. var Zips = new Dictionary<string, Stream>();
  6775. var io = new IOOperatorHelper();
  6776. if (isModule)
  6777. {
  6778. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  6779. foreach (var moduleArr in moduleGroup)
  6780. {
  6781. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  6782. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  6783. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  6784. var chiZips = new Dictionary<string, Stream>();
  6785. foreach (var item in moduleArr)
  6786. {
  6787. if (System.IO.File.Exists(item.FilePath))
  6788. {
  6789. using (var fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  6790. {
  6791. byte[] bytes = new byte[fileStream.Length];
  6792. fileStream.Read(bytes, 0, bytes.Length);
  6793. fileStream.Close();
  6794. Stream stream = new MemoryStream(bytes);
  6795. chiZips.Add(item.FileName, stream);
  6796. }
  6797. }
  6798. }
  6799. if (chiZips.Count > 0)
  6800. {
  6801. var byts = io.ConvertZipStream(chiZips);
  6802. Stream stream = new MemoryStream(byts);
  6803. Zips.Add(key.Name + "_.zip", stream);
  6804. }
  6805. }
  6806. }
  6807. else
  6808. {
  6809. foreach (var item in dbQuery)
  6810. {
  6811. using (var fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  6812. {
  6813. byte[] bytes = new byte[fileStream.Length];
  6814. fileStream.Read(bytes, 0, bytes.Length);
  6815. fileStream.Close();
  6816. var stream = new MemoryStream(bytes);
  6817. while (Zips.ContainsKey(item.FileName))
  6818. {
  6819. item.FileName = new Random().Next(100) + "_" + item.FileName;
  6820. }
  6821. Zips.Add(item.FileName, stream);
  6822. }
  6823. }
  6824. }
  6825. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  6826. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  6827. if (Zips.Count > 0)
  6828. {
  6829. var byts = io.ConvertZipStream(Zips);
  6830. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  6831. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  6832. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  6833. }
  6834. else
  6835. {
  6836. jw.Msg = "暂无生成文件!";
  6837. }
  6838. return Ok(jw);
  6839. }
  6840. /// <summary>
  6841. /// 下载该团组下此模块的所有文件
  6842. /// </summary>
  6843. /// <param name="dto"></param>
  6844. /// <returns></returns>
  6845. [HttpPost]
  6846. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  6847. {
  6848. var jw = JsonView(false);
  6849. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  6850. if (groupInfo == null)
  6851. {
  6852. jw.Msg = "团组信息不存在!";
  6853. return Ok(jw);
  6854. }
  6855. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  6856. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  6857. && x.IsDel == 0);
  6858. if (key == null)
  6859. {
  6860. jw.Msg = "Ctable指向错误!";
  6861. return Ok(jw);
  6862. }
  6863. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  6864. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  6865. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  6866. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  6867. var io = new IOOperatorHelper();
  6868. var Zips = new Dictionary<string, Stream>();
  6869. foreach (var item in dbQuery)
  6870. {
  6871. if (System.IO.File.Exists(item.FilePath))
  6872. {
  6873. using (var fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  6874. {
  6875. byte[] bytes = new byte[fileStream.Length];
  6876. fileStream.Read(bytes, 0, bytes.Length);
  6877. fileStream.Close();
  6878. var stream = new MemoryStream(bytes);
  6879. while (Zips.ContainsKey(item.FileName))
  6880. {
  6881. item.FileName = new Random().Next(100) + "_" + item.FileName;
  6882. }
  6883. Zips.Add(item.FileName, stream);
  6884. }
  6885. }
  6886. }
  6887. if (Zips.Count > 0)
  6888. {
  6889. var byts = io.ConvertZipStream(Zips);
  6890. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  6891. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  6892. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  6893. }
  6894. else
  6895. {
  6896. jw.Msg = "暂无生成文件!";
  6897. }
  6898. return Ok(jw);
  6899. }
  6900. /// <summary>
  6901. /// 删除该团组下的指定文件
  6902. /// </summary>
  6903. /// <param name="dto"></param>
  6904. /// <returns></returns>
  6905. [HttpPost]
  6906. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  6907. {
  6908. var jw = JsonView(false);
  6909. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  6910. if (sing == null)
  6911. {
  6912. jw.Msg = "暂无";
  6913. return Ok(jw);
  6914. }
  6915. if (System.IO.File.Exists(sing.FilePath))
  6916. {
  6917. try
  6918. {
  6919. System.IO.File.Delete(sing.FilePath);
  6920. }
  6921. catch (Exception ex)
  6922. {
  6923. jw.Msg = "删除失败!" + ex.Message;
  6924. return Ok(jw);
  6925. }
  6926. }
  6927. sing.IsDel = 1;
  6928. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  6929. sing.DeleteUserId = dto.UserId;
  6930. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  6931. jw = JsonView(true, "删除成功!");
  6932. return Ok(jw);
  6933. }
  6934. #endregion
  6935. #region 共享文件上传
  6936. /// <summary>
  6937. /// 共享文件数据初始化
  6938. /// </summary>
  6939. /// <returns></returns>
  6940. [HttpGet]
  6941. public async Task<IActionResult> SharedFileInit(int userid, int portType)
  6942. {
  6943. var marketingDepartmentIds = new List<int> { 6, 26, 27, 28 };
  6944. var isMarketingDepartment = _sqlSugar.Queryable<Sys_Users>()
  6945. .Where(x => x.IsDel == 0 && marketingDepartmentIds.Contains(x.DepId))
  6946. .Select(x => x.Id)
  6947. .ToList()
  6948. .Contains(userid);
  6949. var dropDownType = _sqlSugar.Queryable<Sys_SetData>()
  6950. .Where(x => x.STid == 111 && x.IsDel == 0)
  6951. .Select(x => new
  6952. {
  6953. x.Name,
  6954. x.Id,
  6955. }).ToList();
  6956. if (isMarketingDepartment)
  6957. {
  6958. dropDownType = dropDownType.Where(x => x.Id == 1412).ToList();
  6959. }
  6960. if (portType == 1)
  6961. {
  6962. var provCityDatas = await _groupRepository.ProvinceCityBasicSource();
  6963. var dropDownGroupList = _sqlSugar.Queryable<Grp_DelegationInfo>()
  6964. .Where(x => x.IsDel == 0)
  6965. .OrderByDescending(x => x.VisitDate)
  6966. .Select(x => new
  6967. {
  6968. x.TeamName,
  6969. x.Id,
  6970. x.CityId,
  6971. })
  6972. .ToList()
  6973. .Select(x =>
  6974. {
  6975. var provinceId = x.CityId;
  6976. var isDefualtVal = true;
  6977. if (provinceId > 0)
  6978. {
  6979. var parentId = _groupRepository.FindParentIdByChildId(provCityDatas, provinceId);
  6980. if (parentId != null)
  6981. {
  6982. isDefualtVal = false;
  6983. provinceId = (int)parentId;
  6984. }
  6985. }
  6986. if (isDefualtVal)
  6987. {
  6988. provinceId = 122; //默认四川
  6989. }
  6990. return new
  6991. {
  6992. x.TeamName,
  6993. x.Id,
  6994. provinceId,
  6995. };
  6996. })
  6997. .ToList();
  6998. return Ok(JsonView(true, "SUCCESS!", new
  6999. {
  7000. dropDownType,
  7001. dropDownGroupList,
  7002. isMarketingDepartment
  7003. }));
  7004. }
  7005. else if (portType == 2 || portType == 3)
  7006. {
  7007. return Ok(JsonView(true, "SUCCESS!", new
  7008. {
  7009. dropDownType,
  7010. isMarketingDepartment
  7011. }));
  7012. }
  7013. else
  7014. {
  7015. return Ok(JsonView(false, "portType有误!"));
  7016. }
  7017. }
  7018. /// <summary>
  7019. /// 共享文件上传
  7020. /// </summary>
  7021. /// <param name="dto"></param>
  7022. /// <returns></returns>
  7023. [HttpPost]
  7024. public IActionResult SharedFileUpload([FromForm] SharedFileUploadDto dto)
  7025. {
  7026. var isGroup = new List<int> { 1412 };
  7027. if (isGroup.Contains(dto.FileType) && dto.Diid < 1)
  7028. {
  7029. return Ok(JsonView(false, "该文件需要关联团组!"));
  7030. }
  7031. if (dto.Files == null || dto.Files.Count == 0)
  7032. {
  7033. return Ok(JsonView(false, "无文件信息!"));
  7034. }
  7035. if (dto.Files.Sum(x => x.Length) > 20 * 1024 * 1024)
  7036. {
  7037. return Ok(JsonView(false, "文件大小超过20M!"));
  7038. }
  7039. if (dto.Userid < 1)
  7040. {
  7041. return Ok(JsonView(false, "请传入有效的Userid!"));
  7042. }
  7043. var jobInfo = _sqlSugar.Queryable<Sys_Users, Sys_JobPost>((u, j) => u.JobPostId == j.Id && j.IsDel == 0)
  7044. .Where(u => u.IsDel == 0 && u.Id == dto.Userid)
  7045. .Select((u, j) => new
  7046. {
  7047. u.CnName,
  7048. UserId = u.Id,
  7049. j.JobName,
  7050. })
  7051. .First();
  7052. if (jobInfo == null)
  7053. {
  7054. return Ok(JsonView(false, "请传入有效的Userid!"));
  7055. }
  7056. var commonFileExtensions = new List<string>
  7057. {
  7058. // 文本文件
  7059. ".txt", ".doc", ".docx", ".odt", ".pdf", ".rtf", ".md", ".log",
  7060. // 图片文件
  7061. ".jpg", ".jpeg", ".png", ".gif", ".bmp", ".tiff", ".svg",
  7062. // 视频文件
  7063. ".mp4", ".avi", ".mov", ".mkv", ".wmv", ".flv", ".mpg", ".mpeg",
  7064. // 音频文件
  7065. ".mp3", ".wav", ".ogg", ".aac", ".flac",
  7066. // 压缩文件
  7067. ".zip", ".rar", ".7z", ".tar", ".gz", ".bz2",
  7068. // 数据文件
  7069. ".csv", ".xls", ".xlsx", ".json", ".xml", ".yaml", ".ini",
  7070. };
  7071. try
  7072. {
  7073. var setting = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1416);
  7074. var settingExtend = JsonConvert.DeserializeObject<List<string>>(setting.Remark);
  7075. commonFileExtensions.AddRange(settingExtend);
  7076. }
  7077. catch (Exception)
  7078. { }
  7079. var setdata = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.FileType);
  7080. if (setdata == null)
  7081. {
  7082. return Ok(JsonView(false, "请传入有效的FileType!"));
  7083. }
  7084. var insertList = new List<Grp_GroupShareFile>();
  7085. string winPath = AppSettingsHelper.Get("ShareFileBasePath") + $"{setdata.Name}/";
  7086. if (!Directory.Exists(winPath))
  7087. {
  7088. Directory.CreateDirectory(winPath);
  7089. }
  7090. foreach (var item in dto.Files)
  7091. {
  7092. var houzui = Path.GetExtension(item.FileName);
  7093. if (!commonFileExtensions.Contains(houzui))
  7094. {
  7095. return Ok(JsonView(false, "未知后缀名称!"));
  7096. }
  7097. var fileName = $"{jobInfo.JobName}-{jobInfo.CnName}-{item.FileName}";
  7098. var saveFilePath = winPath + fileName;
  7099. using (FileStream fs = System.IO.File.Create(saveFilePath))
  7100. {
  7101. item.CopyTo(fs);
  7102. fs.Flush();
  7103. }
  7104. var fileDetail = new Grp_GroupShareFile()
  7105. {
  7106. CreateUserId = dto.Userid,
  7107. CreateTime = DateTime.Now,
  7108. UploadJob = jobInfo.JobName,
  7109. FileName = fileName,
  7110. FileType = dto.FileType,
  7111. Diid = dto.Diid,
  7112. FilePath = winPath + fileName,
  7113. };
  7114. insertList.Add(fileDetail);
  7115. }
  7116. _sqlSugar.Insertable<Grp_GroupShareFile>(insertList).ExecuteCommand();
  7117. return Ok(JsonView(true, "保存成功!"));
  7118. }
  7119. /// <summary>
  7120. /// 查询共享文件列表
  7121. /// </summary>
  7122. /// <param name="dto"></param>
  7123. /// <returns></returns>
  7124. [HttpPost]
  7125. public IActionResult QuerySharedFile(QuerySharedFileDto dto)
  7126. {
  7127. var isGroup = new List<int> { 1412 };
  7128. if (!isGroup.Contains(dto.FileType)) dto.Diid = 0;
  7129. var queryExpression = Expressionable.Create<Grp_GroupShareFile>()
  7130. .And(x => x.Diid == dto.Diid)
  7131. .And(x => x.FileType == dto.FileType)
  7132. .And(x => x.IsDel == 0)
  7133. .AndIF(!dto.FileName.IsNullOrWhiteSpace(), x => x.FileName.Contains(dto.FileName))
  7134. .AndIF(DateTime.TryParse(dto.StartTime, out DateTime Start), x => x.CreateTime >= Start)
  7135. .AndIF(DateTime.TryParse(dto.EndTime, out DateTime End), x => x.CreateTime <= End);
  7136. int totalCount = 0;
  7137. var dbQuery = _sqlSugar.Queryable<Grp_GroupShareFile>()
  7138. .Where(queryExpression.ToExpression())
  7139. .OrderBy(x => x.UploadJob)
  7140. .Select(x => new
  7141. {
  7142. x.Id,
  7143. FilePath = AppSettingsHelper.Get("ShareFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("ShareFileBasePath"), AppSettingsHelper.Get("ShareFileFtpPath")),
  7144. x.FileName,
  7145. x.FileType,
  7146. x.CreateTime,
  7147. })
  7148. .ToPageList(dto.PageIndex, dto.PageSize, ref totalCount);
  7149. return Ok(JsonView(true, "SUCCESS!", new
  7150. {
  7151. FileList = dbQuery,
  7152. dto.PageSize,
  7153. dto.PageIndex,
  7154. totalCount
  7155. }));
  7156. }
  7157. /// <summary>
  7158. /// 删除共享文件模块下的指定文件
  7159. /// </summary>
  7160. /// <param name="dto"></param>
  7161. /// <returns></returns>
  7162. [HttpPost]
  7163. public IActionResult DeleteSharedFile(DeleteGroupFileDto dto)
  7164. {
  7165. var jw = JsonView(false);
  7166. var sing = _sqlSugar.Queryable<Grp_GroupShareFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  7167. if (sing == null)
  7168. {
  7169. jw.Msg = "暂无文件信息!";
  7170. return Ok(jw);
  7171. }
  7172. if (sing.CreateUserId != dto.UserId)
  7173. {
  7174. jw.Msg = "只能删除自己上传的文件!";
  7175. return Ok(jw);
  7176. }
  7177. if (System.IO.File.Exists(sing.FilePath))
  7178. {
  7179. try
  7180. {
  7181. System.IO.File.Delete(sing.FilePath);
  7182. }
  7183. catch (Exception ex)
  7184. {
  7185. jw.Msg = "删除失败!" + ex.Message;
  7186. return Ok(jw);
  7187. }
  7188. }
  7189. sing.IsDel = 1;
  7190. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  7191. sing.DeleteUserId = dto.UserId;
  7192. _sqlSugar.Updateable<Grp_GroupShareFile>(sing).ExecuteCommand();
  7193. jw = JsonView(true, "删除成功!");
  7194. return Ok(jw);
  7195. }
  7196. #endregion
  7197. #region 团组英文资料
  7198. /// <summary>
  7199. /// 查询团组英文所有资料
  7200. /// </summary>
  7201. /// <param name="dto"></param>
  7202. /// <returns></returns>
  7203. [HttpPost]
  7204. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7205. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  7206. {
  7207. try
  7208. {
  7209. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  7210. if (groupData.Code != 0)
  7211. {
  7212. return Ok(JsonView(false, groupData.Msg));
  7213. }
  7214. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  7215. }
  7216. catch (Exception ex)
  7217. {
  7218. return Ok(JsonView(false, ex.Message));
  7219. throw;
  7220. }
  7221. }
  7222. /// <summary>
  7223. /// 团组英文资料操作(Status:1.新增,2.修改)
  7224. /// </summary>
  7225. /// <param name="dto"></param>
  7226. /// <returns></returns>
  7227. [HttpPost]
  7228. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7229. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  7230. {
  7231. try
  7232. {
  7233. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  7234. if (groupData.Code != 0)
  7235. {
  7236. return Ok(JsonView(false, groupData.Msg));
  7237. }
  7238. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  7239. }
  7240. catch (Exception ex)
  7241. {
  7242. return Ok(JsonView(false, ex.Message));
  7243. throw;
  7244. }
  7245. }
  7246. /// <summary>
  7247. /// 团组英文资料Id查询数据
  7248. /// </summary>
  7249. /// <param name="dto"></param>
  7250. /// <returns></returns>
  7251. [HttpPost]
  7252. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7253. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  7254. {
  7255. try
  7256. {
  7257. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  7258. if (_DelegationEnData != null)
  7259. {
  7260. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  7261. }
  7262. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  7263. }
  7264. catch (Exception ex)
  7265. {
  7266. return Ok(JsonView(false, "程序错误!"));
  7267. throw;
  7268. }
  7269. }
  7270. /// <summary>
  7271. /// 团组英文资料删除
  7272. /// </summary>
  7273. /// <param name="dto"></param>
  7274. /// <returns></returns>
  7275. [HttpPost]
  7276. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7277. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  7278. {
  7279. try
  7280. {
  7281. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  7282. if (!res)
  7283. {
  7284. return Ok(JsonView(false, "删除失败"));
  7285. }
  7286. return Ok(JsonView(true, "删除成功!"));
  7287. }
  7288. catch (Exception ex)
  7289. {
  7290. return Ok(JsonView(false, ex.Message));
  7291. throw;
  7292. }
  7293. }
  7294. #endregion
  7295. #region 导出邀请函
  7296. /// <summary>
  7297. /// 导出邀请函页面初始化
  7298. /// </summary>
  7299. /// <param name="dto"></param>
  7300. /// <returns></returns>
  7301. [HttpPost]
  7302. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7303. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  7304. {
  7305. try
  7306. {
  7307. var grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.VisitStartDate, OrderByType.Desc).ToList();
  7308. var crm_Deles = new List<Crm_DeleClient>();
  7309. if (dto.DiId == 0)
  7310. {
  7311. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  7312. }
  7313. else
  7314. {
  7315. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  7316. }
  7317. return Ok(JsonView(true, "查询成功!", new
  7318. {
  7319. deleClient = crm_Deles,
  7320. delegations = grp_Delegations
  7321. }));
  7322. }
  7323. catch (Exception ex)
  7324. {
  7325. return Ok(JsonView(false, "程序错误!"));
  7326. throw;
  7327. }
  7328. }
  7329. /// <summary>
  7330. /// 导出邀请函
  7331. /// </summary>
  7332. /// <param name="dto"></param>
  7333. /// <returns></returns>
  7334. [HttpPost]
  7335. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7336. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  7337. {
  7338. #region 参数验证
  7339. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  7340. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  7341. #endregion
  7342. try
  7343. {
  7344. var transDic = new Dictionary<string, string>();
  7345. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  7346. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  7347. From Grp_TourClientList tcl
  7348. Left Join
  7349. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  7350. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  7351. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  7352. From Crm_DeleClient dc
  7353. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  7354. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  7355. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  7356. Where dc.IsDel = 0) temp
  7357. On temp.DcId =tcl.ClientId
  7358. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  7359. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  7360. var texts = new List<string>();
  7361. if (datas.Count != 0)
  7362. {
  7363. foreach (TourClientListDetailsView item in datas)
  7364. {
  7365. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  7366. {
  7367. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  7368. }
  7369. else
  7370. {
  7371. string name = item.LastName + item.FirstName;
  7372. texts.Add(name);
  7373. }
  7374. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  7375. {
  7376. if (!transDic.ContainsKey(item.Job))
  7377. {
  7378. texts.Add(item.Job);
  7379. }
  7380. }
  7381. if (!string.IsNullOrEmpty(item.CompanyFullName))
  7382. {
  7383. texts.Add(item.CompanyFullName);
  7384. }
  7385. }
  7386. var transData = await _airTicketResRep.ReTransBatch(texts, "en");
  7387. if (transData.Count > 0)
  7388. {
  7389. foreach (TranslateResult item in transData)
  7390. {
  7391. if (!transDic.ContainsKey(item.Query))
  7392. {
  7393. transDic.Add(item.Query, item.Translation);
  7394. }
  7395. }
  7396. }
  7397. var list = new List<GuestList>();
  7398. foreach (var dele in datas)
  7399. {
  7400. var guestList = new GuestList();
  7401. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  7402. {
  7403. guestList.Name = dele.Pinyin;
  7404. }
  7405. else
  7406. {
  7407. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  7408. guestList.Name = Name;
  7409. }
  7410. if (dele.Sex == 0)
  7411. {
  7412. guestList.Sex = "Male";
  7413. }
  7414. else if (dele.Sex == 1)
  7415. {
  7416. guestList.Sex = "Female";
  7417. }
  7418. guestList.DOB = dele.BirthDay.Replace('-', '.');
  7419. if (!string.IsNullOrEmpty(dele.Job))
  7420. {
  7421. guestList.Job = dele.Job;
  7422. }
  7423. list.Add(guestList);
  7424. }
  7425. //载入模板
  7426. var doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  7427. var builder = new DocumentBuilder(doc);
  7428. //获取word里所有表格
  7429. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7430. //获取所填表格的序数
  7431. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  7432. var rowStart = tableOne.Rows[0]; //获取第1行
  7433. //循环赋值
  7434. for (int i = 0; i < list.Count; i++)
  7435. {
  7436. builder.MoveToCell(0, i + 1, 0, 0);
  7437. builder.Write(list[i].Name.ToString());
  7438. builder.MoveToCell(0, i + 1, 1, 0);
  7439. builder.Write(list[i].Sex.ToString());
  7440. builder.MoveToCell(0, i + 1, 2, 0);
  7441. builder.Write(list[i].DOB.ToString());
  7442. builder.MoveToCell(0, i + 1, 3, 0);
  7443. builder.Write(list[i].Job.ToString());
  7444. }
  7445. //删除多余行
  7446. while (tableOne.Rows.Count > list.Count + 1)
  7447. {
  7448. tableOne.Rows.RemoveAt(list.Count + 1);
  7449. }
  7450. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  7451. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  7452. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  7453. doc.Save(filePath);
  7454. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  7455. return Ok(JsonView(true, "操作成功!", Url));
  7456. }
  7457. else
  7458. {
  7459. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  7460. }
  7461. }
  7462. catch (Exception ex)
  7463. {
  7464. return Ok(JsonView(false, ex.Message));
  7465. throw;
  7466. }
  7467. }
  7468. #endregion
  7469. #region 团组经理模块 出入境费用
  7470. /// <summary>
  7471. /// 团组模块 - 出入境费用 - 省份基础数据源
  7472. /// </summary>
  7473. /// <returns></returns>
  7474. [HttpGet]
  7475. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7476. public async Task<IActionResult> GetEnterExitProvBelongCostDataSource()
  7477. {
  7478. return Ok(JsonView(await _groupRepository.ProvinceBasicSource()));
  7479. }
  7480. /// <summary>
  7481. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  7482. /// </summary>
  7483. /// <param name="dto"></param>
  7484. /// <returns></returns>
  7485. [HttpPost]
  7486. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7487. public async Task<IActionResult> GetEnterExitCostDataSource(EnterExitCostDataSourceDto dto)
  7488. {
  7489. var groupNameData = await _groupRepository.EnterExitCostGroupNameAsync();
  7490. var groupNamFirst = groupNameData.FirstOrDefault();
  7491. //SetDataInfoView
  7492. var dataSource = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  7493. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  7494. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  7495. //验证城市归属并给默认值
  7496. int provinceId = 122;
  7497. if (groupNamFirst != null) provinceId = groupNamFirst.ProvinceId;
  7498. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostRep.FileOwner(provinceId);
  7499. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  7500. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  7501. return Ok(JsonView(true, "查询成功!", new
  7502. {
  7503. GroupNameData = groupNameData,
  7504. CurrencyData = _CurrencyData,
  7505. WordTypeData = wordTypeData,
  7506. ExcelTypeData = excelTypeData,
  7507. CurrencyInit = _currencyInfos,
  7508. ViewPermissionData = viewPermissionData
  7509. }));
  7510. }
  7511. /// <summary>
  7512. /// 团组模块 - 出入境费用 - 文件类型list 跟据省份Id获取
  7513. /// </summary>
  7514. /// <returns></returns>
  7515. [HttpGet("{provinceId}")]
  7516. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7517. public async Task<IActionResult> EnterExitCostFileOwner([FromRoute] int provinceId = 122)
  7518. {
  7519. //验证城市归属并给默认值
  7520. if (provinceId < 1) provinceId = 122;
  7521. /*
  7522. * 122 四川
  7523. * 108 贵州
  7524. * 103 重庆
  7525. * 132 云南
  7526. */
  7527. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostDraftRep.FileOwner(provinceId);
  7528. return Ok(JsonView(true, "查询成功!", new
  7529. {
  7530. WordTypeData = wordTypeData,
  7531. ExcelTypeData = excelTypeData,
  7532. }));
  7533. }
  7534. /// <summary>
  7535. /// 团组模块 - 出入境费用
  7536. /// 实时汇率 tips
  7537. /// 签证费用 tips
  7538. /// 机票费用 tips
  7539. /// </summary>
  7540. /// <returns></returns>
  7541. [HttpPost]
  7542. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7543. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  7544. {
  7545. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  7546. //默认币种显示
  7547. var reteInfos = await GeneralMethod.EnterExitCostLiveRate();
  7548. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.DiId);
  7549. var airData = await GeneralMethod.EntryAndExitTips(dto.DiId);
  7550. return Ok(JsonView(true, "查询成功!", new
  7551. {
  7552. //GroupNameData = groupNameData.Data,
  7553. visaData = visaData.Data,
  7554. airData,
  7555. reteInfos
  7556. }));
  7557. }
  7558. /// <summary>
  7559. /// 团组模块 - 出入境费用 - Info
  7560. /// </summary>
  7561. /// <param name="dto"></param>
  7562. /// <returns></returns>
  7563. [HttpPost]
  7564. //[ApiLog("Grp_EnterExitCost", OperationEnum.Details)]
  7565. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7566. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  7567. {
  7568. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7569. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7570. return Ok(await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto));
  7571. }
  7572. /// <summary>
  7573. /// 团组模块 - 出入境费用 - 设置view权限
  7574. /// </summary>
  7575. /// <returns></returns>
  7576. [HttpPost]
  7577. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7578. public async Task<IActionResult> EnterExitCostSetViewPermissiion(EnterExitCostSetViewPermissiionDto dto)
  7579. {
  7580. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7581. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7582. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  7583. var permissions = new List<Grp_EnterExitCostPermission>();
  7584. foreach (var userId in dto.UserIds)
  7585. {
  7586. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.GroupId, UserId = userId, CreateUserId = dto.CurrUserId });
  7587. }
  7588. if (permissions.Any())
  7589. {
  7590. _sqlSugar.BeginTran();
  7591. try
  7592. {
  7593. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.GroupId).ExecuteCommandAsync();
  7594. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  7595. if (result < 1)
  7596. {
  7597. _sqlSugar.RollbackTran();
  7598. return Ok(JsonView(false));
  7599. }
  7600. }
  7601. catch (Exception ex)
  7602. {
  7603. _sqlSugar.RollbackTran();
  7604. return Ok(JsonView(false, ex.Message));
  7605. }
  7606. _sqlSugar.CommitTran();
  7607. return Ok(JsonView(true));
  7608. }
  7609. return Ok(JsonView(false));
  7610. }
  7611. /// <summary>
  7612. /// 团组模块 - 出入境费用 - Add And Update
  7613. /// </summary>
  7614. /// <returns></returns>
  7615. [HttpPost]
  7616. [ApiLog("Grp_EnterExitCost", OperationEnum.Add)]
  7617. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7618. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  7619. {
  7620. try
  7621. {
  7622. var rateRecords = new List<RateRecordInfo>();
  7623. #region 汇率保存前存储
  7624. var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(x => x.IsDel == 0 && x.DiId == dto.DiId);
  7625. if (info != null)
  7626. {
  7627. var cacheRateInfos = CommonFun.GetCurrencyChinaToList(info.CurrencyRemark);
  7628. if (cacheRateInfos != null && cacheRateInfos.Count > 0)
  7629. {
  7630. rateRecords = cacheRateInfos.Select(x => new RateRecordInfo()
  7631. {
  7632. CurrencyCode = x.CurrencyCode,
  7633. CurrencyName = x.CurrencyName,
  7634. UpdatePreRate = x.Rate,
  7635. UpdateBreRate = dto.Currencys.Where(x1 => x1.CurrencyName.Equals(x.CurrencyName)).FirstOrDefault()?.Rate ?? 0.00M
  7636. }).ToList();
  7637. }
  7638. else
  7639. {
  7640. rateRecords = dto.Currencys.Select(x => new RateRecordInfo()
  7641. {
  7642. CurrencyCode = x.CurrencyCode,
  7643. CurrencyName = x.CurrencyName,
  7644. UpdatePreRate = 0.00M,
  7645. UpdateBreRate = x.Rate
  7646. }).ToList();
  7647. }
  7648. }
  7649. else
  7650. {
  7651. rateRecords = dto.Currencys.Select(x => new RateRecordInfo()
  7652. {
  7653. CurrencyCode = x.CurrencyCode,
  7654. CurrencyName = x.CurrencyName,
  7655. UpdatePreRate = 0.00M,
  7656. UpdateBreRate = x.Rate
  7657. }).ToList();
  7658. }
  7659. #endregion
  7660. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  7661. if (dto.DayOtherPriceData.Any())
  7662. {
  7663. var inserList = dto.DayOtherPriceData
  7664. .Where(x => x.Id == 0)
  7665. .Select(x => new Grp_DayOtherPrice
  7666. {
  7667. Cost = x.Cost,
  7668. Id = x.Id,
  7669. CreateTime = DateTime.Now,
  7670. CreateUserId = dto.UserId,
  7671. Currency = x.Currency,
  7672. Diid = x.DiId,
  7673. Index = x.Index,
  7674. IsDel = 0,
  7675. SetDataId = x.SetDataId,
  7676. SubTotal = x.SubTotal,
  7677. Remark = x.Remark
  7678. })
  7679. .ToList();
  7680. var updateList = dto.DayOtherPriceData
  7681. .Where(x => x.Id != 0)
  7682. .Select(x => new Grp_DayOtherPrice
  7683. {
  7684. Cost = x.Cost,
  7685. Id = x.Id,
  7686. CreateTime = DateTime.Now,
  7687. CreateUserId = dto.UserId,
  7688. Currency = x.Currency,
  7689. Diid = x.DiId,
  7690. Index = x.Index,
  7691. IsDel = 0,
  7692. SetDataId = x.SetDataId,
  7693. SubTotal = x.SubTotal,
  7694. Remark = x.Remark
  7695. })
  7696. .ToList();
  7697. //添加
  7698. _sqlSugar.BeginTran();
  7699. if (inserList.Any())
  7700. {
  7701. var rowCount = _sqlSugar.Insertable<Grp_DayOtherPrice>(inserList).ExecuteCommand();
  7702. }
  7703. if (updateList.Any())
  7704. {
  7705. var rowCount = _sqlSugar.Updateable<Grp_DayOtherPrice>(updateList).ExecuteCommand();
  7706. }
  7707. _sqlSugar.CommitTran();
  7708. }
  7709. if (data.Code != 0)
  7710. {
  7711. return Ok(JsonView(false, data.Msg));
  7712. }
  7713. //生成默认文件pdf并且通知人员
  7714. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  7715. {
  7716. DiId = dto.DiId,
  7717. ExportType = 1,
  7718. SubTypeId = 1005
  7719. }, "pdf");
  7720. //发送通知
  7721. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  7722. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  7723. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  7724. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign, fileUrl);
  7725. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  7726. //汇率信息记录
  7727. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  7728. var checkCurrencys = await _enterExitCostRep.GetCheckCurrencies(dto.DiId);
  7729. //汇率验证、反推
  7730. (bool isSendMsg, string msgContent, List<CurrencyInfo> liveRates) = await GeneralMethod.EnterExitCostCheckRate(dto.DiId, checkCurrencys);
  7731. if (isSendMsg)
  7732. {
  7733. //消息推送
  7734. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFin(dto.DiId, dto.UserId, msgContent);
  7735. }
  7736. #region 日志汇率记录
  7737. //按照已使用币种记录
  7738. if (checkCurrencys != null && checkCurrencys.Count > 0)
  7739. {
  7740. rateRecords = rateRecords.Where(x => checkCurrencys.Select(x1 => x1.CurrencyName).ToList().Contains(x.CurrencyName)).ToList();
  7741. //汇率记录中加入实时汇率
  7742. if (liveRates != null && liveRates.Count > 0)
  7743. {
  7744. foreach (var item in rateRecords)
  7745. {
  7746. item.CurrLiveRate = liveRates.Where(x => x.CurrencyName.Equals(item.CurrencyName)).FirstOrDefault()?.Rate ?? 0.00M;
  7747. }
  7748. }
  7749. var teamName = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.Id == dto.DiId && x.IsDel == 0).Select(x => x.TeamName).FirstAsync();
  7750. var operationName = await _sqlSugar.Queryable<Sys_Users>().Where(x => x.Id == dto.UserId && x.IsDel == 0).Select(x => x.CnName).FirstAsync();
  7751. var logContent = new StringBuilder();
  7752. foreach (var item in rateRecords)
  7753. {
  7754. var blRate = (item.CurrLiveRate * 1.0350M).TruncDecimals(4);
  7755. string msg = $">- {item.CurrencyName}汇率:(页面保存前){item.UpdatePreRate:#0.0000}/(页面保存){item.UpdateBreRate:#0.0000}/实时汇率(已上浮1.0350):{blRate:#0.0000}【注:原接口输出汇率为:{item.CurrLiveRate:#0.0000}】";
  7756. logContent.AppendLine(msg);
  7757. }
  7758. _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());
  7759. }
  7760. #endregion
  7761. return Ok(JsonView(true, data.Msg, data.Data));
  7762. }
  7763. catch (Exception ex)
  7764. {
  7765. return Ok(JsonView(false, ex.Message));
  7766. }
  7767. }
  7768. /// <summary>
  7769. /// 团组模块 - 出入境费用 - Confirm 费用
  7770. /// </summary>
  7771. /// <returns></returns>
  7772. [HttpPost]
  7773. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7774. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  7775. {
  7776. //TODO:测试完毕需把对应的用户ID更改
  7777. //1、数据表添加字段
  7778. //2、更改字段接口()
  7779. var _view = await _enterExitCostRep.ConfirmCost(dto);
  7780. //3、确认成功 给财务发送消息
  7781. if (_view.Code == 200)
  7782. {
  7783. if (dto.Type == 1)
  7784. {
  7785. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  7786. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  7787. }
  7788. }
  7789. return Ok(_view);
  7790. }
  7791. /// <summary>
  7792. /// 团组模块 - 出入境费用 - File download
  7793. /// </summary>
  7794. /// <param name="dto"></param>
  7795. /// <returns></returns>
  7796. [HttpPost]
  7797. //[ApiLog("Grp_EnterExitCost", OperationEnum.Download)]
  7798. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7799. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  7800. {
  7801. try
  7802. {
  7803. if (dto.DiId < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  7804. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  7805. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  7806. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  7807. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  7808. 3 团组成员名单 1 团组成员名单", ""));
  7809. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).OrderByDescending(x => x.CreateTime).First();
  7810. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  7811. if (_EnterExitCosts == null) return Ok(JsonView(400, "该团组未填写出入境费用;", ""));
  7812. var currencyInit = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToList();
  7813. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  7814. //数据源
  7815. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  7816. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  7817. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  7818. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  7819. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  7820. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  7821. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  7822. .Where((x, a, b) => x.IsDel == 0 && x.Diid == dto.DiId)
  7823. .Select((x, a, b) => new
  7824. {
  7825. x.Index,
  7826. itemName = a.Name,
  7827. CurrencyStr = b.Name,
  7828. x.Cost,
  7829. x.SubTotal,
  7830. x.Remark
  7831. })
  7832. .OrderBy((x) => x.Index)
  7833. .ToList(); //其他款项费用
  7834. var peiceItemCurrencys = new List<string>();
  7835. if (_DayAndCosts.Any())
  7836. {
  7837. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  7838. if (currencyIds.Any()) peiceItemCurrencys.AddRange(currencyInit.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  7839. }
  7840. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  7841. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  7842. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  7843. {
  7844. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  7845. }
  7846. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  7847. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  7848. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  7849. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  7850. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  7851. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  7852. .Select((tcl, dc, cc) => new ClientInfo
  7853. {
  7854. LastName = dc.LastName,
  7855. FirstName = dc.FirstName,
  7856. Sex = dc.Sex,
  7857. Birthday = dc.BirthDay,
  7858. Company = cc.CompanyFullName,
  7859. Job = dc.Job
  7860. })
  7861. .ToList();
  7862. foreach (var item in DeleClientList)
  7863. {
  7864. EncryptionProcessor.DecryptProperties(item);
  7865. }
  7866. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  7867. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  7868. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  7869. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  7870. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  7871. if (dto.ExportType == 1) //明细表
  7872. {
  7873. if (dto.SubTypeId == 1005) //1005(默认明细表)
  7874. {
  7875. //获取模板
  7876. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  7877. //载入模板
  7878. var doc = new Document(tempPath);
  7879. var builder = new DocumentBuilder(doc);
  7880. var dic = new Dictionary<string, string>();
  7881. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  7882. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  7883. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  7884. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  7885. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  7886. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  7887. //境内费用(其他费用)
  7888. if (_EnterExitCosts.ChoiceOne == 1)
  7889. {
  7890. string row1_1 = "";
  7891. if (_EnterExitCosts.Visa > 0)
  7892. {
  7893. //insidePayTotal += _EnterExitCosts.Visa;
  7894. row1_1 = $"签证费:{_EnterExitCosts.Visa:#0.00} 元/人";
  7895. //if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  7896. //{
  7897. // row1_1 += $"\t签证费用描述: {_EnterExitCosts.VisaRemark} 人民币/人";
  7898. //}
  7899. }
  7900. string row1_2 = "";
  7901. if (_EnterExitCosts.YiMiao > 0)
  7902. {
  7903. //insidePayTotal += _EnterExitCosts.YiMiao;
  7904. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00} 元/人";
  7905. }
  7906. if (_EnterExitCosts.HeSuan > 0)
  7907. {
  7908. //insidePayTotal += _EnterExitCosts.HeSuan;
  7909. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan:#0.00} 元/人";
  7910. }
  7911. if (_EnterExitCosts.Service > 0)
  7912. {
  7913. //insidePayTotal += _EnterExitCosts.Service;
  7914. row1_2 += $"服务费:{_EnterExitCosts.Service:#0.00} 元/人";
  7915. }
  7916. string row1_3 = "";
  7917. if (_EnterExitCosts.Safe > 0)
  7918. {
  7919. //insidePayTotal += _EnterExitCosts.Safe;
  7920. row1_3 += $"保险费:{_EnterExitCosts.Safe:#0.00} 元/人";
  7921. }
  7922. if (_EnterExitCosts.Ticket > 0)
  7923. {
  7924. //insidePayTotal += _EnterExitCosts.Ticket;
  7925. row1_3 += $"参展门票:{_EnterExitCosts.Ticket:#0.00} 元/人";
  7926. }
  7927. string row1 = "";
  7928. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  7929. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  7930. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  7931. row1 += $"备注:{_EnterExitCosts.Remark}";
  7932. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  7933. dic.Add("Row1Str", row1);
  7934. }
  7935. var airTotalStr = new StringBuilder();
  7936. var airPriceStr = new StringBuilder();
  7937. var cityTrafficLabel = new StringBuilder();
  7938. //经济舱
  7939. if (_EnterExitCosts.SumJJC == 1)
  7940. {
  7941. airTotalStr.AppendFormat($"{_EnterExitCosts.OutsideJJPay:#0.00}元/人(经济舱)");
  7942. airPriceStr.AppendFormat($"{_EnterExitCosts.AirJJ:#0.00}元/人(经济舱)");
  7943. cityTrafficLabel.AppendFormat("经济舱:{0:#0.00} 元/人 ", _EnterExitCosts.CityTranffic);
  7944. }
  7945. //公务舱
  7946. if (_EnterExitCosts.SumGWC == 1)
  7947. {
  7948. airTotalStr.AppendFormat($"{_EnterExitCosts.OutsideGWPay:#0.00} 元/人(公务舱)");
  7949. airPriceStr.AppendFormat($"{_EnterExitCosts.AirGW:#0.00} 元/人(公务舱)");
  7950. cityTrafficLabel.AppendFormat("公务舱:{0:#0.00} 元/人 ", _EnterExitCosts.CityTranffic1);
  7951. }
  7952. //头等舱
  7953. if (_EnterExitCosts.SumTDC == 1)
  7954. {
  7955. airTotalStr.AppendFormat($"{_EnterExitCosts.OutsideTDPay:#0.00} 元/人(头等舱)");
  7956. airPriceStr.AppendFormat($"{_EnterExitCosts.AirTD:#0.00} 元/人(头等舱)");
  7957. cityTrafficLabel.AppendFormat("头等舱:{0:#0.00} 元/人 ", _EnterExitCosts.CityTranffic2);
  7958. }
  7959. //描述
  7960. var remarkLable = new StringBuilder();
  7961. //第二项描述
  7962. remarkLable.Append("备注:");
  7963. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) remarkLable.AppendFormat(_EnterExitCosts.TwoItemRemark);
  7964. //汇率描述
  7965. if (peiceItemCurrencyInfos.Any())
  7966. {
  7967. remarkLable.AppendLine();
  7968. remarkLable.AppendFormat("汇率描述:");
  7969. foreach (var item in peiceItemCurrencyInfos)
  7970. {
  7971. remarkLable.AppendFormat($"{item.CurrencyName}({item.CurrencyCode}):{item.Rate:#0.0000} ");
  7972. }
  7973. }
  7974. dic.Add("AirTotalStr", airTotalStr.ToString());
  7975. dic.Add("AirPriceStr", airPriceStr.ToString());
  7976. dic.Add("CityTranffic", cityTrafficLabel.ToString());
  7977. dic.Add("TwoItemRemark", remarkLable.ToString());
  7978. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7979. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7980. int table1Row = 0,
  7981. table2Row = 0,
  7982. table3Row = 0,
  7983. table4Row = 0,
  7984. table5Row = 0;
  7985. //住宿费
  7986. if (_EnterExitCosts.ChoiceThree == 1)
  7987. {
  7988. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  7989. table1Row = dac1.Count;
  7990. #region 填充word表格内容
  7991. for (int i = 0; i < dac1.Count; i++)
  7992. {
  7993. Grp_DayAndCost dac = dac1[i];
  7994. if (dac == null) continue;
  7995. builder.MoveToCell(0, i, 0, 0);
  7996. builder.Write("第" + dac.Days.ToString() + "晚:");
  7997. builder.MoveToCell(0, i, 1, 0);
  7998. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  7999. //builder.Write(dac.Place == null ? "" : dac.Place);
  8000. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  8001. builder.MoveToCell(0, i, 2, 0);
  8002. builder.Write("费用标准:");
  8003. string curr = "";
  8004. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8005. if (currData != null)
  8006. {
  8007. curr = currData.Name;
  8008. }
  8009. builder.MoveToCell(0, i, 3, 0);
  8010. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8011. builder.MoveToCell(0, i, 4, 0);
  8012. builder.Write("费用小计:");
  8013. builder.MoveToCell(0, i, 5, 0);
  8014. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8015. }
  8016. #endregion
  8017. }
  8018. else dic.Add("SubZS", "0.00");
  8019. //删除多余行
  8020. while (table1.Rows.Count > table1Row)
  8021. {
  8022. table1.Rows.RemoveAt(table1Row);
  8023. }
  8024. //伙食费
  8025. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  8026. if (_EnterExitCosts.ChoiceFour == 1)
  8027. {
  8028. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  8029. table2Row = dac2.Count;
  8030. #region 填充word表格内容
  8031. for (int i = 0; i < dac2.Count; i++)
  8032. {
  8033. Grp_DayAndCost dac = dac2[i];
  8034. if (dac == null) continue;
  8035. builder.MoveToCell(1, i, 0, 0);
  8036. builder.Write("第" + dac.Days.ToString() + "天:");
  8037. builder.MoveToCell(1, i, 1, 0);
  8038. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  8039. builder.MoveToCell(1, i, 2, 0);
  8040. builder.Write("费用标准:");
  8041. string curr = "";
  8042. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8043. if (currData != null)
  8044. {
  8045. curr = currData.Name;
  8046. }
  8047. builder.MoveToCell(1, i, 3, 0);
  8048. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8049. builder.MoveToCell(1, i, 4, 0);
  8050. builder.Write("费用小计:");
  8051. builder.MoveToCell(1, i, 5, 0);
  8052. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8053. }
  8054. #endregion
  8055. }
  8056. else dic.Add("SubHS", "0.00");
  8057. //删除多余行
  8058. while (table2.Rows.Count > table2Row)
  8059. {
  8060. table2.Rows.RemoveAt(table2Row);
  8061. }
  8062. //公杂费
  8063. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  8064. if (_EnterExitCosts.ChoiceFive == 1)
  8065. {
  8066. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  8067. table3Row = dac3.Count;
  8068. #region 填充word表格内容
  8069. for (int i = 0; i < dac3.Count; i++)
  8070. {
  8071. Grp_DayAndCost dac = dac3[i];
  8072. if (dac == null) continue;
  8073. builder.MoveToCell(2, i, 0, 0);
  8074. builder.Write("第" + dac.Days.ToString() + "天:");
  8075. builder.MoveToCell(2, i, 1, 0);
  8076. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  8077. builder.MoveToCell(2, i, 2, 0);
  8078. builder.Write("费用标准:");
  8079. string curr = "";
  8080. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8081. if (currData != null)
  8082. {
  8083. curr = currData.Name;
  8084. }
  8085. builder.MoveToCell(2, i, 3, 0);
  8086. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8087. builder.MoveToCell(2, i, 4, 0);
  8088. builder.Write("费用小计:");
  8089. builder.MoveToCell(2, i, 5, 0);
  8090. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8091. }
  8092. //删除多余行
  8093. while (table3.Rows.Count > table3Row)
  8094. {
  8095. table3.Rows.RemoveAt(table3Row);
  8096. }
  8097. #endregion
  8098. }
  8099. else dic.Add("SubGZF", "0.00");
  8100. //删除多余行
  8101. while (table3.Rows.Count > table3Row)
  8102. {
  8103. table3.Rows.RemoveAt(table3Row);
  8104. }
  8105. //培训费
  8106. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  8107. if (_EnterExitCosts.ChoiceSix == 1)
  8108. {
  8109. string pxStr = $"六、培训费合计: {tainFeeTotal:#0.00} 元/人";
  8110. dic.Add("SubPX", pxStr);
  8111. table4Row = dac4.Count;
  8112. #region 填充word表格内容
  8113. for (int i = 0; i < dac4.Count; i++)
  8114. {
  8115. Grp_DayAndCost dac = dac4[i];
  8116. if (dac == null) continue;
  8117. builder.MoveToCell(3, i, 0, 0);
  8118. builder.Write("第" + dac.Days.ToString() + "天:");
  8119. builder.MoveToCell(3, i, 1, 0);
  8120. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  8121. builder.MoveToCell(3, i, 2, 0);
  8122. builder.Write("费用标准:");
  8123. string curr = "";
  8124. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8125. if (currData != null)
  8126. {
  8127. curr = currData.Name;
  8128. }
  8129. builder.MoveToCell(3, i, 3, 0);
  8130. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8131. builder.MoveToCell(3, i, 4, 0);
  8132. builder.Write("费用小计:");
  8133. builder.MoveToCell(3, i, 5, 0);
  8134. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8135. }
  8136. #endregion
  8137. }
  8138. //else dic.Add("SubPX", $"六、培训费合计: 0.00 元/人");
  8139. //删除多余行
  8140. while (table4.Rows.Count > table4Row)
  8141. {
  8142. table4.Rows.RemoveAt(table4Row);
  8143. }
  8144. //其他费用
  8145. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  8146. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  8147. {
  8148. string qtStr = $"七、其他费用合计: {otherPriceTotal:#0.00} 元/人";
  8149. dic.Add("titleQi", qtStr);
  8150. table5Row = dac5.Count;
  8151. #region 填充word表格内容
  8152. for (int i = 0; i < dac5.Count; i++)
  8153. {
  8154. var dac = dac5[i];
  8155. if (dac == null) continue;
  8156. builder.MoveToCell(4, i, 0, 0);
  8157. builder.Write("第" + dac.Index.ToString() + "项:");
  8158. builder.MoveToCell(4, i, 1, 0);
  8159. builder.Write(dac.itemName);
  8160. builder.MoveToCell(4, i, 2, 0);
  8161. builder.Write("费用标准:");
  8162. builder.MoveToCell(4, i, 3, 0);
  8163. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  8164. builder.MoveToCell(4, i, 4, 0);
  8165. builder.Write("费用小计:");
  8166. builder.MoveToCell(4, i, 5, 0);
  8167. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8168. builder.MoveToCell(4, i, 6, 0);
  8169. builder.Write("备注:");
  8170. builder.MoveToCell(4, i, 7, 0);
  8171. builder.Write(dac.Remark);
  8172. }
  8173. #endregion
  8174. }
  8175. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  8176. //删除多余行
  8177. while (table5.Rows.Count > table5Row)
  8178. {
  8179. table5.Rows.RemoveAt(table5Row);
  8180. }
  8181. //加上其他费用
  8182. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  8183. decimal subJJC = 0.00M,
  8184. subGWC = 0.00M,
  8185. subTDC = 0.00M;
  8186. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  8187. string totalLabel = string.Format("全部费用总计:");
  8188. //经济舱
  8189. if (_EnterExitCosts.SumJJC == 1)
  8190. {
  8191. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  8192. totalLabel += $"{subJJC:#0.00} 元/人(经济舱)";
  8193. }
  8194. //公务舱
  8195. if (_EnterExitCosts.SumGWC == 1)
  8196. {
  8197. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  8198. totalLabel += $"{subGWC:#0.00} 元/人(公务舱)";
  8199. }
  8200. //头等舱
  8201. if (_EnterExitCosts.SumTDC == 1)
  8202. {
  8203. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  8204. totalLabel += $"{subTDC:#0.00} 元/人(头等舱)";
  8205. }
  8206. //TotalLabel
  8207. dic.Add("TotalLabel", totalLabel);
  8208. //dic.Add("SubJJC", subJJC.ToString("#0.00"));
  8209. //dic.Add("SubGWC", subGWC.ToString("#0.00"));
  8210. //dic.Add("SubTDC", subTDC.ToString("#0.00"));
  8211. #region 填充word模板书签内容
  8212. foreach (var key in dic.Keys)
  8213. {
  8214. Bookmark bookmark = doc.Range.Bookmarks[key];
  8215. if (bookmark != null)
  8216. {
  8217. builder.MoveToBookmark(key);
  8218. builder.Write(dic[key]);
  8219. }
  8220. }
  8221. #endregion
  8222. #region 设置页眉
  8223. string userLabel = string.Empty;
  8224. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  8225. if (currUserInfo != null)
  8226. {
  8227. var userInfo = await _usersRep.GetUserBriefInfo(currUserInfo.UserId);
  8228. if (userInfo != null)
  8229. {
  8230. string ext = string.IsNullOrEmpty(userInfo.ExtensionNumber) ? "-" : userInfo.ExtensionNumber;
  8231. //userLabel = $"联系人:{userInfo.Name} 职位:{userInfo.Job}\r\n座机/分机号:{ext} 手机号:{userInfo.Tel} 公司邮箱:{userInfo.Email}";
  8232. userLabel = $"联系人:{userInfo.Name} 职 位:{userInfo.Job} 手机号:{userInfo.Tel}\r\n公司邮箱:{userInfo.Email}";
  8233. }
  8234. }
  8235. //设置页脚
  8236. //GeneralMethod.AsposeWordSetFooter(builder, userLabel, "华文仿宋", 10);
  8237. #endregion
  8238. var guid = CommonFun.GUID.Substring(0, 8);
  8239. //文件名
  8240. string strFileName = CommonFun.ValidFileName($"{_DelegationInfo.TeamName}出入境费用{guid}.docx");
  8241. AsposeHelper.removewatermark_v2180();
  8242. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8243. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8244. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8245. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8246. }
  8247. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  8248. {
  8249. //获取模板
  8250. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  8251. //载入模板
  8252. var doc = new Document(tempPath);
  8253. var builder = new DocumentBuilder(doc);
  8254. var dic = new Dictionary<string, string>();
  8255. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  8256. {
  8257. var list = new List<string>();
  8258. try
  8259. {
  8260. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  8261. foreach (var item in spilitArr)
  8262. {
  8263. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  8264. var depCode = spDotandEmpty[2].Substring(0, 3);
  8265. var arrCode = spDotandEmpty[2].Substring(3, 3);
  8266. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  8267. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  8268. list.Add(depName);
  8269. list.Add(arrName);
  8270. }
  8271. list = list.Distinct().ToList();
  8272. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  8273. }
  8274. catch (Exception)
  8275. {
  8276. dic.Add("ReturnCode", "行程录入不正确!");
  8277. }
  8278. }
  8279. else
  8280. {
  8281. dic.Add("ReturnCode", "未录入行程!");
  8282. }
  8283. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  8284. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  8285. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  8286. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  8287. {
  8288. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  8289. dic.Add("Day", sp.Days.ToString());
  8290. }
  8291. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  8292. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  8293. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  8294. //dic.Add("Names", Names);
  8295. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8296. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  8297. decimal dac1totalPrice = 0.00M;
  8298. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  8299. foreach (var dac in dac1)
  8300. {
  8301. if (dac.SubTotal == 0.00M)
  8302. {
  8303. continue;
  8304. }
  8305. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  8306. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  8307. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  8308. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  8309. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  8310. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  8311. builder.Write(currency);//币种
  8312. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  8313. builder.Write(dac.Cost.ToString("#0.00"));//标准
  8314. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  8315. builder.Write("");//人数
  8316. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  8317. builder.Write("");//天数
  8318. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  8319. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  8320. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  8321. decimal rate = 0.00M;
  8322. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  8323. builder.Write(rate.ToString("#0.0000"));//汇率
  8324. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  8325. decimal rbmPrice = dac.SubTotal;
  8326. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  8327. accommodationStartIndex++;
  8328. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  8329. }
  8330. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  8331. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  8332. {
  8333. table1.Rows.RemoveAt(i - 1);
  8334. foodandotherStartIndex--;
  8335. }
  8336. if (dac2.Count == dac3.Count)//国家 币种 金额
  8337. {
  8338. for (int i = 0; i < dac2.Count; i++)
  8339. {
  8340. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  8341. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  8342. }
  8343. }
  8344. decimal dac2totalPrice = 0.00M;
  8345. foreach (var dac in dac2)
  8346. {
  8347. if (dac.SubTotal == 0)
  8348. {
  8349. continue;
  8350. }
  8351. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  8352. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  8353. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  8354. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  8355. builder.Write(currency);//币种
  8356. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  8357. builder.Write(dac.Cost.ToString("#0.00"));//标准
  8358. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  8359. builder.Write("");//人数
  8360. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  8361. builder.Write("");//天数
  8362. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  8363. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  8364. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  8365. decimal rate = 0.00M;
  8366. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  8367. builder.Write(rate.ToString("#0.0000"));//汇率
  8368. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  8369. decimal rbmPrice = dac.SubTotal;
  8370. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  8371. foodandotherStartIndex++;
  8372. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  8373. }
  8374. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  8375. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  8376. {
  8377. table1.Rows.RemoveAt(i - 1);
  8378. }
  8379. var cityTrafficLabel = new StringBuilder()
  8380. .AppendFormat(" 经济舱:{0:#0.00} 元", _EnterExitCosts.CityTranffic)
  8381. .AppendFormat(" 公务舱:{0:#0.00} 元", _EnterExitCosts.CityTranffic1)
  8382. .AppendFormat(" 头等舱:{0:#0.00} ", _EnterExitCosts.CityTranffic2)
  8383. .ToString();
  8384. dic.Add("CityTranffic", cityTrafficLabel);
  8385. string otherFeeStr = "";
  8386. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa:#0.00} 元,";
  8387. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe:#0.00} 元,";
  8388. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00} 元,";
  8389. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  8390. foreach (var otherInfo in dac5)
  8391. {
  8392. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  8393. }
  8394. #endregion
  8395. if (otherFeeStr.Length > 0)
  8396. {
  8397. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  8398. otherFeeStr = $"({otherFeeStr})";
  8399. dic.Add("OtherFeeStr", otherFeeStr);
  8400. }
  8401. //总计
  8402. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  8403. //国际旅费
  8404. string outsideAir = string.Empty;
  8405. string allPriceAir = string.Empty;
  8406. if (_EnterExitCosts.SumJJC == 1)
  8407. {
  8408. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  8409. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  8410. }
  8411. if (_EnterExitCosts.SumGWC == 1)
  8412. {
  8413. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  8414. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  8415. }
  8416. if (_EnterExitCosts.SumTDC == 1)
  8417. {
  8418. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  8419. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  8420. }
  8421. dic.Add("InTravelPrice", $"({outsideAir})");
  8422. dic.Add("FinalSumPrice", $"({allPriceAir})");
  8423. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  8424. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  8425. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  8426. foreach (var key in dic.Keys)
  8427. {
  8428. builder.MoveToBookmark(key);
  8429. builder.Write(dic[key]);
  8430. }
  8431. //模板文件名
  8432. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  8433. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8434. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8435. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8436. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8437. }
  8438. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  8439. {
  8440. //获取模板
  8441. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  8442. //载入模板
  8443. var designer = new WorkbookDesigner
  8444. {
  8445. Workbook = new Workbook(tempPath)
  8446. };
  8447. var dic = new Dictionary<string, string>();
  8448. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  8449. {
  8450. var list = new List<string>();
  8451. try
  8452. {
  8453. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  8454. foreach (var item in spilitArr)
  8455. {
  8456. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  8457. var depCode = spDotandEmpty[2].Substring(0, 3);
  8458. var arrCode = spDotandEmpty[2].Substring(3, 3);
  8459. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  8460. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  8461. list.Add(depName);
  8462. list.Add(arrName);
  8463. }
  8464. list = list.Distinct().ToList();
  8465. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  8466. }
  8467. catch (Exception)
  8468. {
  8469. dic.Add("ReturnCode", "行程录入不正确!");
  8470. }
  8471. }
  8472. else
  8473. {
  8474. dic.Add("ReturnCode", "未录入行程!");
  8475. }
  8476. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  8477. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  8478. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  8479. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  8480. {
  8481. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  8482. dic.Add("Day", sp.Days.ToString());
  8483. }
  8484. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  8485. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  8486. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  8487. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  8488. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  8489. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  8490. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  8491. designer.SetDataSource("Name", Names);
  8492. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  8493. designer.SetDataSource("Day", dic["Day"] + "天");
  8494. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  8495. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  8496. int startIndex = 10;
  8497. const int startIndexcopy = 10;
  8498. if (dac2.Count == dac3.Count)//国家 币种 金额
  8499. {
  8500. for (int i = 0; i < dac2.Count; i++)
  8501. {
  8502. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  8503. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  8504. }
  8505. }
  8506. var dtdac1 = new DataTable();
  8507. var place = new List<string>();
  8508. dtdac1.Columns.AddRange(new DataColumn[] {
  8509. new(){ ColumnName = "city"},
  8510. new(){ ColumnName = "curr"},
  8511. new(){ ColumnName = "criterion"},
  8512. new(){ ColumnName = "number",DataType = typeof(int)},
  8513. new(){ ColumnName = "day",DataType = typeof(int)},
  8514. new(){ ColumnName = "cost", DataType = typeof(decimal)},
  8515. new(){ ColumnName = "rate", DataType = typeof(decimal) },
  8516. new(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  8517. });
  8518. var dtdac2 = new DataTable();
  8519. dtdac2.Columns.AddRange(new DataColumn[] {
  8520. new(){ ColumnName = "city"},
  8521. new(){ ColumnName = "curr"},
  8522. new(){ ColumnName = "criterion"},
  8523. new(){ ColumnName = "number",DataType = typeof(int)},
  8524. new(){ ColumnName = "day",DataType = typeof(int)},
  8525. new(){ ColumnName = "cost", DataType = typeof(decimal)},
  8526. new(){ ColumnName = "rate", DataType = typeof(decimal) },
  8527. new(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  8528. });
  8529. dtdac1.TableName = "tb1";
  8530. dtdac2.TableName = "tb2";
  8531. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  8532. foreach (var item in dac1)
  8533. {
  8534. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  8535. if (place.Contains(item.Place))
  8536. {
  8537. continue;
  8538. }
  8539. DataRow row = dtdac1.NewRow();
  8540. row["city"] = item.Place;
  8541. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  8542. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  8543. row["curr"] = currency;
  8544. row["rate"] = rate.ToString("#0.0000");
  8545. row["criterion"] = item.Cost.ToString("#0.00");
  8546. row["number"] = 1;
  8547. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  8548. //row["costRMB"] = rbmPrice;
  8549. dtdac1.Rows.Add(row);
  8550. place.Add(item.Place);
  8551. }
  8552. place = new List<string>();
  8553. foreach (var item in dac2)
  8554. {
  8555. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  8556. if (place.Contains(item.Place))
  8557. {
  8558. continue;
  8559. }
  8560. DataRow row = dtdac2.NewRow();
  8561. row["city"] = item.Place;
  8562. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  8563. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  8564. row["curr"] = currency;
  8565. row["rate"] = rate.ToString("#0.0000");
  8566. row["criterion"] = item.Cost.ToString("#0.00");
  8567. row["number"] = 1;
  8568. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  8569. //row["cost"] = item.SubTotal;
  8570. //row["costRMB"] = rbmPrice;
  8571. dtdac2.Rows.Add(row);
  8572. place.Add(item.Place);
  8573. //dac2totalPrice += rbmPrice;
  8574. }
  8575. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  8576. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  8577. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  8578. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  8579. var cityTrafficLabel = new StringBuilder()
  8580. .AppendFormat(" 其中:国外城市间")
  8581. .AppendFormat(" 经济舱费:{0:#0.00} 元、", _EnterExitCosts.CityTranffic)
  8582. .AppendFormat(" 公务舱费:{0:#0.00} 元、", _EnterExitCosts.CityTranffic1)
  8583. .AppendFormat(" 头等舱费:{0:#0.00} 元", _EnterExitCosts.CityTranffic2)
  8584. .ToString();
  8585. //decimal cityTraffic =_EnterExitCosts.CityTranffic + _EnterExitCosts.CityTranffic1 + _EnterExitCosts.CityTranffic2;
  8586. designer.SetDataSource("cityTranffic", cityTrafficLabel);
  8587. // designer.SetDataSource("sumCityTranffic", @$"{cityTraffic:#0.00} ");
  8588. string cell4Str1 = string.Empty;
  8589. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ:#0.00} 元/人;";
  8590. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW:#0.00} 元/人;";
  8591. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD:#0.00} 元/人;";
  8592. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  8593. string cellStr = $" 5.其他费用(";
  8594. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  8595. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  8596. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  8597. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  8598. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  8599. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  8600. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  8601. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  8602. foreach (var otherInfo in dac5)
  8603. {
  8604. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  8605. }
  8606. #endregion
  8607. if (cellStr.Length > 8)
  8608. {
  8609. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  8610. }
  8611. cellStr += ")";
  8612. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  8613. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  8614. decimal pxFee = dac4.Sum(it => it.Cost);
  8615. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  8616. string celllastStr1 = "";
  8617. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice:#0.00} 元";
  8618. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice:#0.00} 元";
  8619. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee:#0.00} 元";
  8620. celllastStr1 += $",国际旅费 元";
  8621. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee:#0.00} 元";
  8622. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  8623. designer.SetDataSource("cell4Str", cell4Str);
  8624. designer.SetDataSource("cellStr", cellStr);
  8625. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  8626. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  8627. designer.SetDataSource("celllastStr", celllastStr);
  8628. Workbook wb = designer.Workbook;
  8629. var sheet = wb.Worksheets[0];
  8630. //绑定datatable数据集
  8631. designer.SetDataSource(dtdac1);
  8632. designer.SetDataSource(dtdac2);
  8633. designer.Process();
  8634. var rowStart = dtdac1.Rows.Count;
  8635. while (rowStart > 0)
  8636. {
  8637. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  8638. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  8639. startIndex++;
  8640. rowStart--;
  8641. }
  8642. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  8643. startIndex += 1; //总计行
  8644. rowStart = dtdac2.Rows.Count;
  8645. while (rowStart > 0)
  8646. {
  8647. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  8648. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  8649. startIndex++;
  8650. rowStart--;
  8651. }
  8652. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  8653. wb.CalculateFormula(true);
  8654. //模板文件名
  8655. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  8656. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8657. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8658. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8659. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8660. }
  8661. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  8662. {
  8663. //获取模板
  8664. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  8665. //载入模板
  8666. var doc = new Document(tempPath);
  8667. var builder = new DocumentBuilder(doc);
  8668. var dic = new Dictionary<string, string>
  8669. {
  8670. { "GroupName", _DelegationInfo.TeamName },
  8671. { "ClientUnit", _DelegationInfo.ClientUnit }
  8672. };
  8673. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  8674. string missionLeaderJob = "";//负责人job
  8675. //int groupNumber = 0; //团人数
  8676. if (DeleClientList.Count > 0)
  8677. {
  8678. missionLeader = DeleClientList[0]?.Name ?? "";
  8679. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  8680. }
  8681. dic.Add("MissionLeader", missionLeader); //团负责人
  8682. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  8683. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  8684. #region MyRegion
  8685. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  8686. //{
  8687. // List<string> list = new List<string>();
  8688. // try
  8689. // {
  8690. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  8691. // foreach (var item in spilitArr)
  8692. // {
  8693. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  8694. // var depCode = spDotandEmpty[2].Substring(0, 3);
  8695. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  8696. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  8697. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  8698. // list.Add(depName);
  8699. // list.Add(arrName);
  8700. // }
  8701. // list = list.Distinct().ToList();
  8702. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  8703. // }
  8704. // catch (Exception)
  8705. // {
  8706. // dic.Add("ReturnCode", "行程录入不正确!");
  8707. // }
  8708. //}
  8709. //else
  8710. //{
  8711. // dic.Add("ReturnCode", "未录入行程!");
  8712. //}
  8713. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  8714. dic.Add("ReturnCode", string.Join("、", countrys));
  8715. #endregion
  8716. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  8717. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  8718. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  8719. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  8720. //{
  8721. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  8722. // dic.Add("Day", sp.Days.ToString());
  8723. //}
  8724. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  8725. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  8726. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  8727. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8728. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  8729. //培训人员名单
  8730. int cultivateRowIndex = 7;
  8731. foreach (var item in DeleClientList)
  8732. {
  8733. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  8734. builder.Write(item.Name);
  8735. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  8736. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  8737. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  8738. string birthDay = "";
  8739. if (item.Birthday != null)
  8740. {
  8741. DateTime dt = Convert.ToDateTime(item.Birthday);
  8742. birthDay = $"{dt.Year}.{dt.Month}";
  8743. }
  8744. builder.Write(birthDay);
  8745. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  8746. builder.Write(item.Company);
  8747. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  8748. builder.Write(item.Job);
  8749. cultivateRowIndex++;
  8750. }
  8751. //删除多余行
  8752. //cultivateRowIndex -= 2;
  8753. int delRows = 10 + 7 - cultivateRowIndex;
  8754. if (delRows > 0)
  8755. {
  8756. for (int i = 0; i < delRows; i++)
  8757. {
  8758. table1.Rows.RemoveAt(cultivateRowIndex);
  8759. //cultivateRowIndex++;
  8760. }
  8761. }
  8762. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  8763. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  8764. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  8765. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  8766. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  8767. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  8768. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  8769. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  8770. //decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  8771. decimal cityTranfficFeeToatal = 0.00M;
  8772. //dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));
  8773. //其他费用
  8774. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  8775. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  8776. //其他费用合计
  8777. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  8778. decimal _jjcFeeToatal = _EnterExitCosts.OutsideJJPay + _otherFeeTotal; //经济舱
  8779. decimal _gwcFeeToatal = _EnterExitCosts.OutsideGWPay + _otherFeeTotal; //公务舱
  8780. //公务舱合计
  8781. //国际旅费
  8782. //string outsideJJ = "";
  8783. //string allPriceJJ = "";
  8784. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  8785. {
  8786. dic.Add("AirFeeTotal", _EnterExitCosts.OutsideJJPay.ToString("#0.00"));
  8787. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  8788. }
  8789. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  8790. {
  8791. dic.Add("AirFeeTotal", _EnterExitCosts.OutsideGWPay.ToString("#0.00"));
  8792. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  8793. }
  8794. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  8795. {
  8796. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.OutsideJJPay:#0.00} 公务舱:{_EnterExitCosts.OutsideGWPay:#0.00}");
  8797. dic.Add("AirFeeTotal", airFeeTotalStr);
  8798. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal:#0.00} 公务舱:{_gwcFeeToatal:#0.00}");
  8799. dic.Add("FeeTotal", feeTotalStr);
  8800. }
  8801. foreach (var key in dic.Keys)
  8802. {
  8803. builder.MoveToBookmark(key);
  8804. builder.Write(dic[key]);
  8805. }
  8806. //模板文件名
  8807. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  8808. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8809. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8810. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8811. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8812. }
  8813. }
  8814. else if (dto.ExportType == 2) //表格
  8815. {
  8816. //利用键值对存放数据
  8817. Dictionary<string, string> dic = new Dictionary<string, string>();
  8818. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  8819. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  8820. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  8821. dic.Add("Day", sp.Days.ToString());
  8822. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  8823. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  8824. {
  8825. //获取模板
  8826. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  8827. //载入模板
  8828. var doc = new Document(tempPath);
  8829. var builder = new DocumentBuilder(doc);
  8830. dic.Add("TeamName", _DelegationInfo.TeamName);
  8831. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  8832. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  8833. string missionLeaderName = "",
  8834. missionLeaderJob = "";
  8835. if (DeleClientList.Count > 0)
  8836. {
  8837. missionLeaderName = DeleClientList[0].Name;
  8838. missionLeaderJob = DeleClientList[0].Job;
  8839. }
  8840. dic.Add("MissionLeaderName", missionLeaderName);
  8841. dic.Add("MissionLeaderJob", missionLeaderJob);
  8842. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  8843. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  8844. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8845. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  8846. int rowCount = 10;//总人数行
  8847. int startRowIndex = 7; //起始行
  8848. for (int i = 0; i < DeleClientList.Count; i++)
  8849. {
  8850. builder.MoveToCell(0, startRowIndex, 0, 0);
  8851. builder.Write(DeleClientList[i].Name); //出国人员姓名
  8852. builder.MoveToCell(0, startRowIndex, 1, 0);
  8853. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  8854. builder.Write(sex);//性别
  8855. builder.MoveToCell(0, startRowIndex, 2, 0);
  8856. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  8857. builder.MoveToCell(0, startRowIndex, 3, 0);
  8858. builder.Write(DeleClientList[i].Company);//工作单位
  8859. builder.MoveToCell(0, startRowIndex, 4, 0);
  8860. builder.Write(DeleClientList[i].Job);//职务及级别
  8861. builder.MoveToCell(0, startRowIndex, 5, 0);
  8862. builder.Write("");//人员属性
  8863. builder.MoveToCell(0, startRowIndex, 6, 0);
  8864. builder.Write("");//上次出国时间
  8865. startRowIndex++;
  8866. }
  8867. int nullRow = rowCount - DeleClientList.Count;//空行
  8868. for (int i = 0; i < nullRow; i++)
  8869. {
  8870. table1.Rows.Remove(table1.Rows[startRowIndex]);
  8871. }
  8872. foreach (var key in dic.Keys)
  8873. {
  8874. builder.MoveToBookmark(key);
  8875. builder.Write(dic[key]);
  8876. }
  8877. //模板文件名
  8878. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  8879. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8880. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8881. if (dto.PortType == 1) return Ok(JsonView(true, "成功", new { Url = url }));
  8882. else if (dto.PortType == 2 || dto.PortType == 3) return Ok(JsonView(true, "成功", url));
  8883. }
  8884. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  8885. {
  8886. //获取模板
  8887. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  8888. //载入模板
  8889. var doc = new Document(tempPath);
  8890. var builder = new DocumentBuilder(doc);
  8891. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  8892. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  8893. dic.Add("Names", Names);
  8894. int accommodationRows = 12;
  8895. //int foodandotherRows = 12;
  8896. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  8897. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  8898. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8899. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  8900. int accommodationStartIndex = 6;
  8901. decimal dac1totalPrice = 0.00M;
  8902. foreach (var dac in dac1)
  8903. {
  8904. if (dac.SubTotal == 0)
  8905. {
  8906. continue;
  8907. }
  8908. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  8909. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  8910. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  8911. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  8912. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  8913. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  8914. builder.Write(currency);//币种
  8915. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  8916. builder.Write(dac.Cost.ToString("#0.00"));//标准
  8917. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  8918. builder.Write("");//人数
  8919. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  8920. builder.Write("");//天数
  8921. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  8922. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  8923. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  8924. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  8925. builder.Write(rate.ToString("#0.0000"));//汇率
  8926. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  8927. decimal rbmPrice = rate * dac.SubTotal;
  8928. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  8929. accommodationStartIndex++;
  8930. dac1totalPrice += rbmPrice;
  8931. }
  8932. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  8933. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  8934. builder.Write("小计");
  8935. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  8936. builder.Write(dac1totalPrice.ToString("#0.00"));
  8937. accommodationStartIndex++;
  8938. int nullRow = accommodationRows - dac1.Count;
  8939. //删除空行
  8940. //if (nullRow > 0)
  8941. //{
  8942. // int rowIndex = accommodationStartIndex;
  8943. // for (int i = 0; i < nullRow; i++)
  8944. // {
  8945. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  8946. // row.Remove();
  8947. // rowIndex++;
  8948. // }
  8949. //}
  8950. if (dac2.Count == dac3.Count)//国家 币种 金额
  8951. {
  8952. for (int i = 0; i < dac2.Count; i++)
  8953. {
  8954. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  8955. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  8956. }
  8957. }
  8958. int foodandotherStartIndex = 19;//
  8959. decimal dac2totalPrice = 0.00M;
  8960. foreach (var dac in dac2)
  8961. {
  8962. if (dac.SubTotal == 0)
  8963. {
  8964. continue;
  8965. }
  8966. //foodandotherStartIndex = 12;
  8967. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  8968. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  8969. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  8970. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  8971. builder.Write(currency);//币种
  8972. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  8973. builder.Write(dac.Cost.ToString("#0.00"));//标准
  8974. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  8975. builder.Write("");//人数
  8976. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  8977. builder.Write("");//天数
  8978. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  8979. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  8980. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  8981. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  8982. builder.Write(rate.ToString("#0.0000"));//汇率
  8983. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  8984. decimal rbmPrice = rate * dac.SubTotal;
  8985. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  8986. foodandotherStartIndex++;
  8987. dac2totalPrice += rbmPrice;
  8988. }
  8989. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  8990. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  8991. //删除空行
  8992. //if (dac2.Count < foodandotherRows)
  8993. //{
  8994. // while (table2.Rows.Count > dac2.Count)
  8995. // {
  8996. // table2.Rows.RemoveAt(dac2.Count);
  8997. // }
  8998. //}
  8999. var citytrafficLable = new StringBuilder()
  9000. .AppendFormat($"经济舱费用:{_EnterExitCosts.CityTranffic:#0.00} 元、")
  9001. .AppendFormat($"公务舱费用:{_EnterExitCosts.CityTranffic1:#0.00}元、")
  9002. .AppendFormat($"头等舱费用:{_EnterExitCosts.CityTranffic2:#0.00}")
  9003. .ToString();
  9004. dic.Add("CityTranffic", citytrafficLable);
  9005. string otherFeeStr = "";
  9006. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  9007. if (_EnterExitCosts.YiMiao > 0) otherFeeStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  9008. if (_EnterExitCosts.HeSuan > 0) otherFeeStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  9009. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  9010. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  9011. if (_EnterExitCosts.Service > 0) otherFeeStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  9012. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  9013. foreach (var otherInfo in dac5)
  9014. {
  9015. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal:#0.00} 元,";
  9016. }
  9017. #endregion
  9018. if (otherFeeStr.Length > 0)
  9019. {
  9020. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  9021. otherFeeStr = $"({otherFeeStr})";
  9022. dic.Add("OtherFeeStr", otherFeeStr);
  9023. }
  9024. foreach (var key in dic.Keys)
  9025. {
  9026. builder.MoveToBookmark(key);
  9027. builder.Write(dic[key]);
  9028. }
  9029. //模板文件名
  9030. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  9031. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  9032. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  9033. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  9034. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  9035. }
  9036. }
  9037. else if (dto.ExportType == 3)
  9038. {
  9039. if (dto.SubTypeId == 1) //团组成员名单
  9040. {
  9041. if (!DeleClientList.Any()) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成员暂未录入!!!", ""));
  9042. //获取模板
  9043. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  9044. //载入模板
  9045. var doc = new Document(tempPath);
  9046. var builder = new DocumentBuilder(doc);
  9047. //获取word里所有表格
  9048. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  9049. //获取所填表格的序数
  9050. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  9051. var rowStart = tableOne.Rows[0]; //获取第1行
  9052. //循环赋值
  9053. for (int i = 0; i < DeleClientList.Count; i++)
  9054. {
  9055. builder.MoveToCell(0, i + 1, 0, 0);
  9056. builder.Write(DeleClientList[i].Name);
  9057. builder.MoveToCell(0, i + 1, 1, 0);
  9058. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  9059. builder.Write(sex);
  9060. builder.MoveToCell(0, i + 1, 2, 0);
  9061. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  9062. builder.MoveToCell(0, i + 1, 3, 0);
  9063. builder.Write(DeleClientList[i].Company);
  9064. builder.MoveToCell(0, i + 1, 4, 0);
  9065. builder.Write(DeleClientList[i].Job);
  9066. }
  9067. //删除多余行
  9068. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  9069. {
  9070. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  9071. }
  9072. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  9073. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  9074. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  9075. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  9076. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  9077. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  9078. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  9079. }
  9080. }
  9081. return Ok(JsonView(400, "操作失败!", ""));
  9082. }
  9083. catch (Exception ex)
  9084. {
  9085. return Ok(JsonView(400, ex.Message, ""));
  9086. }
  9087. }
  9088. /// <summary>
  9089. /// 获取三公费用标准city
  9090. /// </summary>
  9091. /// <param name="placeData"></param>
  9092. /// <param name="nationalTravelFeeId"></param>
  9093. /// <returns></returns>
  9094. private static string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  9095. {
  9096. string _city = string.Empty;
  9097. if (placeData.Count < 1) return _city;
  9098. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  9099. if (data == null) return _city;
  9100. string country = data.Country;
  9101. string city = data.City;
  9102. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  9103. else _city = city;
  9104. return _city;
  9105. }
  9106. ///// <summary>
  9107. ///// 团组模块 - 出入境费用 - 明细表导出
  9108. ///// </summary>
  9109. ///// <returns></returns>
  9110. //[HttpPost]
  9111. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9112. //public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  9113. //{
  9114. // var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  9115. // if (data.Code != 0)
  9116. // {
  9117. // return Ok(JsonView(false, data.Msg));
  9118. // }
  9119. // return Ok(JsonView(true, data.Msg, data.Data));
  9120. //}
  9121. /// <summary>
  9122. /// 团组模块 - 出入境费用 - 一键清空
  9123. /// </summary>
  9124. /// <returns></returns>
  9125. [HttpPost]
  9126. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  9127. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9128. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  9129. {
  9130. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  9131. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  9132. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  9133. var _view = await _enterExitCostRep.OneClickClear(dto.Id, dto.DiId, dto.UserId);
  9134. await _sqlSugar.Updateable<Grp_DayOtherPrice>()
  9135. .Where(x => x.Diid == dto.DiId && x.IsDel == 0)
  9136. .SetColumns(x => new Grp_DayOtherPrice
  9137. {
  9138. IsDel = 1,
  9139. DeleteUserId = dto.UserId,
  9140. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  9141. })
  9142. .ExecuteCommandAsync();
  9143. if (_view.Code == 0)
  9144. {
  9145. return Ok(JsonView(true, "操作成功"));
  9146. }
  9147. return Ok(JsonView(false, "操作失败"));
  9148. }
  9149. /// <summary>
  9150. /// 团组模块 - 出入境费用 - 子项删除
  9151. /// </summary>
  9152. /// <returns></returns>
  9153. [HttpPost]
  9154. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  9155. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9156. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  9157. {
  9158. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  9159. if (data.Code != 0)
  9160. {
  9161. return Ok(JsonView(false, data.Msg));
  9162. }
  9163. return Ok(JsonView(true, "操作成功!", data.Data));
  9164. }
  9165. /// <summary>
  9166. /// 删除三公其他费用
  9167. /// </summary>
  9168. /// <param name="dto"></param>
  9169. /// <returns></returns>
  9170. [HttpPost]
  9171. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  9172. public IActionResult DeleteOtherExpenses(EnterExitCostSubItemDelDto dto)
  9173. {
  9174. var jw = JsonView(false, "删除失败!");
  9175. var data = new Grp_DayOtherPrice()
  9176. {
  9177. Id = dto.Id,
  9178. IsDel = 1,
  9179. DeleteUserId = dto.DeleteUserId,
  9180. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  9181. };
  9182. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  9183. if (del > 0)
  9184. {
  9185. jw.Code = 200;
  9186. jw.Msg = "删除成功!";
  9187. }
  9188. return Ok(jw);
  9189. }
  9190. /// <summary>
  9191. /// 团组模块 - 出入境国家费用标准 List
  9192. /// </summary>
  9193. /// <returns></returns>
  9194. [HttpPost]
  9195. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9196. public async Task<IActionResult> GetNationalTravelFeeData(NationalTravelFeeDataDto dto)
  9197. {
  9198. int provinceId = dto.ProvinceId;
  9199. if (provinceId < 1) provinceId = 122; //默认四川省数据
  9200. var nftData = await _sqlSugar
  9201. .Queryable<Grp_NationalTravelFee, Sys_SetData, Sys_Users, Sys_Cities>((ntf, sd1, u, c) => new JoinQueryInfos(
  9202. JoinType.Left, ntf.Currency == sd1.Id,
  9203. JoinType.Left, ntf.LastUpdateUserId == u.Id,
  9204. JoinType.Left, ntf.ProvinceId == c.Id
  9205. ))
  9206. .Where((ntf, sd1, u, c) => ntf.IsDel == 0 && ntf.ProvinceId == provinceId)
  9207. .Select((ntf, sd1, u, c) => new NationalTravelFeeInfoView
  9208. {
  9209. Id = ntf.Id,
  9210. ProvinceId = ntf.ProvinceId,
  9211. ProvinceName = c.Name_CN,
  9212. Continent = ntf.Continent,
  9213. Country = ntf.Country,
  9214. City = ntf.City,
  9215. Currency = ntf.Currency,
  9216. CurrencyCode = sd1.Name,
  9217. CurrencyName = sd1.Remark,
  9218. RoomCost = ntf.RoomCost,
  9219. FoodCost = ntf.FoodCost,
  9220. PublicCost = ntf.PublicCost,
  9221. LastUpdateUserId = ntf.LastUpdateUserId,
  9222. LastUpdateUserName = u.CnName,
  9223. LastUpdateTime = ntf.LastUpdateTime
  9224. })
  9225. .ToListAsync();
  9226. return Ok(JsonView(true, "查询成功!", nftData));
  9227. }
  9228. /// <summary>
  9229. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  9230. /// </summary>
  9231. /// <returns></returns>
  9232. [HttpPost]
  9233. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9234. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  9235. {
  9236. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  9237. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  9238. List<string> countryData = new List<string>();
  9239. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country!).ToList());
  9240. countryData = countryData.Distinct().ToList();
  9241. List<dynamic> dataSource = new List<dynamic>();
  9242. foreach (var item in countryData)
  9243. {
  9244. var cityData1 = new List<string>();
  9245. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City ?? "").ToList();
  9246. var countryData2 = new
  9247. {
  9248. CountryName = item,
  9249. CityData = cityData1
  9250. };
  9251. if (!dataSource.Contains(countryData2))
  9252. {
  9253. dataSource.Add(countryData2);
  9254. }
  9255. }
  9256. return Ok(JsonView(true, "查询成功!", dataSource));
  9257. }
  9258. /// <summary>
  9259. /// 团组模块 - 出入境国家费用标准 Page List
  9260. /// </summary>
  9261. /// <returns></returns>
  9262. [HttpPost]
  9263. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9264. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  9265. {
  9266. int portId = dto.PortType,
  9267. pageIndex = dto.PageIndex,
  9268. pageSize = dto.PageSize;
  9269. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  9270. if (pageIndex == 0) pageIndex = 1;
  9271. if (pageSize == 0) pageSize = 10;
  9272. RefAsync<int> total = 0;
  9273. var nationalTravelFeeData = await _sqlSugar
  9274. .Queryable<Grp_NationalTravelFee, Sys_SetData, Sys_Users, Sys_Cities>((ntf, sd1, u, sd2) => new JoinQueryInfos(
  9275. JoinType.Left, ntf.Currency == sd1.Id,
  9276. JoinType.Left, ntf.LastUpdateUserId == u.Id,
  9277. JoinType.Left, ntf.ProvinceId == sd2.Id
  9278. ))
  9279. .Where((ntf, sd1, u, sd2) => ntf.IsDel == 0)
  9280. .WhereIF(dto.ProvinceId > 0, (ntf, sd1, u, sd2) => ntf.ProvinceId == dto.ProvinceId)
  9281. .WhereIF(!string.IsNullOrEmpty(dto.Country), (ntf, sd1, u, sd2) => ntf.Country.Contains(dto.Country))
  9282. .WhereIF(!string.IsNullOrEmpty(dto.City), (ntf, sd1, u, sd2) => ntf.City.Contains(dto.City))
  9283. .OrderByDescending((ntf, sd1, u, sd2) => ntf.LastUpdateTime)
  9284. .Select((ntf, sd1, u, sd2) => new NationalTravelFeePageInfoView
  9285. {
  9286. RowNumber = SqlFunc.RowNumber($"{ntf.LastUpdateTime} Desc"),
  9287. Id = ntf.Id,
  9288. ProvinceId = ntf.ProvinceId,
  9289. ProvinceName = sd2.Name_CN,
  9290. Continent = ntf.Continent,
  9291. Country = ntf.Country,
  9292. City = ntf.City,
  9293. Currency = ntf.Currency,
  9294. CurrencyCode = sd1.Name,
  9295. CurrencyName = sd1.Remark,
  9296. RoomCost = ntf.RoomCost,
  9297. FoodCost = ntf.FoodCost,
  9298. PublicCost = ntf.PublicCost,
  9299. LastUpdateUserId = ntf.LastUpdateUserId,
  9300. LastUpdateUserName = u.CnName,
  9301. LastUpdateTime = ntf.LastUpdateTime,
  9302. Remark = ntf.Remark
  9303. })
  9304. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9305. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  9306. }
  9307. /// <summary>
  9308. /// 团组模块 - 出入境国家费用标准 根据城市查询
  9309. /// </summary>
  9310. /// <returns></returns>
  9311. [HttpPost]
  9312. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9313. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  9314. {
  9315. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  9316. int portId = dto.PortType;
  9317. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  9318. string whereSql = string.Empty;
  9319. if (!string.IsNullOrEmpty(dto.Country))
  9320. {
  9321. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  9322. }
  9323. if (!string.IsNullOrEmpty(dto.City))
  9324. {
  9325. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  9326. }
  9327. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  9328. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,gntf.TrainCost,
  9329. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  9330. From Grp_NationalTravelFee gntf
  9331. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  9332. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  9333. Where gntf.Isdel = 0 {0} ", whereSql);
  9334. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  9335. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  9336. }
  9337. /// <summary>
  9338. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  9339. /// </summary>
  9340. /// <returns></returns>
  9341. [HttpPost]
  9342. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9343. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  9344. {
  9345. return Ok(await _enterExitCostRep.PostNationalTravelFeeOperate(dto));
  9346. }
  9347. /// <summary>
  9348. /// 团组模块 - 出入境国家费用标准 - Del
  9349. /// </summary>
  9350. /// <returns></returns>
  9351. [HttpPost]
  9352. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9353. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  9354. {
  9355. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  9356. {
  9357. Id = dto.Id,
  9358. DeleteUserId = dto.DeleteUserId,
  9359. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  9360. IsDel = 1
  9361. };
  9362. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  9363. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  9364. .WhereColumns(it => new { it.Id })
  9365. .ExecuteCommandAsync();
  9366. if (delStatus <= 0)
  9367. {
  9368. return Ok(JsonView(false, "删除失败!"));
  9369. }
  9370. return Ok(JsonView(true, "操作成功!"));
  9371. }
  9372. /// <summary>
  9373. /// 团组模块 - 出入境国家费用标准 - 费用导入收款账单
  9374. /// 注:Get 请求Headers 加 Token
  9375. /// </summary>
  9376. /// <param name="groupId"></param>
  9377. /// <returns></returns>
  9378. [HttpGet("{groupId}")]
  9379. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9380. public async Task<IActionResult> NationalTravelFeeImportReceivables(int groupId)
  9381. {
  9382. var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  9383. if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  9384. var data = await GeneralMethod.ReceivablesImportFeeAsync(groupId);
  9385. data.ForEach(x =>
  9386. {
  9387. x.CreateUserId = _currUserInfo.UserId;
  9388. });
  9389. if (data.Any())
  9390. {
  9391. var add = await _sqlSugar.Insertable(data).ExecuteCommandAsync();
  9392. if (add > 0)
  9393. {
  9394. return Ok(JsonView(true, "操作成功!"));
  9395. }
  9396. }
  9397. return Ok(JsonView(false, "未操作!"));
  9398. }
  9399. #endregion
  9400. #region 团组经理模块 出入境费用-草稿
  9401. /// <summary>
  9402. /// 团组模块 - 出入境费用-草稿 - 基础数据源 - 省份归属
  9403. /// </summary>
  9404. /// <returns></returns>
  9405. [HttpGet]
  9406. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9407. public async Task<IActionResult> EnterExitDraftProvBelongCostDataSource()
  9408. {
  9409. var provData = await _groupRepository.ProvinceBasicSource();
  9410. return Ok(JsonView(true, "查询成功!", provData));
  9411. }
  9412. /// <summary>
  9413. /// 团组模块 - 出入境费用-草稿 - 文件类型list 根据省份Id获取
  9414. /// </summary>
  9415. /// <returns></returns>
  9416. [HttpGet("{provinceId}")]
  9417. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9418. public async Task<IActionResult> EnterExitCostDraftFileOwner([FromRoute] int provinceId = 122)
  9419. {
  9420. //验证城市归属并给默认值
  9421. if (provinceId < 1) provinceId = 122;
  9422. /*
  9423. * 122 四川
  9424. * 108 贵州
  9425. * 103 重庆
  9426. * 132 云南
  9427. */
  9428. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostDraftRep.FileOwner(provinceId);
  9429. return Ok(JsonView(true, "查询成功!", new
  9430. {
  9431. WordTypeData = wordTypeData,
  9432. ExcelTypeData = excelTypeData,
  9433. }));
  9434. }
  9435. /// <summary>
  9436. /// 团组模块 - 出入境费用-草稿 - 基础数据源(团组名称/币种类型)
  9437. /// </summary>
  9438. /// <returns></returns>
  9439. [HttpPost]
  9440. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9441. public async Task<IActionResult> EnterExitCostDraftDataSource(EnterExitCostDraftDataSourceDto dto)
  9442. {
  9443. var draftNameDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  9444. .Where(x => x.IsDel == 0)
  9445. .OrderByDescending(x => x.CreateTime)
  9446. .Select(x => new { x.Id, x.DraftName })
  9447. .ToListAsync();
  9448. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  9449. //SetDataInfoView
  9450. var dataSource = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  9451. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  9452. var _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  9453. int provinceId = dto.ProvinceId;
  9454. if (provinceId < 1) provinceId = 122;
  9455. /*
  9456. * 122 四川
  9457. * 108 贵州
  9458. * 103 重庆
  9459. * 132 云南
  9460. */
  9461. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostRep.FileOwner(provinceId);
  9462. //默认币种显示
  9463. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  9464. var viewPermissionData = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  9465. return Ok(JsonView(true, "查询成功!", new
  9466. {
  9467. DraftNameDatas = draftNameDatas,
  9468. CurrencyData = _CurrencyData,
  9469. WordTypeData = wordTypeData,
  9470. ExcelTypeData = excelTypeData,
  9471. CurrencyInit = _currencyInfos,
  9472. ViewPermissionData = viewPermissionData
  9473. }));
  9474. }
  9475. /// <summary>
  9476. /// 团组模块 - 出入境费用-草稿
  9477. /// 实时汇率 tips
  9478. /// 机票费用 tips
  9479. /// </summary>
  9480. /// <returns></returns>
  9481. [HttpPost]
  9482. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9483. public async Task<IActionResult> EnterExitCostDraftCorrelationTips(EnterExitCostDraftCorrelationTipsDto dto)
  9484. {
  9485. //var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  9486. return Ok(JsonView(true, "查询成功!", new
  9487. {
  9488. //GroupNameData = groupNameData.Data,
  9489. //visaData = visaData.Data,
  9490. //airData = airData.Data,
  9491. reteInfos = await GeneralMethod.EnterExitCostLiveRate()
  9492. }));
  9493. }
  9494. /// <summary>
  9495. /// 团组模块 - 出入境费用-草稿
  9496. /// 签证费用 tips
  9497. /// </summary>
  9498. /// <returns></returns>
  9499. [HttpPost]
  9500. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9501. public async Task<IActionResult> EnterExitCostDraftVisaTips(EnterExitCostDraftVisaTipsDto dto)
  9502. {
  9503. //if (dto.DraftId < 1) return Ok(JsonView(false,MsgTips.Id));
  9504. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9505. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  9506. .Select(x => x.NationalTravelFeeId)
  9507. .Distinct()
  9508. .ToListAsync();
  9509. //if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  9510. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  9511. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  9512. .Select(x => x.Country)
  9513. .Distinct()
  9514. .ToArrayAsync();
  9515. //if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  9516. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  9517. return Ok(JsonView(true, "查询成功!", new
  9518. {
  9519. totalAmt,
  9520. remark
  9521. }));
  9522. }
  9523. /// <summary>
  9524. /// 团组模块 - 出入境费用-草稿 - Info
  9525. /// </summary>
  9526. /// <returns></returns>
  9527. [HttpPost]
  9528. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Details)]
  9529. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9530. public async Task<IActionResult> EnterExitCostDraftInfoById(EnterExitCostDraftInfoByIdDto dto)
  9531. {
  9532. return Ok(await _enterExitCostDraftRep.EnterExitCostDraftInfoById(dto));
  9533. }
  9534. /// <summary>
  9535. /// 团组模块 - 出入境费用-草稿 - 设置view权限
  9536. /// </summary>
  9537. /// <returns></returns>
  9538. [HttpPost]
  9539. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9540. public async Task<IActionResult> EnterExitCostDraftSetViewPermissiion(EnterExitCostDraftSetViewPermissiionDto dto)
  9541. {
  9542. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9543. if (dto.DraftId < 1) return Ok(JsonView(false, "请传入有效的DraftId;"));
  9544. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  9545. var permissions = new List<Grp_EnterExitCostDraftPermission>();
  9546. foreach (var userId in dto.UserIds)
  9547. {
  9548. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  9549. }
  9550. if (permissions.Any())
  9551. {
  9552. _sqlSugar.BeginTran();
  9553. try
  9554. {
  9555. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  9556. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  9557. if (result < 1)
  9558. {
  9559. _sqlSugar.RollbackTran();
  9560. return Ok(JsonView(false));
  9561. }
  9562. }
  9563. catch (Exception ex)
  9564. {
  9565. _sqlSugar.RollbackTran();
  9566. return Ok(JsonView(false, ex.Message));
  9567. }
  9568. _sqlSugar.CommitTran();
  9569. return Ok(JsonView(true));
  9570. }
  9571. return Ok(JsonView(false));
  9572. }
  9573. /// <summary>
  9574. /// 团组模块 - 出入境费用-草稿 - Add And Update
  9575. /// </summary>
  9576. /// <returns></returns>
  9577. [HttpPost]
  9578. [ApiLog("Grp_EnterExitCostDraft", OperationEnum.Add)]
  9579. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9580. public async Task<IActionResult> EnterExitCostDraftOp(EnterExitCostDraftOpDto dto)
  9581. {
  9582. var data = await _enterExitCostDraftRep.EnterExitCostDraftOp(dto);
  9583. if (data.Code != 0)
  9584. {
  9585. return Ok(JsonView(false, data.Msg));
  9586. }
  9587. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  9588. //汇率信息记录
  9589. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  9590. return Ok(JsonView(true, data.Msg, data.Data));
  9591. }
  9592. /// <summary>
  9593. /// 团组模块 - 出入境费用-草稿 - File downlaod
  9594. /// </summary>
  9595. /// <param name="dto"></param>
  9596. /// <returns></returns>
  9597. [HttpPost]
  9598. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Download)]
  9599. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9600. public async Task<IActionResult> EnterExitCostDraftDownload(EnterExitCostDraftDownloadDto dto)
  9601. {
  9602. try
  9603. {
  9604. var id = dto.Id;
  9605. if (id < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  9606. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  9607. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  9608. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  9609. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  9610. 3 团组成员名单 1 团组成员名单", ""));
  9611. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(it => it.IsDel == 0 && it.Id == id).OrderByDescending(x => x.CreateTime).First();
  9612. if (_EnterExitCosts == null) return Ok(JsonView(400, "未填写出入境费用-草稿;", ""));
  9613. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(it => it.IsDel == 0 && it.ParentId == id).ToList();
  9614. var countryIds = _DayAndCosts.Select(x => x.NationalTravelFeeId).ToList();
  9615. var nationalTravelFeeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0 && countryIds.Contains(it.Id)).ToList();
  9616. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  9617. //数据源
  9618. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  9619. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  9620. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  9621. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  9622. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  9623. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  9624. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  9625. .Where((x, a, b) => x.IsDel == 0 && x.ParentId == id)
  9626. .Select((x, a, b) => new
  9627. {
  9628. x.Index,
  9629. itemName = a.Name,
  9630. CurrencyStr = b.Name,
  9631. x.Cost,
  9632. x.SubTotal,
  9633. x.Remark
  9634. })
  9635. .OrderBy((x) => x.Index)
  9636. .ToList(); //其他款项费用
  9637. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  9638. var peiceItemCurrencys = new List<string>();
  9639. if (_DayAndCosts.Any())
  9640. {
  9641. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  9642. if (currencyIds.Any()) peiceItemCurrencys.AddRange(_CurrDatas.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  9643. }
  9644. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  9645. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  9646. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  9647. {
  9648. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  9649. }
  9650. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  9651. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  9652. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  9653. if (dto.ExportType == 1) //明细表
  9654. {
  9655. if (dto.SubTypeId == 1005) //1005(默认明细表)
  9656. {
  9657. //获取模板
  9658. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  9659. //载入模板
  9660. Document doc = new Document(tempPath);
  9661. DocumentBuilder builder = new DocumentBuilder(doc);
  9662. //利用键值对存放数据
  9663. Dictionary<string, string> dic = new Dictionary<string, string>();
  9664. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  9665. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  9666. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  9667. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  9668. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  9669. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  9670. //境内费用(其他费用)
  9671. if (_EnterExitCosts.ChoiceOne == 1)
  9672. {
  9673. string row1_1 = "";
  9674. if (_EnterExitCosts.Visa > 0)
  9675. {
  9676. //insidePayTotal += _EnterExitCosts.Visa;
  9677. row1_1 = $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  9678. //if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  9679. //{
  9680. // row1_1 += $"\t签证费用描述: {_EnterExitCosts.VisaRemark} 人民币/人";
  9681. //}
  9682. }
  9683. string row1_2 = "";
  9684. if (_EnterExitCosts.YiMiao > 0)
  9685. {
  9686. //insidePayTotal += _EnterExitCosts.YiMiao;
  9687. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  9688. }
  9689. if (_EnterExitCosts.HeSuan > 0)
  9690. {
  9691. //insidePayTotal += _EnterExitCosts.HeSuan;
  9692. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  9693. }
  9694. if (_EnterExitCosts.Service > 0)
  9695. {
  9696. //insidePayTotal += _EnterExitCosts.Service;
  9697. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  9698. }
  9699. string row1_3 = "";
  9700. if (_EnterExitCosts.Safe > 0)
  9701. {
  9702. //insidePayTotal += _EnterExitCosts.Safe;
  9703. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  9704. }
  9705. if (_EnterExitCosts.Ticket > 0)
  9706. {
  9707. //insidePayTotal += _EnterExitCosts.Ticket;
  9708. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  9709. }
  9710. string row1 = "";
  9711. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  9712. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  9713. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  9714. row1 += $"备注:{_EnterExitCosts.Remark}";
  9715. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  9716. dic.Add("Row1Str", row1);
  9717. }
  9718. string airTotalStr = string.Empty,
  9719. airPriceStr = string.Empty;
  9720. //经济舱
  9721. if (_EnterExitCosts.SumJJC == 1)
  9722. {
  9723. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  9724. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  9725. }
  9726. //公务舱
  9727. if (_EnterExitCosts.SumGWC == 1)
  9728. {
  9729. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  9730. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  9731. }
  9732. //头等舱
  9733. if (_EnterExitCosts.SumTDC == 1)
  9734. {
  9735. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  9736. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  9737. }
  9738. //汇率描述
  9739. string rateStr = "";
  9740. if (peiceItemCurrencyInfos.Any())
  9741. {
  9742. rateStr = "\r\n汇率描述:";
  9743. foreach (var item in peiceItemCurrencyInfos)
  9744. {
  9745. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate.ToString("#0.0000")} ";
  9746. }
  9747. }
  9748. string twoItemRemark = "备注:";
  9749. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  9750. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  9751. dic.Add("AirTotalStr", airTotalStr);
  9752. dic.Add("AirPriceStr", airPriceStr);
  9753. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  9754. dic.Add("TwoItemRemark", twoItemRemark);
  9755. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  9756. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  9757. int table1Row = 0,
  9758. table2Row = 0,
  9759. table3Row = 0,
  9760. table4Row = 0,
  9761. table5Row = 0;
  9762. //住宿费
  9763. if (_EnterExitCosts.ChoiceThree == 1)
  9764. {
  9765. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  9766. table1Row = dac1.Count;
  9767. #region 填充word表格内容
  9768. for (int i = 0; i < dac1.Count; i++)
  9769. {
  9770. var dac = dac1[i];
  9771. if (dac == null) continue;
  9772. builder.MoveToCell(0, i, 0, 0);
  9773. builder.Write("第" + dac.Days.ToString() + "晚:");
  9774. builder.MoveToCell(0, i, 1, 0);
  9775. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  9776. //builder.Write(dac.Place == null ? "" : dac.Place);
  9777. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  9778. builder.MoveToCell(0, i, 2, 0);
  9779. builder.Write("费用标准:");
  9780. string curr = "";
  9781. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  9782. if (currData != null)
  9783. {
  9784. curr = currData.Name;
  9785. }
  9786. builder.MoveToCell(0, i, 3, 0);
  9787. builder.Write(dac.Cost.ToString("#0.00") + curr);
  9788. builder.MoveToCell(0, i, 4, 0);
  9789. builder.Write("费用小计:");
  9790. builder.MoveToCell(0, i, 5, 0);
  9791. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  9792. }
  9793. #endregion
  9794. }
  9795. else dic.Add("SubZS", "0.00");
  9796. //删除多余行
  9797. while (table1.Rows.Count > table1Row)
  9798. {
  9799. table1.Rows.RemoveAt(table1Row);
  9800. }
  9801. //伙食费
  9802. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  9803. if (_EnterExitCosts.ChoiceFour == 1)
  9804. {
  9805. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  9806. table2Row = dac2.Count;
  9807. #region 填充word表格内容
  9808. for (int i = 0; i < dac2.Count; i++)
  9809. {
  9810. var dac = dac2[i];
  9811. if (dac == null) continue;
  9812. builder.MoveToCell(1, i, 0, 0);
  9813. builder.Write("第" + dac.Days.ToString() + "天:");
  9814. builder.MoveToCell(1, i, 1, 0);
  9815. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  9816. builder.MoveToCell(1, i, 2, 0);
  9817. builder.Write("费用标准:");
  9818. string curr = "";
  9819. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  9820. if (currData != null)
  9821. {
  9822. curr = currData.Name;
  9823. }
  9824. builder.MoveToCell(1, i, 3, 0);
  9825. builder.Write(dac.Cost.ToString("#0.00") + curr);
  9826. builder.MoveToCell(1, i, 4, 0);
  9827. builder.Write("费用小计:");
  9828. builder.MoveToCell(1, i, 5, 0);
  9829. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  9830. }
  9831. #endregion
  9832. }
  9833. else dic.Add("SubHS", "0.00");
  9834. //删除多余行
  9835. while (table2.Rows.Count > table2Row)
  9836. {
  9837. table2.Rows.RemoveAt(table2Row);
  9838. }
  9839. //公杂费
  9840. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  9841. if (_EnterExitCosts.ChoiceFive == 1)
  9842. {
  9843. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  9844. table3Row = dac3.Count;
  9845. #region 填充word表格内容
  9846. for (int i = 0; i < dac3.Count; i++)
  9847. {
  9848. var dac = dac3[i];
  9849. if (dac == null) continue;
  9850. builder.MoveToCell(2, i, 0, 0);
  9851. builder.Write("第" + dac.Days.ToString() + "天:");
  9852. builder.MoveToCell(2, i, 1, 0);
  9853. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  9854. builder.MoveToCell(2, i, 2, 0);
  9855. builder.Write("费用标准:");
  9856. string curr = "";
  9857. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  9858. if (currData != null)
  9859. {
  9860. curr = currData.Name;
  9861. }
  9862. builder.MoveToCell(2, i, 3, 0);
  9863. builder.Write(dac.Cost.ToString("#0.00") + curr);
  9864. builder.MoveToCell(2, i, 4, 0);
  9865. builder.Write("费用小计:");
  9866. builder.MoveToCell(2, i, 5, 0);
  9867. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  9868. }
  9869. //删除多余行
  9870. while (table3.Rows.Count > table3Row)
  9871. {
  9872. table3.Rows.RemoveAt(table3Row);
  9873. }
  9874. #endregion
  9875. }
  9876. else dic.Add("SubGZF", "0.00");
  9877. //删除多余行
  9878. while (table3.Rows.Count > table3Row)
  9879. {
  9880. table3.Rows.RemoveAt(table3Row);
  9881. }
  9882. //培训费
  9883. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  9884. if (_EnterExitCosts.ChoiceSix == 1)
  9885. {
  9886. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  9887. dic.Add("SubPX", pxStr);
  9888. table4Row = dac4.Count;
  9889. #region 填充word表格内容
  9890. for (int i = 0; i < dac4.Count; i++)
  9891. {
  9892. var dac = dac4[i];
  9893. if (dac == null) continue;
  9894. builder.MoveToCell(3, i, 0, 0);
  9895. builder.Write("第" + dac.Days.ToString() + "天:");
  9896. builder.MoveToCell(3, i, 1, 0);
  9897. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  9898. builder.MoveToCell(3, i, 2, 0);
  9899. builder.Write("费用标准:");
  9900. string curr = "";
  9901. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  9902. if (currData != null)
  9903. {
  9904. curr = currData.Name;
  9905. }
  9906. builder.MoveToCell(3, i, 3, 0);
  9907. builder.Write(dac.Cost.ToString("#0.00") + curr);
  9908. builder.MoveToCell(3, i, 4, 0);
  9909. builder.Write("费用小计:");
  9910. builder.MoveToCell(3, i, 5, 0);
  9911. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  9912. }
  9913. #endregion
  9914. }
  9915. //else dic.Add("SubPX", $"六、培训费合计: 0 元/人");
  9916. //删除多余行
  9917. while (table4.Rows.Count > table4Row)
  9918. {
  9919. table4.Rows.RemoveAt(table4Row);
  9920. }
  9921. //其他费用
  9922. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  9923. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  9924. {
  9925. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  9926. dic.Add("titleQi", qtStr);
  9927. table5Row = dac5.Count;
  9928. #region 填充word表格内容
  9929. for (int i = 0; i < dac5.Count; i++)
  9930. {
  9931. var dac = dac5[i];
  9932. if (dac == null) continue;
  9933. builder.MoveToCell(4, i, 0, 0);
  9934. builder.Write("第" + dac.Index.ToString() + "项:");
  9935. builder.MoveToCell(4, i, 1, 0);
  9936. builder.Write(dac.itemName);
  9937. builder.MoveToCell(4, i, 2, 0);
  9938. builder.Write("费用标准:");
  9939. builder.MoveToCell(4, i, 3, 0);
  9940. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  9941. builder.MoveToCell(4, i, 4, 0);
  9942. builder.Write("费用小计:");
  9943. builder.MoveToCell(4, i, 5, 0);
  9944. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  9945. builder.MoveToCell(4, i, 6, 0);
  9946. builder.Write("备注:");
  9947. builder.MoveToCell(4, i, 7, 0);
  9948. builder.Write(dac.Remark);
  9949. }
  9950. #endregion
  9951. }
  9952. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  9953. //删除多余行
  9954. while (table5.Rows.Count > table5Row)
  9955. {
  9956. table5.Rows.RemoveAt(table5Row);
  9957. }
  9958. //加上其他费用
  9959. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  9960. decimal subJJC = 0.00M,
  9961. subGWC = 0.00M,
  9962. subTDC = 0.00M;
  9963. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  9964. string totalLabel = string.Format("全部费用总计:");
  9965. //经济舱
  9966. if (_EnterExitCosts.SumJJC == 1)
  9967. {
  9968. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  9969. totalLabel += $"{subJJC.ToString("#0.00")} 元/人(经济舱)";
  9970. }
  9971. //公务舱
  9972. if (_EnterExitCosts.SumGWC == 1)
  9973. {
  9974. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  9975. totalLabel += $"{subGWC.ToString("#0.00")} 元/人(公务舱)";
  9976. }
  9977. //头等舱
  9978. if (_EnterExitCosts.SumTDC == 1)
  9979. {
  9980. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  9981. totalLabel += $"{subTDC.ToString("#0.00")} 元/人(头等舱)";
  9982. }
  9983. //TotalLabel
  9984. dic.Add("TotalLabel", totalLabel);
  9985. #region 填充word模板书签内容
  9986. foreach (var key in dic.Keys)
  9987. {
  9988. Bookmark bookmark = doc.Range.Bookmarks[key];
  9989. if (bookmark != null)
  9990. {
  9991. builder.MoveToBookmark(key);
  9992. builder.Write(dic[key]);
  9993. }
  9994. }
  9995. #endregion
  9996. //文件名
  9997. string strFileName = $"{_EnterExitCosts.DraftName}_出入境费用-草稿{Guid.NewGuid().ToString()}.docx";
  9998. strFileName = CommonFun.ValidFileName(strFileName);
  9999. AsposeHelper.removewatermark_v2180();
  10000. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  10001. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  10002. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  10003. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  10004. }
  10005. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  10006. {
  10007. //获取模板
  10008. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  10009. //载入模板
  10010. Document doc = new Document(tempPath);
  10011. DocumentBuilder builder = new DocumentBuilder(doc);
  10012. Dictionary<string, string> dic = new Dictionary<string, string>();
  10013. string returnCodeLabel = string.Empty;
  10014. if (nationalTravelFeeData.Any())
  10015. {
  10016. List<string> list = new List<string>();
  10017. foreach (var item in nationalTravelFeeData)
  10018. {
  10019. list.Add($"{item.Country}({item.City})");
  10020. }
  10021. list = list.Distinct().ToList();
  10022. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  10023. }
  10024. var countryLabel = string.Empty;
  10025. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  10026. if (countryData.Any())
  10027. {
  10028. countryLabel = string.Join("、", countryData);
  10029. }
  10030. dic.Add("ReturnCodeAir", returnCodeLabel);
  10031. dic.Add("VisitStartDate", "-");
  10032. dic.Add("VisitEndDate", "-");
  10033. dic.Add("Day", "-");
  10034. dic.Add("VisitCountry", countryLabel);
  10035. dic.Add("ClientUnit", "-");
  10036. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  10037. //dic.Add("Names", Names);
  10038. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  10039. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  10040. decimal dac1totalPrice = 0.00M;
  10041. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  10042. foreach (var dac in dac1)
  10043. {
  10044. if (dac.SubTotal == 0.00M)
  10045. {
  10046. continue;
  10047. }
  10048. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  10049. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  10050. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  10051. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  10052. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  10053. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  10054. builder.Write(currency);//币种
  10055. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  10056. builder.Write(dac.Cost.ToString("#0.00"));//标准
  10057. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  10058. builder.Write("");//人数
  10059. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  10060. builder.Write("");//天数
  10061. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  10062. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  10063. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  10064. decimal rate = 0.00M;
  10065. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  10066. builder.Write(rate.ToString("#0.0000"));//汇率
  10067. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  10068. decimal rbmPrice = dac.SubTotal;
  10069. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  10070. accommodationStartIndex++;
  10071. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  10072. }
  10073. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  10074. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  10075. {
  10076. table1.Rows.RemoveAt(i - 1);
  10077. foodandotherStartIndex--;
  10078. }
  10079. if (dac2.Count == dac3.Count)//国家 币种 金额
  10080. {
  10081. for (int i = 0; i < dac2.Count; i++)
  10082. {
  10083. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  10084. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  10085. }
  10086. }
  10087. decimal dac2totalPrice = 0.00M;
  10088. foreach (var dac in dac2)
  10089. {
  10090. if (dac.SubTotal == 0)
  10091. {
  10092. continue;
  10093. }
  10094. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  10095. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  10096. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  10097. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  10098. builder.Write(currency);//币种
  10099. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  10100. builder.Write(dac.Cost.ToString("#0.00"));//标准
  10101. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  10102. builder.Write("");//人数
  10103. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  10104. builder.Write("");//天数
  10105. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  10106. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  10107. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  10108. decimal rate = 0.00M;
  10109. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  10110. builder.Write(rate.ToString("#0.0000"));//汇率
  10111. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  10112. decimal rbmPrice = dac.SubTotal;
  10113. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  10114. foodandotherStartIndex++;
  10115. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  10116. }
  10117. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  10118. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  10119. {
  10120. table1.Rows.RemoveAt(i - 1);
  10121. }
  10122. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  10123. string otherFeeStr = "";
  10124. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  10125. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  10126. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  10127. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  10128. foreach (var otherInfo in dac5)
  10129. {
  10130. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  10131. }
  10132. #endregion
  10133. if (otherFeeStr.Length > 0)
  10134. {
  10135. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  10136. otherFeeStr = $"({otherFeeStr})";
  10137. dic.Add("OtherFeeStr", otherFeeStr);
  10138. }
  10139. //总计
  10140. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  10141. //国际旅费
  10142. string outsideAir = string.Empty;
  10143. string allPriceAir = string.Empty;
  10144. if (_EnterExitCosts.SumJJC == 1)
  10145. {
  10146. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  10147. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  10148. }
  10149. if (_EnterExitCosts.SumGWC == 1)
  10150. {
  10151. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  10152. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  10153. }
  10154. if (_EnterExitCosts.SumTDC == 1)
  10155. {
  10156. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  10157. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  10158. }
  10159. dic.Add("InTravelPrice", $"({outsideAir})");
  10160. dic.Add("FinalSumPrice", $"({allPriceAir})");
  10161. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  10162. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  10163. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  10164. foreach (var key in dic.Keys)
  10165. {
  10166. builder.MoveToBookmark(key);
  10167. builder.Write(dic[key]);
  10168. }
  10169. //模板文件名
  10170. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  10171. strFileName = CommonFun.ValidFileName(strFileName);
  10172. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  10173. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  10174. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  10175. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  10176. }
  10177. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  10178. {
  10179. //获取模板
  10180. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  10181. //载入模板
  10182. WorkbookDesigner designer = new WorkbookDesigner();
  10183. designer.Workbook = new Workbook(tempPath);
  10184. Dictionary<string, string> dic = new Dictionary<string, string>();
  10185. string returnCodeLabel = string.Empty;
  10186. if (nationalTravelFeeData.Any())
  10187. {
  10188. List<string> list = new List<string>();
  10189. foreach (var item in nationalTravelFeeData)
  10190. {
  10191. list.Add($"{item.Country}({item.City})");
  10192. }
  10193. list = list.Distinct().ToList();
  10194. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  10195. }
  10196. var countryLabel = string.Empty;
  10197. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  10198. if (countryData.Any())
  10199. {
  10200. countryLabel = string.Join("、", countryData);
  10201. }
  10202. dic.Add("ReturnCodeAir", returnCodeLabel);
  10203. dic.Add("VisitStartDate", "-");
  10204. dic.Add("VisitEndDate", "-");
  10205. dic.Add("Day", "0");
  10206. dic.Add("VisitCountry", countryLabel);
  10207. dic.Add("ClientUnit", "-");
  10208. designer.SetDataSource("ClientUnit", "-");
  10209. designer.SetDataSource("VisitCountry", countryLabel);
  10210. designer.SetDataSource("Group", "-");
  10211. designer.SetDataSource("ClientUnitTitle", "-");
  10212. designer.SetDataSource("Name", "-");
  10213. designer.SetDataSource("VisitStartDate", "-");
  10214. designer.SetDataSource("Day", "0");
  10215. designer.SetDataSource("ReturnCode", returnCodeLabel);
  10216. designer.SetDataSource("ReturnCodeAir", "-");
  10217. int startIndex = 10;
  10218. const int startIndexcopy = 10;
  10219. if (dac2.Count == dac3.Count)//国家 币种 金额
  10220. {
  10221. for (int i = 0; i < dac2.Count; i++)
  10222. {
  10223. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  10224. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  10225. }
  10226. }
  10227. DataTable dtdac1 = new DataTable();
  10228. List<string> place = new List<string>();
  10229. dtdac1.Columns.AddRange(new DataColumn[] {
  10230. new DataColumn(){ ColumnName = "city"},
  10231. new DataColumn(){ ColumnName = "curr"},
  10232. new DataColumn(){ ColumnName = "criterion"},
  10233. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  10234. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  10235. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  10236. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  10237. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  10238. });
  10239. DataTable dtdac2 = new DataTable();
  10240. dtdac2.Columns.AddRange(new DataColumn[] {
  10241. new DataColumn(){ ColumnName = "city"},
  10242. new DataColumn(){ ColumnName = "curr"},
  10243. new DataColumn(){ ColumnName = "criterion"},
  10244. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  10245. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  10246. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  10247. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  10248. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  10249. });
  10250. dtdac1.TableName = "tb1";
  10251. dtdac2.TableName = "tb2";
  10252. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  10253. foreach (var item in dac1)
  10254. {
  10255. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  10256. if (place.Contains(item.Place))
  10257. {
  10258. continue;
  10259. }
  10260. DataRow row = dtdac1.NewRow();
  10261. row["city"] = item.Place;
  10262. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  10263. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  10264. row["curr"] = currency;
  10265. row["rate"] = rate.ToString("#0.0000");
  10266. row["criterion"] = item.Cost.ToString("#0.00");
  10267. row["number"] = 1;
  10268. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  10269. //row["costRMB"] = rbmPrice;
  10270. dtdac1.Rows.Add(row);
  10271. place.Add(item.Place);
  10272. }
  10273. place = new List<string>();
  10274. foreach (var item in dac2)
  10275. {
  10276. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  10277. if (place.Contains(item.Place))
  10278. {
  10279. continue;
  10280. }
  10281. DataRow row = dtdac2.NewRow();
  10282. row["city"] = item.Place;
  10283. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  10284. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  10285. row["curr"] = currency;
  10286. row["rate"] = rate.ToString("#0.0000");
  10287. row["criterion"] = item.Cost.ToString("#0.00");
  10288. row["number"] = 1;
  10289. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  10290. //row["cost"] = item.SubTotal;
  10291. //row["costRMB"] = rbmPrice;
  10292. dtdac2.Rows.Add(row);
  10293. place.Add(item.Place);
  10294. //dac2totalPrice += rbmPrice;
  10295. }
  10296. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  10297. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  10298. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  10299. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  10300. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic:#0.00} 元");
  10301. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic:#0.00} ");
  10302. string cell4Str1 = string.Empty;
  10303. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ:#0.00} 元/人;";
  10304. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW:#0.00} 元/人;";
  10305. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD:#0.00} 元/人;";
  10306. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  10307. string cellStr = $" 5.其他费用(";
  10308. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  10309. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  10310. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  10311. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  10312. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  10313. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  10314. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  10315. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  10316. foreach (var otherInfo in dac5)
  10317. {
  10318. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal:#0.00} 元,";
  10319. }
  10320. #endregion
  10321. if (cellStr.Length > 8)
  10322. {
  10323. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  10324. }
  10325. cellStr += ")";
  10326. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  10327. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  10328. decimal pxFee = dac4.Sum(it => it.Cost);
  10329. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  10330. string celllastStr1 = "";
  10331. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice:#0.00} 元";
  10332. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice:#0.00} 元";
  10333. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee:#0.00} 元";
  10334. celllastStr1 += $",国际旅费 元";
  10335. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee:#0.00} 元";
  10336. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  10337. designer.SetDataSource("cell4Str", cell4Str);
  10338. designer.SetDataSource("cellStr", cellStr);
  10339. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  10340. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  10341. designer.SetDataSource("celllastStr", celllastStr);
  10342. Workbook wb = designer.Workbook;
  10343. var sheet = wb.Worksheets[0];
  10344. //绑定datatable数据集
  10345. designer.SetDataSource(dtdac1);
  10346. designer.SetDataSource(dtdac2);
  10347. designer.Process();
  10348. var rowStart = dtdac1.Rows.Count;
  10349. while (rowStart > 0)
  10350. {
  10351. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  10352. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  10353. startIndex++;
  10354. rowStart--;
  10355. }
  10356. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  10357. startIndex += 1; //总计行
  10358. rowStart = dtdac2.Rows.Count;
  10359. while (rowStart > 0)
  10360. {
  10361. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  10362. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  10363. startIndex++;
  10364. rowStart--;
  10365. }
  10366. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  10367. wb.CalculateFormula(true);
  10368. //模板文件名
  10369. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  10370. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  10371. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  10372. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  10373. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  10374. }
  10375. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  10376. {
  10377. //获取模板
  10378. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  10379. //载入模板
  10380. Document doc = new Document(tempPath);
  10381. DocumentBuilder builder = new DocumentBuilder(doc);
  10382. Dictionary<string, string> dic = new Dictionary<string, string>();
  10383. dic.Add("GroupName", "-");
  10384. dic.Add("ClientUnit", "-");
  10385. //string missionLeader = ""; //团负责人默认接团客户名单第一个人
  10386. //string missionLeaderJob = "";//负责人job
  10387. //int groupNumber = 0; //团人数
  10388. dic.Add("MissionLeader", "-"); //团负责人
  10389. dic.Add("MissionLeaderJob", "-"); //团负责人job
  10390. dic.Add("GroupNumber", "0"); //团人数
  10391. dic.Add("Day", "0");
  10392. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  10393. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  10394. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  10395. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  10396. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  10397. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  10398. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  10399. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  10400. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  10401. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  10402. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  10403. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  10404. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  10405. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  10406. //其他费用
  10407. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  10408. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  10409. //其他费用合计
  10410. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  10411. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  10412. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  10413. //公务舱合计
  10414. //国际旅费
  10415. //string outsideJJ = "";
  10416. //string allPriceJJ = "";
  10417. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  10418. {
  10419. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  10420. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  10421. }
  10422. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  10423. {
  10424. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  10425. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  10426. }
  10427. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  10428. {
  10429. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ:#0.00} 公务舱:{_EnterExitCosts.AirGW:#0.00}");
  10430. dic.Add("AirFeeTotal", airFeeTotalStr);
  10431. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal:#0.00} 公务舱:{_gwcFeeToatal:#0.00}");
  10432. dic.Add("FeeTotal", feeTotalStr);
  10433. }
  10434. foreach (var key in dic.Keys)
  10435. {
  10436. builder.MoveToBookmark(key);
  10437. builder.Write(dic[key]);
  10438. }
  10439. //模板文件名
  10440. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  10441. strFileName = CommonFun.ValidFileName(strFileName);
  10442. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  10443. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  10444. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  10445. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  10446. }
  10447. }
  10448. else if (dto.ExportType == 2) //表格
  10449. {
  10450. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  10451. }
  10452. else if (dto.ExportType == 3)
  10453. {
  10454. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  10455. }
  10456. return Ok(JsonView(400, "只可导出明细表!", ""));
  10457. }
  10458. catch (Exception ex)
  10459. {
  10460. return Ok(JsonView(400, ex.Message, ""));
  10461. }
  10462. }
  10463. /// <summary>
  10464. /// 获取三公费用标准city
  10465. /// </summary>
  10466. /// <param name="placeData"></param>
  10467. /// <param name="nationalTravelFeeId"></param>
  10468. /// <returns></returns>
  10469. private string GetEnterExitCostDraftExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  10470. {
  10471. string _city = string.Empty;
  10472. if (!placeData.Any()) return _city;
  10473. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  10474. if (data == null) return _city;
  10475. string country = data.Country;
  10476. string city = data.City;
  10477. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  10478. else _city = city;
  10479. return _city;
  10480. }
  10481. /// <summary>
  10482. /// 团组模块 - 出入境费用-草稿 - 一键清空
  10483. /// </summary>
  10484. /// <returns></returns>
  10485. [HttpPost]
  10486. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  10487. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10488. public async Task<IActionResult> EnterExitCostDraftOneClickEmpty(EnterExitCostDraftOneClickEmptyDto dto)
  10489. {
  10490. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  10491. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  10492. var _view = await _enterExitCostDraftRep.OneClickEmpty(dto.Id, dto.UserId);
  10493. if (_view.Code == 0)
  10494. {
  10495. return Ok(JsonView(true, "操作成功"));
  10496. }
  10497. return Ok(JsonView(false, "操作失败"));
  10498. }
  10499. /// <summary>
  10500. /// 团组模块 - 出入境费用-草稿 - 子项删除
  10501. /// </summary>
  10502. /// <returns></returns>
  10503. [HttpPost]
  10504. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  10505. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10506. public async Task<IActionResult> EnterExitCostDraftSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  10507. {
  10508. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  10509. if (data.Code != 0)
  10510. {
  10511. return Ok(JsonView(false, data.Msg));
  10512. }
  10513. return Ok(JsonView(true, "操作成功!", data.Data));
  10514. }
  10515. /// <summary>
  10516. /// 三公其他费用草稿 删除
  10517. /// </summary>
  10518. /// <param name="dto"></param>
  10519. /// <returns></returns>
  10520. [HttpPost]
  10521. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  10522. public IActionResult EnterExitCostDraftOtherExpensesDel(EnterExitCostDraftOtherExpensesDelDto dto)
  10523. {
  10524. var jw = JsonView(false, "删除失败!");
  10525. var data = new Grp_DayOtherPriceDraft()
  10526. {
  10527. Id = dto.Id,
  10528. IsDel = 1,
  10529. DeleteUserId = dto.DeleteUserId,
  10530. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  10531. };
  10532. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  10533. if (del > 0)
  10534. {
  10535. jw.Code = 200;
  10536. jw.Msg = "删除成功!";
  10537. }
  10538. return Ok(jw);
  10539. }
  10540. /// <summary>
  10541. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用基础数据
  10542. /// </summary>
  10543. /// <returns></returns>
  10544. [HttpPost]
  10545. public async Task<IActionResult> EnterExitCostDraftImportDataInit()
  10546. {
  10547. var jw = JsonView(false);
  10548. var groupNameDatas = await _groupRepository.EnterExitCostGroupNameAsync();
  10549. var draftDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0).OrderByDescending(x => x.CreateTime).Select(x => new { x.Id, x.DraftName }).ToListAsync();
  10550. jw.Code = StatusCodes.Status200OK;
  10551. jw.Msg = "操作成功!";
  10552. jw.Data = new { groupNameDatas = groupNameDatas, draftNames = draftDatas };
  10553. return Ok(jw);
  10554. }
  10555. /// <summary>
  10556. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用
  10557. /// </summary>
  10558. /// <param name="dto"></param>
  10559. /// <returns></returns>
  10560. [HttpPost]
  10561. public async Task<IActionResult> EnterExitCostDraftImportData(EnterExitCostDraftImportDataDto dto)
  10562. {
  10563. int userId = dto.UserId,
  10564. portId = dto.PortType,
  10565. groupId = dto.GroupId,
  10566. draftId = dto.DraftId;
  10567. _portTypeData.Add(1);
  10568. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10569. if (!_portTypeData.Contains(portId)) return Ok(JsonView(false, MsgTips.Port));
  10570. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId!"));
  10571. if (draftId < 1) return Ok(JsonView(false, "请传入有效的DraftId!"));
  10572. _sqlSugar.BeginTran();
  10573. try
  10574. {
  10575. var draftDatas = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).First();
  10576. if (draftDatas == null)
  10577. {
  10578. _sqlSugar.RollbackTran();
  10579. return Ok(JsonView(false, "草稿数据为空,不可导入!"));
  10580. }
  10581. //验证可覆盖已有数据 两边创建人需为同一人;
  10582. int draftCreateUserId = draftDatas.CreateUserId,
  10583. formalCreateUserId = 0;
  10584. var formalData = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  10585. if (formalData != null)
  10586. {
  10587. formalCreateUserId = formalData.CreateUserId;
  10588. if (draftCreateUserId != formalCreateUserId)
  10589. {
  10590. _sqlSugar.RollbackTran();
  10591. return Ok(JsonView(false, "由草稿数据到入至正式数据,两边创建人为同一人才可导入正式版!"));
  10592. }
  10593. }
  10594. //默认添加查看、编辑权限(创建人、自己)
  10595. await _enterExitCostRep.InitPerm(dto.GroupId, dto.UserId);
  10596. var dayDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  10597. var otherDatas = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  10598. var newExterData = _mapper.Map<Grp_EnterExitCost>(draftDatas);
  10599. newExterData.DiId = groupId;
  10600. newExterData.CreateUserId = userId;
  10601. newExterData.Remark = $"由草稿数据导入;草稿数Id:{draftId}";
  10602. var newDayDatas = _mapper.Map<List<Grp_DayAndCost>>(dayDatas);
  10603. if (newDayDatas.Any()) newDayDatas.Select(x => { x.DiId = groupId; x.CreateUserId = userId; return x; }).ToList();
  10604. var newOtherDatas = _mapper.Map<List<Grp_DayOtherPrice>>(otherDatas);
  10605. if (newOtherDatas.Any()) newOtherDatas.Select(x => { x.Diid = groupId; x.CreateUserId = userId; return x; }).ToList();
  10606. var enterExitCostInfo = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  10607. //数据如果存在执行删除
  10608. if (enterExitCostInfo != null)
  10609. {
  10610. _sqlSugar.Updateable<Grp_EnterExitCost>()
  10611. .SetColumns(x => new Grp_EnterExitCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Remark = "由草稿数据导入前软删除数据!" })
  10612. .Where(x => x.Id == enterExitCostInfo.Id)
  10613. .ExecuteCommand();
  10614. _sqlSugar.Updateable<Grp_DayAndCost>()
  10615. .SetColumns(x => new Grp_DayAndCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  10616. .Where(x => x.DiId == groupId)
  10617. .ExecuteCommand();
  10618. _sqlSugar.Updateable<Grp_DayOtherPrice>()
  10619. .SetColumns(x => new Grp_DayOtherPrice() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  10620. .Where(x => x.Diid == groupId)
  10621. .ExecuteCommand();
  10622. _sqlSugar.Updateable<Grp_EnterExitCostPermission>()
  10623. .SetColumns(x => new Grp_EnterExitCostPermission() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  10624. .Where(x => x.GroupId == groupId)
  10625. .ExecuteCommand();
  10626. }
  10627. //执行insert
  10628. var insertId = _sqlSugar.Insertable(newExterData).ExecuteReturnIdentity();
  10629. if (insertId < 1)
  10630. {
  10631. _sqlSugar.RollbackTran();
  10632. return Ok(JsonView(false, "草稿数据导入失败!"));
  10633. }
  10634. if (newDayDatas.Any()) _sqlSugar.Insertable(newDayDatas).ExecuteCommand();
  10635. if (newOtherDatas.Any()) _sqlSugar.Insertable(newOtherDatas).ExecuteCommand();
  10636. #region 默认添加权限
  10637. #endregion
  10638. _sqlSugar.CommitTran();
  10639. //执行操作之后
  10640. //生成默认文件pdf并且通知人员
  10641. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  10642. {
  10643. DiId = groupId,
  10644. ExportType = 1,
  10645. SubTypeId = 1005
  10646. }, "pdf");
  10647. //发送通知
  10648. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  10649. string md5Sign = GeneralMethod.Encrypt($"{insertId}&fileName={fileUrl}");
  10650. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", insertId, fileUrl);
  10651. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(groupId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  10652. //汇率信息记录
  10653. await GeneralMethod.RateRecordSave(userId, insertId, "出入境费用-草稿导入");
  10654. return Ok(JsonView(true));
  10655. }
  10656. catch (Exception ex)
  10657. {
  10658. _sqlSugar.RollbackTran();
  10659. return Ok(JsonView(false, ex.Message));
  10660. }
  10661. }
  10662. #endregion
  10663. #region 团组经理模块 出入境费用 移动端(Android/IOS)
  10664. /// <summary>
  10665. /// 获取币种基础数据(含逻辑处理)
  10666. /// </summary>
  10667. /// <returns></returns>
  10668. private async Task<List<CurrencyInfo>> EnterExitCostMobileGetCurrencyInit()
  10669. {
  10670. return await GeneralMethod.EnterExitCostInitRate();
  10671. }
  10672. /// <summary>
  10673. /// 团组模块 - 出入境费用-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  10674. /// </summary>
  10675. /// <returns></returns>
  10676. [HttpPost]
  10677. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10678. public async Task<IActionResult> EnterExitCostMobileDataSource(EnterExitCostMobileDataSourceDto dto)
  10679. {
  10680. //验证城市归属并给默认值
  10681. int provinceId = dto.ProvinceId;
  10682. if (provinceId < 1) provinceId = 122;
  10683. var dataSource = await _sqlSugar
  10684. .Queryable<Sys_SetData>()
  10685. .Where(x => x.IsDel == 0 && (x.STid == 72 || x.STid == 73) && x.Remark.Contains(provinceId.ToString()))
  10686. .ToListAsync();
  10687. var fileTypes = new List<EecSetDataInfoView>();
  10688. //三公费用-Word明细类型
  10689. var wordTypeData = dataSource
  10690. .Where(it => it.STid == 72)
  10691. .Select(x => new EecSetDataInfoView
  10692. {
  10693. ParentId = 1,
  10694. Id = x.Id,
  10695. Name = x.Name
  10696. })
  10697. .ToArray();
  10698. if (wordTypeData.Any()) fileTypes.AddRange(wordTypeData);
  10699. var excelTypeData = dataSource
  10700. .Where(it => it.STid == 73)
  10701. .Select(x => new EecSetDataInfoView
  10702. {
  10703. ParentId = 2,
  10704. Id = x.Id,
  10705. Name = x.Name
  10706. })
  10707. .ToArray();
  10708. if (excelTypeData.Any()) fileTypes.AddRange(excelTypeData);
  10709. var groupNameList = new EecSetDataInfoView() { ParentId = 3, Id = 1, Name = "团组成员名单" };
  10710. fileTypes.Add(groupNameList);
  10711. fileTypes = fileTypes.OrderBy(x => x.ParentId).ThenBy(x => x.Id).ToList();
  10712. //默认币种显示
  10713. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  10714. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  10715. return Ok(JsonView(true, "查询成功!", new
  10716. {
  10717. FileTypeData = fileTypes,
  10718. CurrencyInit = _currencyInfos,
  10719. viewPermissionData = viewPermissionData
  10720. }));
  10721. }
  10722. /// <summary>
  10723. /// 团组模块 - 出入境费用-移动端 - 团组基础数据Data
  10724. /// </summary>
  10725. /// <returns></returns>
  10726. [HttpPost]
  10727. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10728. public async Task<IActionResult> EnterExitCostMobileGroupData(PostEnterExitCostMobileGroupDataDto dto)
  10729. {
  10730. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10731. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10732. RefAsync<int> total = 0;
  10733. int diId = 0;
  10734. var status = int.TryParse(dto.GroupName, out diId);
  10735. var basicUserId = await _enterExitCostRep.PermissionViewUsersAsync();
  10736. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  10737. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  10738. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  10739. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  10740. .OrderByDescending(x => x.VisitStartDate)
  10741. .Select(x => new EnterExitCostMobileGroupView()
  10742. {
  10743. Id = x.Id,
  10744. GroupName = x.TeamName,
  10745. IsNull = SqlFunc.Subqueryable<Grp_EnterExitCost>().Where(x1 => x1.DiId == x.Id && x1.IsDel == 0).Any() ? false : true,
  10746. IsView = SqlFunc.Subqueryable<Grp_EnterExitCostPermission>().Where(x1 => x1.GroupId == x.Id && x1.UserId == dto.CurrUserId).Any(),
  10747. ProvinceId = x.CityId
  10748. })
  10749. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10750. //处理省份Id
  10751. if (data.Any())
  10752. {
  10753. var provCityDatas = await _groupRepository.ProvinceCityBasicSource();
  10754. if (provCityDatas.Any())
  10755. {
  10756. foreach (var item in data)
  10757. {
  10758. var provinceId = item.ProvinceId;
  10759. var isDefualtVal = true;
  10760. if (provinceId > 0)
  10761. {
  10762. var parentId = _groupRepository.FindParentIdByChildId(provCityDatas, provinceId);
  10763. if (parentId != null)
  10764. {
  10765. isDefualtVal = false;
  10766. item.ProvinceId = (int)parentId;
  10767. }
  10768. }
  10769. if (isDefualtVal)
  10770. {
  10771. item.ProvinceId = 122; //默认四川
  10772. }
  10773. }
  10774. }
  10775. }
  10776. //处理是否显示
  10777. if (basicUserId.Any(x => x.Id == dto.CurrUserId))
  10778. {
  10779. foreach (var item in data)
  10780. {
  10781. item.IsView = true;
  10782. }
  10783. }
  10784. return Ok(JsonView(true, "查询成功!", data, total));
  10785. }
  10786. /// <summary>
  10787. /// 团组模块 - 出入境费用-移动端 - 币种基础数据Data
  10788. /// </summary>
  10789. /// <returns></returns>
  10790. [HttpPost]
  10791. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10792. public async Task<IActionResult> EnterExitCostMobileCurrencyData(PostEnterExitCostMobileCurrencyDataDto dto)
  10793. {
  10794. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10795. RefAsync<int> total = 0;
  10796. var data = await _sqlSugar.Queryable<Sys_SetData>()
  10797. .Where(x => x.IsDel == 0 && x.STid == 66)
  10798. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  10799. .Select(x => new
  10800. {
  10801. id = x.Id,
  10802. name = x.Name,
  10803. remark = x.Remark,
  10804. })
  10805. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10806. return Ok(JsonView(true, "查询成功!", data, total));
  10807. }
  10808. /// <summary>
  10809. /// 团组模块 - 出入境费用-移动端 - 其他款项 - 币种、费用类型基础数据Data
  10810. /// </summary>
  10811. /// <returns></returns>
  10812. [HttpPost]
  10813. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10814. public async Task<IActionResult> EnterExitCostMobileOtherItemCurrencyData(PostEnterExitCostMobileOtherItemCurrencyDataDto dto)
  10815. {
  10816. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10817. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10818. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType, dto.DiId, 98);
  10819. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  10820. var groupOtherRateData = groupRateData.TeamRates;
  10821. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  10822. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  10823. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  10824. groupOtherRateData = groupOtherRateData
  10825. .Select(x => new TeamRateDescAddCurrencyIdView
  10826. {
  10827. CurrencyId = x.CurrencyId,
  10828. CurrencyName = x.CurrencyName,
  10829. CurrencyCode = x.CurrencyCode,
  10830. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  10831. }).ToList();
  10832. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  10833. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  10834. }
  10835. /// <summary>
  10836. /// 团组模块 - 出入境费用-移动端 - 实时汇率、签证费用、机票费用 Tips
  10837. /// </summary>
  10838. /// <returns></returns>
  10839. [HttpPost]
  10840. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10841. public async Task<IActionResult> EnterExitCostMobileFeeTips(GetEnterExitCostMobileFeeTipsDto dto)
  10842. {
  10843. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10844. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10845. var tipsData = new List<int>() { 1, 2, 3 };
  10846. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  10847. if (dto.TipsType == 1)
  10848. {
  10849. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  10850. }
  10851. else if (dto.TipsType == 2)
  10852. {
  10853. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.GroupId);
  10854. return Ok(JsonView(true, "查询成功!", visaData.Data));
  10855. }
  10856. else if (dto.TipsType == 3)
  10857. {
  10858. var airData = await GeneralMethod.EntryAndExitTips(dto.GroupId);
  10859. return Ok(JsonView(true, "查询成功!", airData));
  10860. }
  10861. return Ok(JsonView(false));
  10862. }
  10863. /// <summary>
  10864. /// 团组模块 - 出入境国家费用标准-移动端 List
  10865. /// </summary>
  10866. /// <returns></returns>
  10867. [HttpPost]
  10868. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10869. public async Task<IActionResult> NationalTravelFeeMobileData(PostNationalTravelFeeMobileDataDto dto)
  10870. {
  10871. Stopwatch sw = new Stopwatch();
  10872. sw.Start();
  10873. int provinceId = dto.ProvinceId;
  10874. if (provinceId < 1) provinceId = 122; // 默认四川
  10875. RefAsync<int> total = 0;
  10876. var data = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  10877. .LeftJoin<Sys_SetData>((ntf, sd) => ntf.Currency == sd.Id)
  10878. .LeftJoin<Sys_Users>((ntf, sd, u) => ntf.CreateUserId == u.Id)
  10879. .LeftJoin<Sys_Cities>((ntf, sd, u, sd1) => ntf.ProvinceId == sd1.Id)
  10880. .Where((ntf, sd, u, sd1) => ntf.IsDel == 0 && ntf.ProvinceId == provinceId)
  10881. .WhereIF(!string.IsNullOrEmpty(dto.Search), (ntf, sd, u, sd1) => dto.Search.Contains(ntf.Country) || dto.Search.Contains(ntf.City))
  10882. .Select((ntf, sd, u, sd1) => new
  10883. {
  10884. Id = ntf.Id,
  10885. Area = $"{ntf.Country}-{ntf.City}",
  10886. Currency = ntf.Currency,
  10887. CurrencyCode = sd.Name,
  10888. CurrencyName = sd.Remark,
  10889. RoomCost = ntf.RoomCost,
  10890. FoodCost = ntf.FoodCost,
  10891. PublicCost = ntf.PublicCost,
  10892. TrainCost = ntf.TrainCost,
  10893. LastUpdateUserId = ntf.LastUpdateUserId,
  10894. LastUpdateUserName = u.CnName,
  10895. LastUpdateTime = ntf.LastUpdateTime
  10896. })
  10897. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10898. sw.Stop();
  10899. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", data, total));
  10900. }
  10901. /// <summary>
  10902. /// 团组模块 - 出入境费用-移动端 - Info
  10903. /// </summary>
  10904. /// <returns></returns>
  10905. [HttpPost]
  10906. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10907. public async Task<IActionResult> EnterExitCostMobileInfo(EnterExitCostInfobyDiIdDto dto)
  10908. {
  10909. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10910. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10911. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  10912. return Ok(data);
  10913. }
  10914. /// <summary>
  10915. /// 团组模块 - 出入境费用-移动端 - ParentInfo
  10916. /// </summary>
  10917. /// <returns></returns>
  10918. [HttpPost]
  10919. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10920. public async Task<IActionResult> EnterExitCostMobileParentInfo(EnterExitCostInfobyDiIdDto dto)
  10921. {
  10922. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10923. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10924. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10925. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  10926. var mobileInfo = new EnterExitCostMobileParentInfoView();
  10927. mobileInfo.DiId = dto.DiId;
  10928. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  10929. if (eecInfo == null) return Ok(mobileInfo);
  10930. //验证查看权限
  10931. (bool isView, bool isSet) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);
  10932. if (!isView) return Ok(JsonView(false, "没有查看权限!"));
  10933. mobileInfo = _mapper.Map<EnterExitCostMobileParentInfoView>(eecInfo);
  10934. mobileInfo.IsAssignPerm = isSet;
  10935. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCost>()
  10936. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10937. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10938. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  10939. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  10940. {
  10941. SubId = dac.Id,
  10942. DiId = dac.DiId,
  10943. Type = dac.Type,
  10944. Days = dac.Days,
  10945. NationalTravelFeeId = dac.NationalTravelFeeId,
  10946. Arae = $"{ntf.Country}-{ntf.City}",
  10947. Cost = dac.Cost,
  10948. Currency = dac.Currency,
  10949. CurrencyName = sd.Name,
  10950. SubTotal = dac.SubTotal,
  10951. })
  10952. .ToList();
  10953. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  10954. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  10955. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  10956. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  10957. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  10958. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  10959. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  10960. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  10961. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  10962. //其他款项
  10963. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  10964. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  10965. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  10966. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  10967. .OrderBy((dop, sd1, sd2) => dop.Index)
  10968. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  10969. {
  10970. SubId = dop.Id,
  10971. DiId = dop.Diid,
  10972. Index = dop.Index,
  10973. SetDataId = dop.SetDataId,
  10974. SetDataName = sd1.Name,
  10975. Cost = dop.Cost,
  10976. Currency = dop.Currency,
  10977. CurrencyName = sd2.Remark,
  10978. SubTotal = dop.SubTotal,
  10979. Remark = dop.Remark,
  10980. })
  10981. .ToArray();
  10982. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  10983. return Ok(mobileInfo);
  10984. }
  10985. /// <summary>
  10986. /// 团组模块 - 出入境费用-移动端 - 查看权限用户
  10987. /// </summary>
  10988. /// <returns></returns>
  10989. [HttpPost]
  10990. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10991. public async Task<IActionResult> EnterExitCostMobileViewPermissionUsers(EnterExitCostMobileViewPermissionUsersDto dto)
  10992. {
  10993. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10994. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10995. //验证查看权限
  10996. (bool viewPerm, bool assignPerm) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);//分配权限
  10997. if (!viewPerm) return Ok(JsonView(false, "未分配查看权限,如要查看,请联系市场部或国交部负责人!"));
  10998. var userIds = await _sqlSugar
  10999. .Queryable<Grp_EnterExitCostPermission>()
  11000. .Where(x => x.IsDel == 0 && x.GroupId == dto.DiId)
  11001. .Select(x => x.UserId)
  11002. .ToArrayAsync();
  11003. var perUsers = await _enterExitCostRep.PermissionViewUsersAsync();
  11004. var perUsersView = new List<dynamic>();
  11005. foreach (var item in perUsers)
  11006. {
  11007. bool isView1 = false;
  11008. if (userIds.Any(x => x == item.Id)) isView1 = true;
  11009. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  11010. }
  11011. return Ok(JsonView(perUsersView));
  11012. }
  11013. /// <summary>
  11014. /// 团组模块 - 出入境费用-移动端 - SubInfo
  11015. /// </summary>
  11016. /// <returns></returns>
  11017. [HttpPost]
  11018. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11019. public async Task<IActionResult> EnterExitCostMobileSubInfo(PostEnterExitCostMobileSubInfoDto dto)
  11020. {
  11021. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11022. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11023. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11024. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  11025. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  11026. //验证查看权限
  11027. //(bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  11028. //if (!isView) return Ok(JsonView(false, msg));
  11029. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  11030. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  11031. var subType = dto.SubType;
  11032. if (subType == 1) //1:境内费用
  11033. {
  11034. var oneData = new ChoiceOneMobileSubInfoView()
  11035. {
  11036. Id = eecInfo.Id,
  11037. ChoiceOne = eecInfo.ChoiceOne,
  11038. ChoiceOneTotalCost = eecInfo.InsidePay,
  11039. Visa = eecInfo.Visa,
  11040. VisaRemark = eecInfo.VisaRemark,
  11041. YiMiao = eecInfo.YiMiao,
  11042. HeSuan = eecInfo.HeSuan,
  11043. Service = eecInfo.Service,
  11044. Ticket = eecInfo.Ticket,
  11045. Safe = eecInfo.Safe,
  11046. FirstItemRemark = eecInfo.FirstItemRemark
  11047. };
  11048. return Ok(JsonView(oneData));
  11049. }
  11050. else if (subType == 2) //2:国际旅费
  11051. {
  11052. var twoData = new ChoiceTwoMobileSubInfoView()
  11053. {
  11054. Id = eecInfo.Id,
  11055. ChoiceTwoJJ = eecInfo.SumJJC,
  11056. OutsideJJPay = eecInfo.OutsideJJPay,
  11057. ChoiceTwoGW = eecInfo.SumGWC,
  11058. OutsideGWPay = eecInfo.OutsideGWPay,
  11059. ChoiceTwoTD = eecInfo.SumTDC,
  11060. OutsideTDPay = eecInfo.OutsideTDPay,
  11061. AirJJ = eecInfo.AirJJ,
  11062. AirGW = eecInfo.AirGW,
  11063. AirTD = eecInfo.AirTD,
  11064. CityTranffic = eecInfo.CityTranffic,
  11065. CityTranffic1 = eecInfo.CityTranffic1,
  11066. CityTranffic2 = eecInfo.CityTranffic2,
  11067. TwoItemRemark = eecInfo.TwoItemRemark
  11068. };
  11069. return Ok(JsonView(twoData));
  11070. }
  11071. else if (subType == 3) //3:住宿费
  11072. {
  11073. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  11074. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  11075. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  11076. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 1)
  11077. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  11078. {
  11079. SubId = dac.Id,
  11080. DiId = dac.DiId,
  11081. Type = dac.Type,
  11082. Days = dac.Days,
  11083. NationalTravelFeeId = dac.NationalTravelFeeId,
  11084. Arae = $"{ntf.Country}-{ntf.City}",
  11085. Cost = dac.Cost,
  11086. Currency = dac.Currency,
  11087. CurrencyName = sd.Name,
  11088. SubTotal = dac.SubTotal,
  11089. })
  11090. .ToArray();
  11091. var data = new ChoiceMobileSubInfo3To6View()
  11092. {
  11093. ParentId = eecInfo.Id,
  11094. Choice = eecInfo.ChoiceThree,
  11095. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  11096. Details = dayAndCostDatas
  11097. };
  11098. return Ok(JsonView(data));
  11099. }
  11100. else if (subType == 4) //4:伙食费
  11101. {
  11102. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  11103. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  11104. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  11105. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 2)
  11106. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  11107. {
  11108. SubId = dac.Id,
  11109. DiId = dac.DiId,
  11110. Type = dac.Type,
  11111. Days = dac.Days,
  11112. NationalTravelFeeId = dac.NationalTravelFeeId,
  11113. Arae = $"{ntf.Country}-{ntf.City}",
  11114. Cost = dac.Cost,
  11115. Currency = dac.Currency,
  11116. CurrencyName = sd.Name,
  11117. SubTotal = dac.SubTotal,
  11118. })
  11119. .ToArray();
  11120. var data = new ChoiceMobileSubInfo3To6View()
  11121. {
  11122. ParentId = eecInfo.Id,
  11123. Choice = eecInfo.ChoiceFour,
  11124. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  11125. Details = dayAndCostDatas
  11126. };
  11127. return Ok(JsonView(data));
  11128. }
  11129. else if (subType == 5) //5:公杂费
  11130. {
  11131. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  11132. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  11133. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  11134. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 3)
  11135. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  11136. {
  11137. SubId = dac.Id,
  11138. DiId = dac.DiId,
  11139. Type = dac.Type,
  11140. Days = dac.Days,
  11141. NationalTravelFeeId = dac.NationalTravelFeeId,
  11142. Arae = $"{ntf.Country}-{ntf.City}",
  11143. Cost = dac.Cost,
  11144. Currency = dac.Currency,
  11145. CurrencyName = sd.Name,
  11146. SubTotal = dac.SubTotal,
  11147. })
  11148. .ToArray();
  11149. var data = new ChoiceMobileSubInfo3To6View()
  11150. {
  11151. ParentId = eecInfo.Id,
  11152. Choice = eecInfo.ChoiceFive,
  11153. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  11154. Details = dayAndCostDatas
  11155. };
  11156. return Ok(JsonView(data));
  11157. }
  11158. else if (subType == 6) //6:培训费
  11159. {
  11160. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  11161. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  11162. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  11163. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 4)
  11164. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  11165. {
  11166. SubId = dac.Id,
  11167. DiId = dac.DiId,
  11168. Type = dac.Type,
  11169. Days = dac.Days,
  11170. NationalTravelFeeId = dac.NationalTravelFeeId,
  11171. Arae = $"{ntf.Country}-{ntf.City}",
  11172. Cost = dac.Cost,
  11173. Currency = dac.Currency,
  11174. CurrencyName = sd.Name,
  11175. SubTotal = dac.SubTotal,
  11176. })
  11177. .ToArray();
  11178. var data = new ChoiceMobileSubInfo3To6View()
  11179. {
  11180. ParentId = eecInfo.Id,
  11181. Choice = eecInfo.ChoiceSix,
  11182. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  11183. Details = dayAndCostDatas
  11184. };
  11185. return Ok(JsonView(data));
  11186. }
  11187. else if (subType == 7) //7:其他
  11188. {
  11189. //其他款项
  11190. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  11191. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  11192. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  11193. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  11194. .OrderBy((dop, sd1, sd2) => dop.Index)
  11195. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  11196. {
  11197. SubId = dop.Id,
  11198. DiId = dop.Diid,
  11199. Index = dop.Index,
  11200. SetDataId = dop.SetDataId,
  11201. SetDataName = sd1.Name,
  11202. Cost = dop.Cost,
  11203. Currency = dop.Currency,
  11204. CurrencyName = sd2.Name,
  11205. SubTotal = dop.SubTotal,
  11206. Remark = dop.Remark,
  11207. })
  11208. .ToArray();
  11209. var data = new ChoiceSevenMobileSubInfoView()
  11210. {
  11211. ParentId = eecInfo.Id,
  11212. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  11213. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  11214. Details = otherData
  11215. };
  11216. return Ok(JsonView(data));
  11217. }
  11218. return Ok(JsonView(false));
  11219. }
  11220. #region op
  11221. ///// <summary>
  11222. ///// 移动端更新费用消息通知
  11223. ///// </summary>
  11224. ///// <param name="diid"></param>
  11225. ///// <param name="id"></param>
  11226. ///// <param name="currUserId"></param>
  11227. //private async Task EnterExitCostMobileOpNotice(int diid, int id, int currUserId)
  11228. //{
  11229. // try
  11230. // {
  11231. // ////生成默认文件pdf并且通知人员
  11232. // //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  11233. // //{
  11234. // // DiId = diid,
  11235. // // ExportType = 1,
  11236. // // SubTypeId = 1005
  11237. // //}, "pdf");
  11238. // ////发送通知
  11239. // //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  11240. // //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  11241. // //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  11242. // //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(diid, new List<string>() { "208", "233", "21" }, currUserId, url);
  11243. // ////汇率信息记录
  11244. // //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  11245. // }
  11246. // catch (Exception ex)
  11247. // {
  11248. // //记录日志
  11249. // throw;
  11250. // }
  11251. //}
  11252. /// <summary>
  11253. /// 验证出入境费用数据是否存在
  11254. /// 不存在添加
  11255. /// </summary>
  11256. /// <param name="diId"></param>
  11257. /// <param name="currUserId"></param>
  11258. /// <returns></returns>
  11259. /// <exception cref="CustomException"></exception>
  11260. private async Task<int> EnterExitCostVerifyIsNull(int diId, int currUserId)
  11261. {
  11262. var parentId = 0;
  11263. var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).OrderByDescending(x => x.CreateTime).FirstAsync();
  11264. if (info != null)
  11265. {
  11266. parentId = info.Id;
  11267. }
  11268. else
  11269. {
  11270. var currencys = await EnterExitCostMobileGetCurrencyInit();
  11271. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCost() { DiId = diId, CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  11272. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  11273. parentId = addId;
  11274. }
  11275. return parentId;
  11276. }
  11277. /// <summary>
  11278. /// 团组模块 - 出入境费用-移动端 - 设置view权限
  11279. /// </summary>
  11280. /// <returns></returns>
  11281. [HttpPost]
  11282. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11283. public async Task<IActionResult> EnterExitCostMobileSetViewPermissiion(EnterExitCostMobileSetViewPermissiionDto dto)
  11284. {
  11285. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11286. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11287. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  11288. //验证编辑权限
  11289. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  11290. //if (!isEdit) return Ok(JsonView(false, msg));
  11291. var permissions = new List<Grp_EnterExitCostPermission>();
  11292. foreach (var userId in dto.UserIds)
  11293. {
  11294. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = userId, CreateUserId = dto.CurrUserId });
  11295. }
  11296. if (permissions.Any())
  11297. {
  11298. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  11299. {
  11300. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  11301. }
  11302. _sqlSugar.BeginTran();
  11303. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.DiId).ExecuteCommandAsync();
  11304. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  11305. if (result < 1)
  11306. {
  11307. _sqlSugar.RollbackTran();
  11308. return Ok(JsonView(false));
  11309. }
  11310. _sqlSugar.CommitTran();
  11311. return Ok(JsonView(true));
  11312. }
  11313. return Ok(JsonView(false));
  11314. }
  11315. /// <summary>
  11316. /// 团组模块 - 出入境费用-移动端 - OP --> 汇率
  11317. /// </summary>
  11318. /// <returns></returns>
  11319. [HttpPost]
  11320. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11321. public async Task<IActionResult> EnterExitCostMobileOpRate(PostEnterExitCostMobileFeeRateOpDto dto)
  11322. {
  11323. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11324. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11325. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11326. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  11327. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  11328. int id = dto.Id;
  11329. if (id <= 0) //add
  11330. {
  11331. //int provinceId = dto.ProvinceId;
  11332. int groupId = dto.DiId;
  11333. //if (provinceId < 1) provinceId = 122;
  11334. var info = new Grp_EnterExitCost() { DiId = groupId, CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId };
  11335. info.LastUpdateUserId = dto.CurrUserId;
  11336. info.LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  11337. var add = await _sqlSugar.Insertable(info).ExecuteCommandAsync();
  11338. if (add < 1) return Ok(JsonView(false));
  11339. id = add;
  11340. }
  11341. else //update
  11342. {
  11343. ////验证编辑权限
  11344. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  11345. //if (!isEdit) return Ok(JsonView(false, msg));
  11346. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>().SetColumns(x => new Grp_EnterExitCost()
  11347. {
  11348. CurrencyRemark = currencyStr,
  11349. LastUpdateUserId = dto.CurrUserId,
  11350. LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  11351. }).Where(x => x.Id == dto.Id).ExecuteCommandAsync();
  11352. if (upd < 1) return Ok(JsonView(false));
  11353. }
  11354. #region 汇率变更时更改币种相关费用
  11355. var opDayCosts = new List<Grp_DayAndCost>();
  11356. var opDayOtherCosts = new List<Grp_DayOtherPrice>();
  11357. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  11358. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCost>()
  11359. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  11360. .Where((dac, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  11361. .Select((dac, sd) => new
  11362. {
  11363. dac.Id,
  11364. dac.DiId,
  11365. CurrencyCode = sd.Name,
  11366. dac.Cost
  11367. })
  11368. .ToList();
  11369. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  11370. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  11371. .Where((dop, sd) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  11372. .Select((dop, sd) => new
  11373. {
  11374. dop.Id,
  11375. dop.Diid,
  11376. CurrencyCode = sd.Name,
  11377. dop.Cost
  11378. })
  11379. .ToList();
  11380. if (dayCosts.Count > 0)
  11381. {
  11382. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  11383. foreach (var dc in new_dayCosts)
  11384. {
  11385. var thisCurrency = dc.Key.ToUpper();
  11386. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  11387. if (thisRate == 0.00M) continue;
  11388. foreach (var dcSub in dc)
  11389. {
  11390. opDayCosts.Add(new Grp_DayAndCost()
  11391. {
  11392. Id = dcSub.Id,
  11393. DiId = dcSub.DiId,
  11394. Cost = dcSub.Cost,
  11395. SubTotal = dcSub.Cost * thisRate,
  11396. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  11397. });
  11398. }
  11399. }
  11400. if (opDayCosts.Count > 0)
  11401. {
  11402. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  11403. }
  11404. }
  11405. if (dayOtherCosts.Count > 0)
  11406. {
  11407. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  11408. foreach (var dc in new_dayOtherCosts)
  11409. {
  11410. var thisCurrency = dc.Key.ToUpper();
  11411. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  11412. if (thisRate == 0.00M) continue;
  11413. foreach (var dcSub in dc)
  11414. {
  11415. opDayOtherCosts.Add(new Grp_DayOtherPrice()
  11416. {
  11417. Id = dcSub.Id,
  11418. Diid = dcSub.Diid,
  11419. Cost = dcSub.Cost,
  11420. SubTotal = dcSub.Cost * thisRate,
  11421. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  11422. });
  11423. }
  11424. }
  11425. if (opDayOtherCosts.Count > 0)
  11426. {
  11427. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  11428. }
  11429. }
  11430. #endregion
  11431. //消息通知
  11432. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11433. //汇率信息记录
  11434. await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  11435. return Ok(JsonView(new { parentId = id }));
  11436. }
  11437. /// <summary>
  11438. /// 团组模块 - 出入境费用-移动端 - OP --> 复选框
  11439. /// </summary>
  11440. /// <returns></returns>
  11441. [HttpPost]
  11442. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11443. public async Task<IActionResult> EnterExitCostMobileOpCheckbox(PostEnterExitCostMobileFeeOpCheckboxDto dto)
  11444. {
  11445. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11446. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11447. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11448. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11449. var checkboxInfo = _mapper.Map<Grp_EnterExitCost>(dto);
  11450. checkboxInfo.LastUpdateUserId = dto.CurrUserId;
  11451. checkboxInfo.LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  11452. int id = dto.Id;
  11453. if (id <= 0) //add
  11454. {
  11455. checkboxInfo.CreateUserId = dto.CurrUserId;
  11456. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11457. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  11458. if (add < 1) return Ok(JsonView(false));
  11459. }
  11460. else //update
  11461. {
  11462. ////验证编辑权限
  11463. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  11464. //if (!isEdit) return Ok(JsonView(false, msg));
  11465. var upd = await _sqlSugar.Updateable(checkboxInfo)
  11466. .UpdateColumns(x => new
  11467. {
  11468. x.ChoiceOne,
  11469. x.ChoiceTwo,
  11470. x.SumJJC,
  11471. x.SumGWC,
  11472. x.SumTDC,
  11473. x.ChoiceThree,
  11474. x.ChoiceFour,
  11475. x.ChoiceFive,
  11476. x.ChoiceSix,
  11477. x.OtherExpenses_Checked
  11478. })
  11479. .Where(x => x.Id == id)
  11480. .ExecuteCommandAsync();
  11481. if (upd < 1) return Ok(JsonView(false));
  11482. }
  11483. return Ok(JsonView(new { parentId = id }));
  11484. }
  11485. /// <summary>
  11486. /// 团组模块 - 出入境费用-移动端 - OP --> 3-7项复选框单个复选框更改
  11487. /// </summary>
  11488. /// <returns></returns>
  11489. [HttpPost]
  11490. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11491. public async Task<IActionResult> EnterExitCostMobileOpSingleCheckbox(EnterExitCostMobileOpSingleCheckboxDto dto)
  11492. {
  11493. int itemTypeId = dto.ItemType, id = dto.Id, currUserId = dto.CurrUserId, diId = dto.DiId, isSelected = dto.IsSelected;
  11494. // if (provinceId < 1) provinceId = 122;
  11495. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  11496. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11497. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11498. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11499. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  11500. var checkboxInfo = new Grp_EnterExitCost()
  11501. {
  11502. Id = id,
  11503. //ProvinceId = provinceId,
  11504. DiId = diId,
  11505. CreateUserId = currUserId,
  11506. LastUpdateUserId = dto.CurrUserId,
  11507. LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  11508. };
  11509. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  11510. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  11511. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  11512. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  11513. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  11514. if (id <= 0) //add
  11515. {
  11516. checkboxInfo.CreateUserId = dto.CurrUserId;
  11517. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11518. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  11519. if (add < 1) return Ok(JsonView(false));
  11520. }
  11521. else //update
  11522. {
  11523. ////验证编辑权限
  11524. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  11525. //if (!isEdit) return Ok(JsonView(false, msg));
  11526. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>()
  11527. .SetColumns(it => it.LastUpdateUserId == dto.CurrUserId)
  11528. .SetColumns(it => it.LastUpdateTime == DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
  11529. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  11530. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  11531. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  11532. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  11533. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  11534. .Where(x => x.Id == id)
  11535. .ExecuteCommandAsync();
  11536. if (upd < 1) return Ok(JsonView(false));
  11537. }
  11538. return Ok(JsonView(new { parentId = id }));
  11539. }
  11540. /// <summary>
  11541. /// 团组模块 - 出入境费用-移动端 - OP --> 境内费用 Step1
  11542. /// </summary>
  11543. /// <returns></returns>
  11544. [HttpPost]
  11545. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11546. public async Task<IActionResult> EnterExitCostMobileOpStep1(PostEnterExitCostMobileOpStep1Dto dto)
  11547. {
  11548. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11549. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11550. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11551. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11552. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  11553. info.FirstItemRemark = dto.FirstItemRemark;
  11554. info.LastUpdateUserId = dto.CurrUserId;
  11555. info.LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  11556. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  11557. int id = dto.Id;
  11558. if (id <= 0) //add
  11559. {
  11560. info.CreateUserId = dto.CurrUserId;
  11561. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11562. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  11563. if (add < 1) return Ok(JsonView(false));
  11564. id = add;
  11565. }
  11566. else //update
  11567. {
  11568. ////验证编辑权限
  11569. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  11570. //if (!isEdit) return Ok(JsonView(false, msg));
  11571. var upd = await _sqlSugar.Updateable(info)
  11572. .UpdateColumns(x => new
  11573. {
  11574. x.ChoiceOne,
  11575. x.InsidePay,
  11576. x.VisaRemark,
  11577. x.Visa,
  11578. x.Service,
  11579. x.Safe,
  11580. x.Ticket,
  11581. x.HeSuan,
  11582. x.YiMiao,
  11583. x.FirstItemRemark,
  11584. x.LastUpdateUserId,
  11585. x.LastUpdateTime
  11586. })
  11587. .Where(x => x.Id == id)
  11588. .ExecuteCommandAsync();
  11589. if (upd < 1) return Ok(JsonView(false));
  11590. }
  11591. //消息通知
  11592. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11593. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  11594. }
  11595. /// <summary>
  11596. /// 团组模块 - 出入境费用-移动端 - OP --> 国际旅费 Step2
  11597. /// </summary>
  11598. /// <returns></returns>
  11599. [HttpPost]
  11600. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11601. public async Task<IActionResult> EnterExitCostMobileOpStep2(PostEnterExitCostMobileOpStep2Dto dto)
  11602. {
  11603. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11604. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11605. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11606. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11607. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  11608. info.DiId = dto.DiId;
  11609. //info.ProvinceId = dto.ProvinceId;
  11610. info.OutsideJJPay = dto.OutsideJJPay;
  11611. info.OutsideGWPay = dto.OutsideGWPay;
  11612. info.OutsideTDPay = dto.OutsideTDPay;
  11613. info.AirJJ = dto.AirJJ;
  11614. info.AirGW = dto.AirGW;
  11615. info.AirTD = dto.AirTD;
  11616. info.CityTranffic = dto.CityTranffic;
  11617. info.CityTranffic1 = dto.CityTranffic1;
  11618. info.CityTranffic2 = dto.CityTranffic2;
  11619. info.TwoItemRemark = dto.TwoItemRemark;
  11620. info.SumJJC = dto.ChoiceTwoJJ;
  11621. info.SumGWC = dto.ChoiceTwoGW;
  11622. info.SumTDC = dto.ChoiceTwoTD;
  11623. info.LastUpdateUserId = dto.CurrUserId;
  11624. info.LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  11625. int id = dto.Id;
  11626. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  11627. if (id <= 0) //add i
  11628. {
  11629. info.CreateUserId = dto.CurrUserId;
  11630. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11631. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  11632. if (addId <= 0) return Ok(JsonView(false));
  11633. id = addId;
  11634. }
  11635. else //update
  11636. {
  11637. ////验证编辑权限
  11638. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  11639. //if (!isEdit) return Ok(JsonView(false, msg));
  11640. var upd = await _sqlSugar.Updateable(info)
  11641. .UpdateColumns(x => new
  11642. {
  11643. x.SumJJC,
  11644. x.OutsideJJPay,
  11645. x.SumGWC,
  11646. x.OutsideGWPay,
  11647. x.SumTDC,
  11648. x.OutsideTDPay,
  11649. x.AirJJ,
  11650. x.AirGW,
  11651. x.AirTD,
  11652. x.CityTranffic,
  11653. x.CityTranffic1,
  11654. x.CityTranffic2,
  11655. x.TwoItemRemark,
  11656. x.LastUpdateTime,
  11657. x.LastUpdateUserId
  11658. })
  11659. .Where(x => x.Id == id)
  11660. .ExecuteCommandAsync();
  11661. if (upd < 1) return Ok(JsonView(false));
  11662. }
  11663. jjcItemTotal = info.AirJJ + info.CityTranffic;
  11664. gwcItemTotal = info.AirGW + info.CityTranffic1;
  11665. tdcItemTotal = info.AirTD + info.CityTranffic2;
  11666. //消息通知
  11667. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11668. return Ok(JsonView(new
  11669. {
  11670. parentId = id,
  11671. choiceTwoJJ = dto.ChoiceTwoJJ,
  11672. jjcItemTotal = jjcItemTotal,
  11673. choiceTwoGW = dto.ChoiceTwoGW,
  11674. gwcItemTotal = gwcItemTotal,
  11675. choiceTwoTD = dto.ChoiceTwoTD,
  11676. tdcItemTotal = tdcItemTotal
  11677. }));
  11678. }
  11679. /// <summary>
  11680. /// 团组模块 - 出入境费用-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  11681. /// </summary>
  11682. /// <returns></returns>
  11683. [HttpPost]
  11684. [ApiExplorerSettings(IgnoreApi = true)]
  11685. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11686. public async Task<IActionResult> EnterExitCostMobileOpBatchStep3To6(PostEnterExitCostMobileOpStep3To6Dto dto)
  11687. {
  11688. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11689. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11690. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11691. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  11692. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  11693. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  11694. var infos1 = _mapper.Map<List<Grp_DayAndCost>>(dto.Infos);
  11695. var infos = infos1.Select(x => new Grp_DayAndCost
  11696. {
  11697. Id = x.Id,
  11698. DiId = dto.DiId,
  11699. Type = dto.FeeType,
  11700. Days = x.Days,
  11701. NationalTravelFeeId = x.NationalTravelFeeId,
  11702. Cost = x.Cost,
  11703. Currency = x.Currency,
  11704. SubTotal = x.SubTotal,
  11705. CreateUserId = dto.CurrUserId
  11706. })
  11707. .ToList();
  11708. var adds = infos.Where(x => x.Id <= 0).ToList();
  11709. var upds = infos.Where(x => x.Id > 0).ToList();
  11710. if (adds.Count > 0)
  11711. {
  11712. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  11713. if (add < 1) return Ok(JsonView(false));
  11714. }
  11715. if (upds.Count > 0)
  11716. {
  11717. var upd = await _sqlSugar.Updateable(adds)
  11718. .UpdateColumns(x => new
  11719. {
  11720. x.Days,
  11721. x.NationalTravelFeeId,
  11722. x.Cost,
  11723. x.Currency,
  11724. x.SubTotal
  11725. })
  11726. .WhereColumns(x => new { x.Id })
  11727. .ExecuteCommandAsync();
  11728. if (upd < 1) return Ok(JsonView(false));
  11729. }
  11730. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  11731. //消息通知
  11732. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  11733. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11734. return Ok(JsonView(new { itemTotal = itemTotal }));
  11735. }
  11736. /// <summary>
  11737. /// 团组模块 - 出入境费用-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  11738. /// </summary>
  11739. /// <returns></returns>
  11740. [HttpPost]
  11741. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11742. public async Task<IActionResult> EnterExitCostMobileOpSingleStep3To6(PostEnterExitCostMobileOpSingleStep3To6Dto dto)
  11743. {
  11744. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  11745. int subId = dto.SubId, feeType = dto.FeeType;
  11746. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11747. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11748. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11749. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  11750. var subInfo = _mapper.Map<Grp_DayAndCost>(dto);
  11751. subInfo.Id = subId;
  11752. subInfo.DiId = dto.DiId;
  11753. if (feeType == 3) subInfo.Type = 1;
  11754. else if (feeType == 4) subInfo.Type = 2;
  11755. else if (feeType == 5) subInfo.Type = 3;
  11756. else if (feeType == 6) subInfo.Type = 4;
  11757. subInfo.CreateUserId = dto.CurrUserId;
  11758. int parentId = await EnterExitCostVerifyIsNull(dto.DiId, dto.CurrUserId); //主表验证
  11759. if (parentId < 1) return Ok(JsonView(false));
  11760. //子表op
  11761. if (subId < 1)
  11762. {
  11763. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  11764. if (subAdd < 1) return Ok(JsonView(false));
  11765. }
  11766. else
  11767. {
  11768. ////验证编辑权限
  11769. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  11770. //if (!isEdit) return Ok(JsonView(false, msg));
  11771. var subUpd = await _sqlSugar.Updateable(subInfo)
  11772. .UpdateColumns(x => new
  11773. {
  11774. x.Days,
  11775. x.NationalTravelFeeId,
  11776. x.Cost,
  11777. x.Currency,
  11778. x.SubTotal
  11779. })
  11780. .WhereColumns(x => new { x.Id })
  11781. .ExecuteCommandAsync();
  11782. if (subUpd < 1) return Ok(JsonView(false));
  11783. }
  11784. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == feeType).Sum(x => x.SubTotal);
  11785. //await EnterExitCostMobileOpNotice(dto.DiId, parentId, dto.CurrUserId);
  11786. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  11787. }
  11788. /// <summary>
  11789. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-批量 Step7
  11790. /// </summary>
  11791. /// <returns></returns>
  11792. [HttpPost]
  11793. [ApiExplorerSettings(IgnoreApi = true)]
  11794. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11795. public async Task<IActionResult> EnterExitCostMobileOpBatchStep7(PostEnterExitCostMobileOpStep7Dto dto)
  11796. {
  11797. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11798. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11799. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11800. var infos1 = _mapper.Map<List<Grp_DayOtherPrice>>(dto.Infos);
  11801. var infos = infos1.Select(x => new Grp_DayOtherPrice()
  11802. {
  11803. Id = x.Id,
  11804. Diid = dto.DiId,
  11805. SetDataId = x.SetDataId,
  11806. Index = x.Index,
  11807. Cost = x.Cost,
  11808. Currency = x.Currency,
  11809. SubTotal = x.SubTotal,
  11810. CreateUserId = dto.CurrUserId,
  11811. Remark = x.Remark
  11812. }).ToList();
  11813. var adds = infos.Where(x => x.Id <= 0).ToList();
  11814. var upds = infos.Where(x => x.Id > 0).ToList();
  11815. if (adds.Count > 0)
  11816. {
  11817. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  11818. if (add < 1) return Ok(JsonView(false));
  11819. }
  11820. if (upds.Count > 0)
  11821. {
  11822. var upd = await _sqlSugar.Updateable(adds)
  11823. .UpdateColumns(x => new
  11824. {
  11825. x.Index,
  11826. x.SetDataId,
  11827. x.Cost,
  11828. x.Currency,
  11829. x.SubTotal,
  11830. x.Remark
  11831. })
  11832. .WhereColumns(x => new { x.Id })
  11833. .ExecuteCommandAsync();
  11834. if (upd < 1) return Ok(JsonView(false));
  11835. }
  11836. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == dto.DiId).Sum(x => x.SubTotal);
  11837. //消息通知
  11838. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  11839. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11840. return Ok(JsonView(new { itemTotal = itemTotal }));
  11841. }
  11842. /// <summary>
  11843. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-单条 Step7
  11844. /// </summary>
  11845. /// <returns></returns>
  11846. [HttpPost]
  11847. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11848. public async Task<IActionResult> EnterExitCostMobileOpSingleStep7(PostEnterExitCostMobileOpSingleStep7Dto dto)
  11849. {
  11850. int subId = dto.SubId;
  11851. int diId = dto.Diid;
  11852. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11853. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11854. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11855. var subInfo = _mapper.Map<Grp_DayOtherPrice>(dto);
  11856. subInfo.Id = subId;
  11857. subInfo.Diid = dto.Diid;
  11858. subInfo.CreateUserId = dto.CurrUserId;
  11859. int parentId = await EnterExitCostVerifyIsNull(diId, dto.CurrUserId); //主表验证
  11860. if (parentId < 1) return Ok(JsonView(false));
  11861. #region 子表op
  11862. if (subId < 1)//add
  11863. {
  11864. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  11865. if (subAdd < 1) return Ok(JsonView(false));
  11866. }
  11867. else //upd
  11868. {
  11869. ////验证编辑权限
  11870. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.Diid, dto.CurrUserId, 2);
  11871. //if (!isEdit) return Ok(JsonView(false, msg));
  11872. var subUpd = await _sqlSugar.Updateable(subInfo)
  11873. .UpdateColumns(x => new
  11874. {
  11875. x.Index,
  11876. x.SetDataId,
  11877. x.Cost,
  11878. x.Currency,
  11879. x.SubTotal,
  11880. x.Remark
  11881. })
  11882. .WhereColumns(x => new { x.Id })
  11883. .ExecuteCommandAsync();
  11884. if (subUpd < 1) return Ok(JsonView(false));
  11885. }
  11886. #endregion
  11887. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == diId).Sum(x => x.SubTotal);
  11888. //消息通知
  11889. //await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  11890. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  11891. }
  11892. /// <summary>
  11893. /// 团组模块 - 出入境费用-移动端 - 3-6子项删除
  11894. /// </summary>
  11895. /// <returns></returns>
  11896. [HttpPost]
  11897. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11898. public async Task<IActionResult> EnterExitCostMobileSubItemDel(EnterExitCostSubItemDelDto dto)
  11899. {
  11900. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  11901. if (data.Code != 0)
  11902. {
  11903. return Ok(JsonView(false, data.Msg));
  11904. }
  11905. return Ok(JsonView(true, "操作成功!", data.Data));
  11906. }
  11907. /// <summary>
  11908. /// 团组模块 - 出入境费用-移动端 - 其他费用删除
  11909. /// </summary>
  11910. /// <param name="dto"></param>
  11911. /// <returns></returns>
  11912. [HttpPost]
  11913. public IActionResult EnterExitCostMobileOtherFeeDel(EnterExitCostSubItemDelDto dto)
  11914. {
  11915. var data = new Grp_DayOtherPrice()
  11916. {
  11917. Id = dto.Id,
  11918. IsDel = 1,
  11919. DeleteUserId = dto.DeleteUserId,
  11920. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  11921. };
  11922. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  11923. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  11924. return Ok(JsonView(false, "删除失败!"));
  11925. }
  11926. #endregion
  11927. #endregion
  11928. #region 团组经理模块 出入境费用-草稿 移动端(Android/IOS)
  11929. /// <summary>
  11930. /// 团组模块 - 出入境费用-草稿 - 基础数据源 - 省份归属
  11931. /// </summary>
  11932. /// <returns></returns>
  11933. [HttpGet]
  11934. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11935. public async Task<IActionResult> EnterExitDraftMobileProvBelongCostDataSource()
  11936. {
  11937. var provData = await _groupRepository.ProvinceBasicSource();
  11938. return Ok(JsonView(true, "查询成功!", provData));
  11939. }
  11940. /// <summary>
  11941. /// 团组模块 - 出入境费用-草稿-移动端 - 草稿名称数据Data
  11942. /// </summary>
  11943. /// <returns></returns>
  11944. [HttpPost]
  11945. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11946. public async Task<IActionResult> EnterExitCostDraftMobileNameData(EnterExitCostDraftMobileNameDataDto dto)
  11947. {
  11948. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11949. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11950. RefAsync<int> total = 0;
  11951. var data = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  11952. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.DraftName))
  11953. .WhereIF(!string.IsNullOrEmpty(dto.DraftName), x => x.DraftName.Contains(dto.DraftName))
  11954. .Select(x => new
  11955. {
  11956. Id = x.Id,
  11957. DraftName = x.DraftName,
  11958. IsViewOrEdit = SqlFunc.Subqueryable<Grp_EnterExitCostDraftPermission>()
  11959. .Where(x1 => x1.IsDel == 0 && x1.Permission == 1 && x1.DraftId == x.Id && x1.UserId == dto.CurrUserId)
  11960. .Any()
  11961. })
  11962. .OrderByDescending(x => x.Id)
  11963. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  11964. return Ok(JsonView(true, "查询成功!", data, total));
  11965. }
  11966. /// <summary>
  11967. /// 出入境费用-草稿 移动端
  11968. /// 获取币种基础数据(含逻辑处理)
  11969. /// </summary>
  11970. /// <returns></returns>
  11971. private async Task<List<CurrencyInfo>> EnterExitCostDraftMobileGetCurrencyInit()
  11972. {
  11973. return await GeneralMethod.EnterExitCostInitRate();
  11974. }
  11975. /// <summary>
  11976. /// 团组模块 - 出入境费用-草稿-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  11977. /// </summary>
  11978. /// <returns></returns>
  11979. [HttpPost]
  11980. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11981. public async Task<IActionResult> EnterExitCostDraftMobileDataSource(EnterExitCostDraftMobileDataSourceDto dto)
  11982. {
  11983. //验证城市归属并给默认值
  11984. int provinceId = dto.ProvinceId;
  11985. if (provinceId < 1) provinceId = 122;
  11986. var dataSource = await _sqlSugar
  11987. .Queryable<Sys_SetData>()
  11988. .Where(x => x.IsDel == 0 && (x.STid == 72 || x.STid == 73) && x.Remark.Contains(provinceId.ToString()))
  11989. .ToListAsync();
  11990. //三公费用-Word明细类型
  11991. var wordTypeData = dataSource.Where(it => it.STid == 72)
  11992. .Select(x => new SetDataInfoView
  11993. {
  11994. Id = x.Id,
  11995. Name = x.Name,
  11996. Remark = x.Remark
  11997. })
  11998. .ToList();
  11999. //三公费用-Excel明细类型
  12000. var excelTypeData = dataSource.Where(it => it.STid == 73)
  12001. .Select(x => new SetDataInfoView
  12002. {
  12003. Id = x.Id,
  12004. Name = x.Name,
  12005. Remark = x.Remark
  12006. })
  12007. .ToList();
  12008. //默认币种显示
  12009. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  12010. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  12011. return Ok(JsonView(true, "查询成功!", new
  12012. {
  12013. WordTypeData = wordTypeData,
  12014. ExcelTypeData = excelTypeData,
  12015. CurrencyInit = _currencyInfos,
  12016. viewPermissionData = viewPermissionData
  12017. }));
  12018. }
  12019. /// <summary>
  12020. /// 团组模块 - 出入境费用-草稿-移动端 - 团组基础数据Data
  12021. /// </summary>
  12022. /// <returns></returns>
  12023. [HttpPost]
  12024. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12025. public async Task<IActionResult> EnterExitCostDraftMobileGroupData(PostEnterExitCostDraftMobileGroupDataDto dto)
  12026. {
  12027. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12028. RefAsync<int> total = 0;
  12029. int diId = 0;
  12030. var status = int.TryParse(dto.GroupName, out diId);
  12031. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  12032. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  12033. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  12034. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  12035. .OrderByDescending(x => x.VisitStartDate)
  12036. .Select(x => new
  12037. {
  12038. Id = x.Id,
  12039. GroupName = x.TeamName
  12040. })
  12041. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  12042. return Ok(JsonView(true, "查询成功!", data, total));
  12043. }
  12044. /// <summary>
  12045. /// 团组模块 - 出入境费用-草稿-移动端 - 币种基础数据Data
  12046. /// </summary>
  12047. /// <returns></returns>
  12048. [HttpPost]
  12049. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12050. public async Task<IActionResult> EnterExitCostDraftMobileCurrencyData(PostEnterExitCostDraftMobileCurrencyDataDto dto)
  12051. {
  12052. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12053. RefAsync<int> total = 0;
  12054. var data = await _sqlSugar.Queryable<Sys_SetData>()
  12055. .Where(x => x.IsDel == 0 && x.STid == 66)
  12056. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  12057. .Select(x => new
  12058. {
  12059. id = x.Id,
  12060. name = x.Name,
  12061. remark = x.Remark,
  12062. })
  12063. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  12064. return Ok(JsonView(true, "查询成功!", data, total));
  12065. }
  12066. /// <summary>
  12067. /// 团组模块 - 出入境费用-草稿-移动端 - 其他款项 - 币种、费用类型基础数据Data
  12068. /// </summary>
  12069. /// <returns></returns>
  12070. [HttpPost]
  12071. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12072. public async Task<IActionResult> EnterExitCostDraftMobileOtherItemCurrencyData(PostEnterExitCostDraftMobileOtherItemCurrencyDataDto dto)
  12073. {
  12074. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12075. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  12076. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(1, 2477, 98);
  12077. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  12078. var groupOtherRateData = groupRateData.TeamRates;
  12079. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  12080. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  12081. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  12082. groupOtherRateData = groupOtherRateData
  12083. .Select(x => new TeamRateDescAddCurrencyIdView
  12084. {
  12085. CurrencyId = x.CurrencyId,
  12086. CurrencyName = x.CurrencyName,
  12087. CurrencyCode = x.CurrencyCode,
  12088. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  12089. }).ToList();
  12090. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  12091. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  12092. }
  12093. /// <summary>
  12094. /// 团组模块 - 出入境费用-草稿-移动端 - 实时汇率、签证费用、机票费用 Tips
  12095. /// </summary>
  12096. /// <returns></returns>
  12097. [HttpPost]
  12098. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12099. public async Task<IActionResult> EnterExitCostDraftMobileFeeTips(EnterExitCostDraftMobileFeeTipsDto dto)
  12100. {
  12101. int portType = dto.PortType;
  12102. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12103. var tipsData = new List<int>() { 1, 2, 3 };
  12104. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  12105. if (dto.TipsType == 1)
  12106. {
  12107. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  12108. }
  12109. else if (dto.TipsType == 2)
  12110. {
  12111. if (portType == 2)
  12112. {
  12113. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  12114. }
  12115. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  12116. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  12117. .Select(x => x.NationalTravelFeeId)
  12118. .Distinct()
  12119. .ToListAsync();
  12120. if (portType == 2)
  12121. {
  12122. if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  12123. }
  12124. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  12125. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  12126. .Select(x => x.Country)
  12127. .Distinct()
  12128. .ToArrayAsync();
  12129. if (portType == 2)
  12130. {
  12131. if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  12132. }
  12133. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  12134. return Ok(JsonView(true, "查询成功!", new
  12135. {
  12136. totalAmt = totalAmt,
  12137. remark = remark
  12138. }));
  12139. }
  12140. else if (dto.TipsType == 3)
  12141. {
  12142. return Ok(JsonView(false, "暂无机票费用提示信息!"));
  12143. }
  12144. return Ok(JsonView(false));
  12145. }
  12146. /// <summary>
  12147. /// 团组模块 - 出入境费用-草稿-移动端 - 创建
  12148. /// </summary>
  12149. /// <returns></returns>
  12150. [HttpPost]
  12151. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12152. public async Task<IActionResult> EnterExitCostDraftMobileCreate(EnterExitCostDraftMobileCreateDto dto)
  12153. {
  12154. if (string.IsNullOrEmpty(dto.DraftName)) return Ok(JsonView(false, "草稿名称为空!"));
  12155. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12156. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  12157. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DraftName.Equals(dto.DraftName) && it.IsDel == 0);
  12158. if (eecInfo != null) return Ok(JsonView(false, "草稿名称重复!"));
  12159. var rateInfos = await EnterExitCostMobileGetCurrencyInit();
  12160. var info = new Grp_EnterExitCostDraft()
  12161. {
  12162. ProvinceId = dto.ProvinceId,
  12163. DraftName = dto.DraftName,
  12164. CurrencyRemark = CommonFun.GetCurrencyChinaToString(rateInfos),
  12165. CreateUserId = dto.CurrUserId
  12166. };
  12167. _sqlSugar.BeginTran();
  12168. var draftId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  12169. if (draftId < 1)
  12170. {
  12171. _sqlSugar.RollbackTran();
  12172. return Ok(JsonView(false, "草稿创建失败!"));
  12173. }
  12174. //添加默认权限
  12175. await _enterExitCostDraftRep.InitPerm(draftId, dto.CurrUserId);
  12176. _sqlSugar.CommitTran();
  12177. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(draftId, dto.CurrUserId);
  12178. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  12179. mobileInfo.Id = draftId;
  12180. mobileInfo.DraftName = dto.DraftName;
  12181. mobileInfo.Currencys = rateInfos;
  12182. mobileInfo.IsAssignPerm = assignPerm;
  12183. return Ok(JsonView(mobileInfo));
  12184. }
  12185. /// <summary>
  12186. /// 出入境费用-草稿-移动端 查看编辑提示消息
  12187. /// </summary>
  12188. private static string _viewPermStr = $"未分配查看权限,如要查看,请联系市场部或国交部负责人!";
  12189. /// <summary>
  12190. /// 团组模块 - 出入境费用-草稿-移动端 - ParentInfo
  12191. /// </summary>
  12192. /// <returns></returns>
  12193. [HttpPost]
  12194. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12195. public async Task<IActionResult> EnterExitCostDraftMobileParentInfo(EnterExitCostDraftMobileParentInfoDto dto)
  12196. {
  12197. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  12198. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12199. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  12200. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  12201. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  12202. if (eecInfo == null) return Ok(JsonView(mobileInfo));
  12203. //验证查看编辑权限
  12204. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  12205. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  12206. mobileInfo = _mapper.Map<EnterExitCostDraftMobileParentInfoView>(eecInfo);
  12207. mobileInfo.ProvinceId = eecInfo.ProvinceId;
  12208. mobileInfo.IsAssignPerm = assignPerm;
  12209. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  12210. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  12211. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  12212. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  12213. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  12214. {
  12215. ParentId = dac.ParentId,
  12216. SubId = dac.Id,
  12217. Type = dac.Type,
  12218. Days = dac.Days,
  12219. NationalTravelFeeId = dac.NationalTravelFeeId,
  12220. Arae = $"{ntf.Country}-{ntf.City}",
  12221. Cost = dac.Cost,
  12222. Currency = dac.Currency,
  12223. CurrencyName = sd.Name,
  12224. SubTotal = dac.SubTotal,
  12225. })
  12226. .ToList();
  12227. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  12228. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  12229. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  12230. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  12231. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  12232. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  12233. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  12234. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  12235. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  12236. //其他款项
  12237. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  12238. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  12239. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  12240. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  12241. .OrderBy((dop, sd1, sd2) => dop.Index)
  12242. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  12243. {
  12244. ParentId = dop.ParentId,
  12245. SubId = dop.Id,
  12246. Index = dop.Index,
  12247. SetDataId = dop.SetDataId,
  12248. SetDataName = sd1.Name,
  12249. Cost = dop.Cost,
  12250. Currency = dop.Currency,
  12251. CurrencyName = sd2.Remark,
  12252. SubTotal = dop.SubTotal,
  12253. Remark = dop.Remark,
  12254. })
  12255. .ToArray();
  12256. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  12257. return Ok(mobileInfo);
  12258. }
  12259. /// <summary>
  12260. /// 团组模块 - 出入境费用-草稿-移动端 - SubInfo
  12261. /// </summary>
  12262. /// <returns></returns>
  12263. [HttpPost]
  12264. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12265. public async Task<IActionResult> EnterExitCostDraftMobileSubInfo(PostEnterExitCostDraftMobileSubInfoDto dto)
  12266. {
  12267. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12268. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  12269. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12270. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  12271. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  12272. //验证查看编辑权限
  12273. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  12274. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  12275. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  12276. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  12277. var subType = dto.SubType;
  12278. if (subType == 1) //1:境内费用
  12279. {
  12280. var oneData = new ChoiceOneMobileSubInfoView()
  12281. {
  12282. Id = eecInfo.Id,
  12283. ChoiceOne = eecInfo.ChoiceOne,
  12284. ChoiceOneTotalCost = eecInfo.InsidePay,
  12285. Visa = eecInfo.Visa,
  12286. VisaRemark = eecInfo.VisaRemark,
  12287. YiMiao = eecInfo.YiMiao,
  12288. HeSuan = eecInfo.HeSuan,
  12289. Service = eecInfo.Service,
  12290. Ticket = eecInfo.Ticket,
  12291. Safe = eecInfo.Safe,
  12292. FirstItemRemark = eecInfo.FirstItemRemark
  12293. };
  12294. return Ok(JsonView(oneData));
  12295. }
  12296. else if (subType == 2) //2:国际旅费
  12297. {
  12298. var twoData = new ChoiceTwoMobileSubInfoView()
  12299. {
  12300. Id = eecInfo.Id,
  12301. ChoiceTwoJJ = eecInfo.SumJJC,
  12302. OutsideJJPay = eecInfo.OutsideJJPay,
  12303. ChoiceTwoGW = eecInfo.SumGWC,
  12304. OutsideGWPay = eecInfo.OutsideGWPay,
  12305. ChoiceTwoTD = eecInfo.SumTDC,
  12306. OutsideTDPay = eecInfo.OutsideTDPay,
  12307. AirJJ = eecInfo.AirJJ,
  12308. AirGW = eecInfo.AirGW,
  12309. AirTD = eecInfo.AirTD,
  12310. CityTranffic = eecInfo.CityTranffic,
  12311. TwoItemRemark = eecInfo.TwoItemRemark
  12312. };
  12313. return Ok(JsonView(twoData));
  12314. }
  12315. else if (subType == 3) //3:住宿费
  12316. {
  12317. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  12318. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  12319. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  12320. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 1)
  12321. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  12322. {
  12323. ParentId = dac.ParentId,
  12324. SubId = dac.Id,
  12325. Type = dac.Type,
  12326. Days = dac.Days,
  12327. NationalTravelFeeId = dac.NationalTravelFeeId,
  12328. Arae = $"{ntf.Country}-{ntf.City}",
  12329. Cost = dac.Cost,
  12330. Currency = dac.Currency,
  12331. CurrencyName = sd.Name,
  12332. SubTotal = dac.SubTotal,
  12333. })
  12334. .ToArray();
  12335. var data = new ChoiceDraftMobileSubInfo3To6View()
  12336. {
  12337. ParentId = eecInfo.Id,
  12338. Choice = eecInfo.ChoiceThree,
  12339. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  12340. Details = dayAndCostDatas
  12341. };
  12342. return Ok(JsonView(data));
  12343. }
  12344. else if (subType == 4) //4:伙食费
  12345. {
  12346. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  12347. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  12348. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  12349. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 2)
  12350. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  12351. {
  12352. ParentId = dac.ParentId,
  12353. SubId = dac.Id,
  12354. Type = dac.Type,
  12355. Days = dac.Days,
  12356. NationalTravelFeeId = dac.NationalTravelFeeId,
  12357. Arae = $"{ntf.Country}-{ntf.City}",
  12358. Cost = dac.Cost,
  12359. Currency = dac.Currency,
  12360. CurrencyName = sd.Name,
  12361. SubTotal = dac.SubTotal,
  12362. })
  12363. .ToArray();
  12364. var data = new ChoiceDraftMobileSubInfo3To6View()
  12365. {
  12366. ParentId = eecInfo.Id,
  12367. Choice = eecInfo.ChoiceFour,
  12368. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  12369. Details = dayAndCostDatas
  12370. };
  12371. return Ok(JsonView(data));
  12372. }
  12373. else if (subType == 5) //5:公杂费
  12374. {
  12375. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  12376. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  12377. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  12378. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 3)
  12379. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  12380. {
  12381. ParentId = dac.ParentId,
  12382. SubId = dac.Id,
  12383. Type = dac.Type,
  12384. Days = dac.Days,
  12385. NationalTravelFeeId = dac.NationalTravelFeeId,
  12386. Arae = $"{ntf.Country}-{ntf.City}",
  12387. Cost = dac.Cost,
  12388. Currency = dac.Currency,
  12389. CurrencyName = sd.Name,
  12390. SubTotal = dac.SubTotal,
  12391. })
  12392. .ToArray();
  12393. var data = new ChoiceDraftMobileSubInfo3To6View()
  12394. {
  12395. ParentId = eecInfo.Id,
  12396. Choice = eecInfo.ChoiceFive,
  12397. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  12398. Details = dayAndCostDatas
  12399. };
  12400. return Ok(JsonView(data));
  12401. }
  12402. else if (subType == 6) //6:培训费
  12403. {
  12404. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  12405. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  12406. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  12407. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 4)
  12408. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  12409. {
  12410. ParentId = dac.ParentId,
  12411. SubId = dac.Id,
  12412. Type = dac.Type,
  12413. Days = dac.Days,
  12414. NationalTravelFeeId = dac.NationalTravelFeeId,
  12415. Arae = $"{ntf.Country}-{ntf.City}",
  12416. Cost = dac.Cost,
  12417. Currency = dac.Currency,
  12418. CurrencyName = sd.Name,
  12419. SubTotal = dac.SubTotal,
  12420. })
  12421. .ToArray();
  12422. var data = new ChoiceDraftMobileSubInfo3To6View()
  12423. {
  12424. ParentId = eecInfo.Id,
  12425. Choice = eecInfo.ChoiceSix,
  12426. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  12427. Details = dayAndCostDatas
  12428. };
  12429. return Ok(JsonView(data));
  12430. }
  12431. else if (subType == 7) //7:其他
  12432. {
  12433. //其他款项
  12434. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  12435. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  12436. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  12437. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  12438. .OrderBy((dop, sd1, sd2) => dop.Index)
  12439. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  12440. {
  12441. ParentId = dop.ParentId,
  12442. SubId = dop.Id,
  12443. Index = dop.Index,
  12444. SetDataId = dop.SetDataId,
  12445. SetDataName = sd1.Name,
  12446. Cost = dop.Cost,
  12447. Currency = dop.Currency,
  12448. CurrencyName = sd2.Name,
  12449. SubTotal = dop.SubTotal,
  12450. Remark = dop.Remark,
  12451. })
  12452. .ToArray();
  12453. var data = new ChoiceSevenDraftMobileSubInfoView()
  12454. {
  12455. ParentId = eecInfo.Id,
  12456. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  12457. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  12458. Details = otherData
  12459. };
  12460. return Ok(JsonView(data));
  12461. }
  12462. return Ok(JsonView(false));
  12463. }
  12464. #region op
  12465. ///// <summary>
  12466. ///// 移动端更新费用消息通知
  12467. ///// </summary>
  12468. ///// <param name="draftId"></param>
  12469. ///// <param name="id"></param>
  12470. ///// <param name="currUserId"></param>
  12471. //private async Task EnterExitCostDraftMobileOpNotice(int draftId, int id, int currUserId)
  12472. //{
  12473. // try
  12474. // {
  12475. // ////生成默认文件pdf并且通知人员
  12476. // //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  12477. // //{
  12478. // // DiId = draftId,
  12479. // // ExportType = 1,
  12480. // // SubTypeId = 1005
  12481. // //}, "pdf");
  12482. // ////发送通知
  12483. // //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  12484. // //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  12485. // //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  12486. // //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(draftId, new List<string>() { "208", "233", "21" }, currUserId, url);
  12487. // ////汇率信息记录
  12488. // //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  12489. // }
  12490. // catch (Exception ex)
  12491. // {
  12492. // //记录日志
  12493. // throw;
  12494. // }
  12495. //}
  12496. /// <summary>
  12497. /// 验证出入境费用数据是否存在
  12498. /// 不存在添加
  12499. /// </summary>
  12500. /// <param name="draftId"></param>
  12501. /// <param name="currUserId"></param>
  12502. /// <returns></returns>
  12503. /// <exception cref="CustomException"></exception>
  12504. private async Task<int> EnterExitCostDraftVerifyIsNull(int draftId, int currUserId)
  12505. {
  12506. var parentId = 0;
  12507. var info = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).OrderByDescending(x => x.CreateTime).FirstAsync();
  12508. if (info != null) parentId = info.Id;
  12509. else
  12510. {
  12511. var currencys = await EnterExitCostDraftMobileGetCurrencyInit();
  12512. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  12513. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  12514. parentId = addId;
  12515. }
  12516. return parentId;
  12517. }
  12518. /// <summary>
  12519. /// 团组模块 - 出入境费用-草稿-移动端 - 查看权限用户
  12520. /// </summary>
  12521. /// <returns></returns>
  12522. [HttpPost]
  12523. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12524. public async Task<IActionResult> EnterExitCostDraftMobileViewPermissionUsers(EnterExitCostDraftMobileViewPermissionUsersDto dto)
  12525. {
  12526. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  12527. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12528. //验证查看权限
  12529. (bool isView, bool isSet) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  12530. if (!isView) return Ok(JsonView(false, _viewPermStr));
  12531. var userIds = await _sqlSugar
  12532. .Queryable<Grp_EnterExitCostDraftPermission>()
  12533. .Where(x => x.IsDel == 0 && x.DraftId == dto.DraftId)
  12534. .Select(x => x.UserId)
  12535. .ToArrayAsync();
  12536. var perUsers = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  12537. var perUsersView = new List<dynamic>();
  12538. var feeBasePerm = AppSettingsHelper.Get<FeeBasePermView>("FeeBasePerm");
  12539. var viewPermissionData = new List<PermissionViewUserview>();
  12540. if (feeBasePerm.Any())
  12541. {
  12542. foreach (var item in feeBasePerm)
  12543. {
  12544. if (item.Users.Any())
  12545. {
  12546. viewPermissionData.AddRange(item.Users);
  12547. }
  12548. }
  12549. }
  12550. foreach (var item in perUsers)
  12551. {
  12552. bool isView1 = false;
  12553. if (userIds.Any(x => x == item.Id)) isView1 = true;
  12554. else if (viewPermissionData.Any(x => x.Id == dto.CurrUserId) && item.Id == dto.CurrUserId) isView1 = true;
  12555. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  12556. }
  12557. return Ok(JsonView(perUsersView));
  12558. }
  12559. /// <summary>
  12560. /// 团组模块 - 出入境费用-草稿-移动端 - 设置view权限
  12561. /// </summary>
  12562. /// <returns></returns>
  12563. [HttpPost]
  12564. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12565. public async Task<IActionResult> EnterExitCostDraftMobileSetViewPermissiion(EnterExitCostDraftMobileSetViewPermissiionDto dto)
  12566. {
  12567. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12568. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  12569. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  12570. //验证查看编辑权限
  12571. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  12572. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  12573. var permissions = new List<Grp_EnterExitCostDraftPermission>() { };
  12574. foreach (var userId in dto.UserIds)
  12575. {
  12576. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  12577. }
  12578. if (permissions.Any())
  12579. {
  12580. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  12581. {
  12582. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  12583. }
  12584. _sqlSugar.BeginTran();
  12585. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  12586. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  12587. if (result < 1)
  12588. {
  12589. _sqlSugar.RollbackTran();
  12590. return Ok(JsonView(false));
  12591. }
  12592. _sqlSugar.CommitTran();
  12593. return Ok(JsonView(true));
  12594. }
  12595. return Ok(JsonView(false));
  12596. }
  12597. /// <summary>
  12598. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 省份
  12599. /// </summary>
  12600. /// <returns></returns>
  12601. [HttpPost]
  12602. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12603. public async Task<IActionResult> EnterExitCostDraftMobileOpProv(EnterExitCostDraftMobileOpProvDto dto)
  12604. {
  12605. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12606. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12607. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12608. if (dto.ProvinceId < 1) return Ok(JsonView(false, "请传入有效的省份Id!"));
  12609. int id = dto.DraftId;
  12610. if (id <= 0) //add
  12611. {
  12612. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  12613. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  12614. if (add < 1) return Ok(JsonView(false));
  12615. id = add;
  12616. }
  12617. else //update
  12618. {
  12619. //验证查看编辑权限
  12620. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  12621. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  12622. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  12623. if (upd < 1) return Ok(JsonView(false));
  12624. }
  12625. return Ok(JsonView(new { parentId = id }));
  12626. }
  12627. /// <summary>
  12628. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 汇率
  12629. /// </summary>
  12630. /// <returns></returns>
  12631. [HttpPost]
  12632. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12633. public async Task<IActionResult> EnterExitCostDraftMobileOpRate(PostEnterExitCostDraftMobileFeeRateOpDto dto)
  12634. {
  12635. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12636. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12637. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12638. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  12639. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  12640. int id = dto.DraftId;
  12641. if (id <= 0) //add
  12642. {
  12643. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  12644. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId, CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  12645. if (add < 1) return Ok(JsonView(false));
  12646. id = add;
  12647. }
  12648. else //update
  12649. {
  12650. //验证查看编辑权限
  12651. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  12652. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  12653. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  12654. if (upd < 1) return Ok(JsonView(false));
  12655. }
  12656. #region 汇率变更时更改币种相关费用
  12657. var opDayCosts = new List<Grp_DayAndCostDraft>();
  12658. var opDayOtherCosts = new List<Grp_DayOtherPriceDraft>();
  12659. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  12660. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  12661. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  12662. .Where((dac, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  12663. .Select((dac, sd) => new
  12664. {
  12665. dac.Id,
  12666. dac.ParentId,
  12667. CurrencyCode = sd.Name,
  12668. dac.Cost
  12669. })
  12670. .ToList();
  12671. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  12672. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  12673. .Where((dop, sd) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  12674. .Select((dop, sd) => new
  12675. {
  12676. dop.Id,
  12677. dop.ParentId,
  12678. CurrencyCode = sd.Name,
  12679. dop.Cost
  12680. })
  12681. .ToList();
  12682. if (dayCosts.Count > 0)
  12683. {
  12684. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  12685. foreach (var dc in new_dayCosts)
  12686. {
  12687. var thisCurrency = dc.Key.ToUpper();
  12688. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  12689. if (thisRate == 0.00M) continue;
  12690. foreach (var dcSub in dc)
  12691. {
  12692. opDayCosts.Add(new Grp_DayAndCostDraft()
  12693. {
  12694. Id = dcSub.Id,
  12695. ParentId = dcSub.ParentId,
  12696. Cost = dcSub.Cost,
  12697. SubTotal = dcSub.Cost * thisRate,
  12698. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now:yyyy-MM-dd HH:mm:ss}、opUserId:{dto.CurrUserId}]"
  12699. });
  12700. }
  12701. }
  12702. if (opDayCosts.Count > 0)
  12703. {
  12704. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  12705. }
  12706. }
  12707. if (dayOtherCosts.Count > 0)
  12708. {
  12709. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  12710. foreach (var dc in new_dayOtherCosts)
  12711. {
  12712. var thisCurrency = dc.Key.ToUpper();
  12713. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  12714. if (thisRate == 0.00M) continue;
  12715. foreach (var dcSub in dc)
  12716. {
  12717. opDayOtherCosts.Add(new Grp_DayOtherPriceDraft()
  12718. {
  12719. Id = dcSub.Id,
  12720. ParentId = dcSub.ParentId,
  12721. Cost = dcSub.Cost,
  12722. SubTotal = dcSub.Cost * thisRate,
  12723. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  12724. });
  12725. }
  12726. }
  12727. if (opDayOtherCosts.Count > 0)
  12728. {
  12729. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  12730. }
  12731. }
  12732. #endregion
  12733. ////消息通知
  12734. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  12735. ////汇率信息记录
  12736. //await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  12737. return Ok(JsonView(new { parentId = id }));
  12738. }
  12739. /// <summary>
  12740. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 复选框
  12741. /// </summary>
  12742. /// <returns></returns>
  12743. [HttpPost]
  12744. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12745. public async Task<IActionResult> EnterExitCostDraftMobileOpCheckbox(PostEnterExitCostDraftMobileFeeOpCheckboxDto dto)
  12746. {
  12747. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12748. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  12749. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12750. var checkboxInfo = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  12751. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  12752. int id = dto.DraftId;
  12753. if (id <= 0) //add
  12754. {
  12755. checkboxInfo.ProvinceId = dto.ProvinceId;
  12756. checkboxInfo.CreateUserId = dto.CurrUserId;
  12757. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostDraftMobileGetCurrencyInit());
  12758. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  12759. if (add < 1) return Ok(JsonView(false));
  12760. }
  12761. else //update
  12762. {
  12763. var upd = await _sqlSugar.Updateable(checkboxInfo)
  12764. .UpdateColumns(x => new
  12765. {
  12766. x.ChoiceOne,
  12767. x.ChoiceTwo,
  12768. x.SumJJC,
  12769. x.SumGWC,
  12770. x.SumTDC,
  12771. x.ChoiceThree,
  12772. x.ChoiceFour,
  12773. x.ChoiceFive,
  12774. x.ChoiceSix,
  12775. x.OtherExpenses_Checked
  12776. })
  12777. .Where(x => x.Id == id)
  12778. .ExecuteCommandAsync();
  12779. if (upd < 1) return Ok(JsonView(false));
  12780. }
  12781. return Ok(JsonView(new { parentId = id }));
  12782. }
  12783. /// <summary>
  12784. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 3-7项复选框单个复选框
  12785. /// </summary>
  12786. /// <returns></returns>
  12787. [HttpPost]
  12788. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12789. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleCheckbox(EnterExitCostDarftMobileOpSingleCheckboxDto dto)
  12790. {
  12791. int itemTypeId = dto.ItemType, currUserId = dto.CurrUserId, draftId = dto.DraftId, isSelected = dto.IsSelected;
  12792. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  12793. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12794. if (draftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  12795. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12796. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  12797. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  12798. var checkboxInfo = new Grp_EnterExitCostDraft()
  12799. {
  12800. Id = draftId,
  12801. ProvinceId = dto.ProvinceId,
  12802. CreateUserId = currUserId
  12803. };
  12804. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  12805. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  12806. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  12807. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  12808. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  12809. if (draftId <= 0) //add
  12810. {
  12811. checkboxInfo.CreateUserId = dto.CurrUserId;
  12812. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  12813. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  12814. if (add < 1) return Ok(JsonView(false));
  12815. }
  12816. else //update
  12817. {
  12818. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>()
  12819. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  12820. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  12821. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  12822. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  12823. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  12824. .Where(x => x.Id == draftId)
  12825. .ExecuteCommandAsync();
  12826. if (upd < 1) return Ok(JsonView(false));
  12827. }
  12828. return Ok(JsonView(new { parentId = draftId }));
  12829. }
  12830. /// <summary>
  12831. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 境内费用 Step1
  12832. /// </summary>
  12833. /// <returns></returns>
  12834. [HttpPost]
  12835. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12836. public async Task<IActionResult> EnterExitCostDraftMobileOpStep1(PostEnterExitCostDraftMobileOpStep1Dto dto)
  12837. {
  12838. int id = dto.DraftId, currUserId = dto.CurrUserId;
  12839. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12840. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  12841. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12842. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  12843. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  12844. info.ProvinceId = dto.ProvinceId;
  12845. info.FirstItemRemark = dto.FirstItemRemark;
  12846. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  12847. if (id <= 0) //add
  12848. {
  12849. info.CreateUserId = dto.CurrUserId;
  12850. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  12851. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  12852. if (add < 1) return Ok(JsonView(false));
  12853. id = add;
  12854. }
  12855. else //update
  12856. {
  12857. var upd = await _sqlSugar.Updateable(info)
  12858. .UpdateColumns(x => new
  12859. {
  12860. x.ChoiceOne,
  12861. x.InsidePay,
  12862. x.VisaRemark,
  12863. x.Visa,
  12864. x.Service,
  12865. x.Safe,
  12866. x.Ticket,
  12867. x.HeSuan,
  12868. x.YiMiao,
  12869. x.FirstItemRemark
  12870. })
  12871. .Where(x => x.Id == id)
  12872. .ExecuteCommandAsync();
  12873. if (upd < 1) return Ok(JsonView(false));
  12874. }
  12875. ////消息通知
  12876. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  12877. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  12878. }
  12879. /// <summary>
  12880. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 国际旅费 Step2
  12881. /// </summary>
  12882. /// <returns></returns>
  12883. [HttpPost]
  12884. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12885. public async Task<IActionResult> EnterExitCostDraftMobileOpStep2(PostEnterExitCostDraftMobileOpStep2Dto dto)
  12886. {
  12887. int id = dto.DraftId;
  12888. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12889. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  12890. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12891. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  12892. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  12893. info.ProvinceId = dto.ProvinceId;
  12894. info.OutsideJJPay = dto.OutsideJJPay;
  12895. info.OutsideGWPay = dto.OutsideGWPay;
  12896. info.OutsideTDPay = dto.OutsideTDPay;
  12897. info.AirJJ = dto.AirJJ;
  12898. info.AirGW = dto.AirGW;
  12899. info.AirTD = dto.AirTD;
  12900. info.CityTranffic = dto.CityTranffic;
  12901. info.TwoItemRemark = dto.TwoItemRemark;
  12902. info.SumJJC = dto.ChoiceTwoJJ;
  12903. info.SumGWC = dto.ChoiceTwoGW;
  12904. info.SumTDC = dto.ChoiceTwoTD;
  12905. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  12906. if (id <= 0) //add
  12907. {
  12908. info.CreateUserId = dto.CurrUserId;
  12909. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  12910. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  12911. if (addId <= 0) return Ok(JsonView(false));
  12912. id = addId;
  12913. }
  12914. else //update
  12915. {
  12916. var upd = await _sqlSugar.Updateable(info)
  12917. .UpdateColumns(x => new
  12918. {
  12919. x.SumJJC,
  12920. x.OutsideJJPay,
  12921. x.SumGWC,
  12922. x.OutsideGWPay,
  12923. x.SumTDC,
  12924. x.OutsideTDPay,
  12925. x.AirJJ,
  12926. x.AirGW,
  12927. x.AirTD,
  12928. x.CityTranffic,
  12929. x.TwoItemRemark
  12930. })
  12931. .Where(x => x.Id == id)
  12932. .ExecuteCommandAsync();
  12933. if (upd < 1) return Ok(JsonView(false));
  12934. }
  12935. jjcItemTotal = info.AirJJ + info.CityTranffic;
  12936. gwcItemTotal = info.AirGW + info.CityTranffic;
  12937. tdcItemTotal = info.AirTD + info.CityTranffic;
  12938. ////消息通知
  12939. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  12940. return Ok(JsonView(new
  12941. {
  12942. parentId = id,
  12943. choiceTwoJJ = dto.ChoiceTwoJJ,
  12944. jjcItemTotal = jjcItemTotal,
  12945. choiceTwoGW = dto.ChoiceTwoGW,
  12946. gwcItemTotal = gwcItemTotal,
  12947. choiceTwoTD = dto.ChoiceTwoTD,
  12948. tdcItemTotal = tdcItemTotal
  12949. }));
  12950. }
  12951. /// <summary>
  12952. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  12953. /// </summary>
  12954. /// <returns></returns>
  12955. [HttpPost]
  12956. [ApiExplorerSettings(IgnoreApi = true)]
  12957. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12958. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep3To6(PostEnterExitCostDraftMobileOpStep3To6Dto dto)
  12959. {
  12960. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12961. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  12962. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12963. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  12964. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  12965. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  12966. var infos1 = _mapper.Map<List<Grp_DayAndCostDraft>>(dto.Infos);
  12967. var infos = infos1.Select(x => new Grp_DayAndCostDraft
  12968. {
  12969. Id = x.Id,
  12970. ParentId = dto.DraftId,
  12971. Type = dto.FeeType,
  12972. Days = x.Days,
  12973. NationalTravelFeeId = x.NationalTravelFeeId,
  12974. Cost = x.Cost,
  12975. Currency = x.Currency,
  12976. SubTotal = x.SubTotal,
  12977. CreateUserId = dto.CurrUserId
  12978. })
  12979. .ToList();
  12980. var adds = infos.Where(x => x.Id <= 0).ToList();
  12981. var upds = infos.Where(x => x.Id > 0).ToList();
  12982. if (adds.Count > 0)
  12983. {
  12984. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  12985. if (add < 1) return Ok(JsonView(false));
  12986. }
  12987. if (upds.Count > 0)
  12988. {
  12989. var upd = await _sqlSugar.Updateable(adds)
  12990. .UpdateColumns(x => new
  12991. {
  12992. x.Days,
  12993. x.NationalTravelFeeId,
  12994. x.Cost,
  12995. x.Currency,
  12996. x.SubTotal
  12997. })
  12998. .WhereColumns(x => new { x.Id })
  12999. .ExecuteCommandAsync();
  13000. if (upd < 1) return Ok(JsonView(false));
  13001. }
  13002. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  13003. ////消息通知
  13004. //var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).First()?.Id ?? 0;
  13005. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  13006. return Ok(JsonView(new { itemTotal = itemTotal }));
  13007. }
  13008. /// <summary>
  13009. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  13010. /// </summary>
  13011. /// <returns></returns>
  13012. [HttpPost]
  13013. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13014. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep3To6(PostEnterExitCostDraftMobileOpSingleStep3To6Dto dto)
  13015. {
  13016. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  13017. int subId = dto.SubId, feeType = dto.FeeType;
  13018. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  13019. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  13020. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  13021. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  13022. var subInfo = _mapper.Map<Grp_DayAndCostDraft>(dto);
  13023. subInfo.Id = subId;
  13024. subInfo.ParentId = dto.DraftId;
  13025. if (feeType == 3) subInfo.Type = 1;
  13026. else if (feeType == 4) subInfo.Type = 2;
  13027. else if (feeType == 5) subInfo.Type = 3;
  13028. else if (feeType == 6) subInfo.Type = 4;
  13029. subInfo.CreateUserId = dto.CurrUserId;
  13030. int parentId = await EnterExitCostDraftVerifyIsNull(dto.DraftId, dto.CurrUserId); //主表验证
  13031. if (parentId < 1) return Ok(JsonView(false));
  13032. //子表op
  13033. if (subId < 1)
  13034. {
  13035. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  13036. if (subAdd < 1) return Ok(JsonView(false));
  13037. }
  13038. else
  13039. {
  13040. var subUpd = await _sqlSugar.Updateable(subInfo)
  13041. .UpdateColumns(x => new
  13042. {
  13043. x.Days,
  13044. x.NationalTravelFeeId,
  13045. x.Cost,
  13046. x.Currency,
  13047. x.SubTotal
  13048. })
  13049. .WhereColumns(x => new { x.Id })
  13050. .ExecuteCommandAsync();
  13051. if (subUpd < 1) return Ok(JsonView(false));
  13052. }
  13053. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == feeType).Sum(x => x.SubTotal);
  13054. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  13055. }
  13056. /// <summary>
  13057. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-批量 Step7
  13058. /// </summary>
  13059. /// <returns></returns>
  13060. [HttpPost]
  13061. [ApiExplorerSettings(IgnoreApi = true)]
  13062. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13063. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep7(PostEnterExitCostDraftMobileOpStep7Dto dto)
  13064. {
  13065. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  13066. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  13067. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  13068. var infos1 = _mapper.Map<List<Grp_DayOtherPriceDraft>>(dto.Infos);
  13069. var infos = infos1.Select(x => new Grp_DayOtherPriceDraft()
  13070. {
  13071. Id = x.Id,
  13072. ParentId = dto.DraftId,
  13073. SetDataId = x.SetDataId,
  13074. Index = x.Index,
  13075. Cost = x.Cost,
  13076. Currency = x.Currency,
  13077. SubTotal = x.SubTotal,
  13078. CreateUserId = dto.CurrUserId,
  13079. Remark = x.Remark
  13080. }).ToList();
  13081. var adds = infos.Where(x => x.Id <= 0).ToList();
  13082. var upds = infos.Where(x => x.Id > 0).ToList();
  13083. if (adds.Count > 0)
  13084. {
  13085. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  13086. if (add < 1) return Ok(JsonView(false));
  13087. }
  13088. if (upds.Count > 0)
  13089. {
  13090. var upd = await _sqlSugar.Updateable(adds)
  13091. .UpdateColumns(x => new
  13092. {
  13093. x.Index,
  13094. x.SetDataId,
  13095. x.Cost,
  13096. x.Currency,
  13097. x.SubTotal,
  13098. x.Remark
  13099. })
  13100. .WhereColumns(x => new { x.Id })
  13101. .ExecuteCommandAsync();
  13102. if (upd < 1) return Ok(JsonView(false));
  13103. }
  13104. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).Sum(x => x.SubTotal);
  13105. //消息通知
  13106. //var id = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == dto.DraftId).First()?.Id ?? 0;
  13107. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  13108. return Ok(JsonView(new { itemTotal = itemTotal }));
  13109. }
  13110. /// <summary>
  13111. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-单条 Step7
  13112. /// </summary>
  13113. /// <returns></returns>
  13114. [HttpPost]
  13115. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13116. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep7(PostEnterExitCostDraftMobileOpSingleStep7Dto dto)
  13117. {
  13118. int subId = dto.SubId, id = dto.DraftId;
  13119. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  13120. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  13121. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  13122. var subInfo = _mapper.Map<Grp_DayOtherPriceDraft>(dto);
  13123. subInfo.Id = subId;
  13124. subInfo.ParentId = id;
  13125. subInfo.CreateUserId = dto.CurrUserId;
  13126. int parentId = await EnterExitCostDraftVerifyIsNull(id, dto.CurrUserId); //主表验证
  13127. if (parentId < 1) return Ok(JsonView(false));
  13128. #region 子表op
  13129. if (subId < 1)//add
  13130. {
  13131. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  13132. if (subAdd < 1) return Ok(JsonView(false));
  13133. }
  13134. else //upd
  13135. {
  13136. var subUpd = await _sqlSugar.Updateable(subInfo)
  13137. .UpdateColumns(x => new
  13138. {
  13139. x.Index,
  13140. x.SetDataId,
  13141. x.Cost,
  13142. x.Currency,
  13143. x.SubTotal,
  13144. x.Remark
  13145. })
  13146. .WhereColumns(x => new { x.Id })
  13147. .ExecuteCommandAsync();
  13148. if (subUpd < 1) return Ok(JsonView(false));
  13149. }
  13150. #endregion
  13151. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == id).Sum(x => x.SubTotal);
  13152. ////消息通知
  13153. //await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  13154. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  13155. }
  13156. /// <summary>
  13157. /// 团组模块 - 出入境费用-草稿-移动端 - 3-6子项删除
  13158. /// </summary>
  13159. /// <returns></returns>
  13160. [HttpPost]
  13161. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13162. public async Task<IActionResult> EnterExitCostDraftMobileSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  13163. {
  13164. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  13165. if (data.Code != 0)
  13166. {
  13167. return Ok(JsonView(false, data.Msg));
  13168. }
  13169. return Ok(JsonView(true, "操作成功!", data.Data));
  13170. }
  13171. /// <summary>
  13172. /// 团组模块 - 出入境费用-草稿-移动端 - 其他费用删除
  13173. /// </summary>
  13174. /// <param name="dto"></param>
  13175. /// <returns></returns>
  13176. [HttpPost]
  13177. public IActionResult EnterExitCostDraftMobileOtherFeeDel(EnterExitCostDraftSubItemDelDto dto)
  13178. {
  13179. var data = new Grp_DayOtherPriceDraft()
  13180. {
  13181. Id = dto.Id,
  13182. IsDel = 1,
  13183. DeleteUserId = dto.DeleteUserId,
  13184. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  13185. };
  13186. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  13187. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  13188. return Ok(JsonView(false, "删除失败!"));
  13189. }
  13190. #endregion
  13191. #endregion
  13192. #region 团组经理模块 出入境费用报价表
  13193. /// <summary>
  13194. /// 团组模块 - 出入境费用报价表 - 初始化数据源(币种类型)
  13195. /// </summary>
  13196. /// <returns></returns>
  13197. [HttpPost]
  13198. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13199. public async Task<IActionResult> EnterExitCostQuoteInitData(PortDtoBase dto)
  13200. {
  13201. var initRates = await GeneralMethod.EnterExitCostInitRate();
  13202. var liveRates = await GeneralMethod.EnterExitCostLiveRate();
  13203. var cnyInfo = new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.0000M };
  13204. initRates.Insert(0, cnyInfo);
  13205. liveRates.Insert(0, cnyInfo);
  13206. return Ok(JsonView(true, "查询成功!", new
  13207. {
  13208. InitRates = initRates,
  13209. LiveRates = liveRates
  13210. }));
  13211. }
  13212. /// <summary>
  13213. /// 团组模块 - 出入境费用报价表 - 报价表名称列表
  13214. /// </summary>
  13215. /// <returns></returns>
  13216. [HttpPost]
  13217. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13218. public async Task<IActionResult> EnterExitCostQuoteNameList(EnterExitCostQuoteNameListDto dto)
  13219. {
  13220. return Ok(await _enterExitCostQuoteRep.QuoteNameListAsync(dto));
  13221. }
  13222. /// <summary>
  13223. /// 团组模块 - 出入境费用报价表 - 团组名称列表
  13224. /// </summary>
  13225. /// <returns></returns>
  13226. [HttpPost]
  13227. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13228. public async Task<IActionResult> EnterExitCostQuoteGroupNameList(EnterExitCostQuoteGroupNameListDto dto)
  13229. {
  13230. return Ok(await _enterExitCostQuoteRep.GroupNameListAsync(dto));
  13231. }
  13232. /// <summary>
  13233. /// 团组模块 - 出入境费用报价表 - 根据团组Id获出入境费用相关信息
  13234. /// </summary>
  13235. /// <returns></returns>
  13236. [HttpPost]
  13237. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13238. public async Task<IActionResult> EnterExitCostQuoteEntryExitCosts(EnterExitCostInfobyDiIdDto dto)
  13239. {
  13240. int groupId = dto.DiId,
  13241. currUserId = dto.CurrUserId;
  13242. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId;"));
  13243. if (currUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId;"));
  13244. //验证报价数据是否存在
  13245. var isNull = await _sqlSugar.Queryable<Grp_EnterExitCostQuote>().FirstAsync(x => x.IsDel == 0 && x.GroupId == dto.DiId);
  13246. if (isNull != null)
  13247. {
  13248. var info1 = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { Id = isNull.Id });
  13249. if (!info1.Rates.Any())
  13250. {
  13251. var rates = await GeneralMethod.EnterExitCostInitRate();
  13252. rates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  13253. info1.Rates = rates.ToArray();
  13254. }
  13255. return Ok(JsonView(info1));
  13256. }
  13257. var result = await _enterExitCostQuoteRep.InfoByGroupIdAsync(dto.DiId);
  13258. result.GroupId = groupId;
  13259. //处理报价名称
  13260. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.DiId && x.IsDel == 0);
  13261. if (groupInfo != null)
  13262. {
  13263. var visitCountry = groupInfo.VisitCountry;
  13264. if (!string.IsNullOrEmpty(visitCountry))
  13265. {
  13266. string quoteName = string.Empty;
  13267. if (visitCountry.Contains("|"))
  13268. {
  13269. var countrys = visitCountry.Split("|");
  13270. quoteName = string.Join("、", countrys);
  13271. }
  13272. else quoteName = visitCountry;
  13273. quoteName += $"团组报价表";
  13274. result.Name = quoteName;
  13275. }
  13276. }
  13277. var info = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  13278. if (info.Code != StatusCodes.Status200OK)
  13279. {
  13280. if (!result.Rates.Any())
  13281. {
  13282. var rates = await GeneralMethod.EnterExitCostInitRate();
  13283. result.Rates = rates.ToArray();
  13284. }
  13285. return Ok(JsonView(true, $"出入境费用明细未填写!", result));
  13286. }
  13287. var infoView = info.Data as EnterExitCostInfoView;
  13288. if (infoView == null) return Ok(JsonView(false, "数据类型转换失败!;"));
  13289. var countryFees = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).ToListAsync();
  13290. var cityFilter = new List<string>() { "全部城市", "其他城市" };
  13291. var currencys = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  13292. var eecRates = infoView.Currencys;
  13293. //默认添加人名币
  13294. if (!eecRates.Any(x => x.CurrencyCode.Equals("CNY")))
  13295. {
  13296. eecRates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  13297. }
  13298. //处理团组人数
  13299. int pplNum = 1;
  13300. if (groupInfo != null) pplNum = groupInfo.VisitPNumber;
  13301. var views = new List<QuoteSubItemInfo>();
  13302. #region 数据填充
  13303. var intTravelCosts = new List<QuoteSubItemInfo>();
  13304. #region 机票费用 1354
  13305. int intTravelIndex = 1;
  13306. if (infoView.SumJJC == 1)
  13307. {
  13308. intTravelCosts.Add(new QuoteSubItemInfo
  13309. {
  13310. ItemId = 1354,
  13311. Index = intTravelIndex,
  13312. FeeName = "经济舱",
  13313. UnitPrice = infoView.AirJJ,
  13314. Currency = "CNY",
  13315. Quantity = 1,
  13316. PplNum = 1,
  13317. TotalAmt = infoView.AirJJ,
  13318. Remark = "",
  13319. });
  13320. intTravelIndex++;
  13321. }
  13322. if (infoView.SumGWC == 1)
  13323. {
  13324. intTravelCosts.Add(new QuoteSubItemInfo
  13325. {
  13326. ItemId = 1354,
  13327. Index = intTravelIndex,
  13328. FeeName = "公务舱",
  13329. UnitPrice = infoView.AirGW,
  13330. Currency = "CNY",
  13331. Quantity = 1,
  13332. PplNum = 1,
  13333. TotalAmt = infoView.AirGW,
  13334. Remark = "",
  13335. });
  13336. intTravelIndex++;
  13337. }
  13338. if (infoView.SumTDC == 1)
  13339. {
  13340. intTravelCosts.Add(new QuoteSubItemInfo
  13341. {
  13342. ItemId = 1354,
  13343. Index = intTravelIndex,
  13344. FeeName = "头等舱",
  13345. UnitPrice = infoView.AirTD,
  13346. Currency = "CNY",
  13347. Quantity = 1,
  13348. PplNum = 1,
  13349. TotalAmt = infoView.AirTD,
  13350. Remark = "",
  13351. });
  13352. intTravelIndex++;
  13353. }
  13354. intTravelCosts.Add(new QuoteSubItemInfo
  13355. {
  13356. ItemId = 1354,
  13357. Index = intTravelIndex,
  13358. FeeName = "城市间交通费用(经济舱)",
  13359. UnitPrice = infoView.CityTranffic,
  13360. Currency = "CNY",
  13361. Quantity = 1,
  13362. PplNum = pplNum,
  13363. TotalAmt = infoView.CityTranffic * pplNum,
  13364. Remark = "",
  13365. });
  13366. intTravelCosts.Add(new QuoteSubItemInfo
  13367. {
  13368. ItemId = 1354,
  13369. Index = intTravelIndex,
  13370. FeeName = "城市间交通费用(公务舱)",
  13371. UnitPrice = infoView.CityTranffic1,
  13372. Currency = "CNY",
  13373. Quantity = 1,
  13374. PplNum = pplNum,
  13375. TotalAmt = infoView.CityTranffic1 * pplNum,
  13376. Remark = "",
  13377. });
  13378. intTravelCosts.Add(new QuoteSubItemInfo
  13379. {
  13380. ItemId = 1354,
  13381. Index = intTravelIndex,
  13382. FeeName = "城市间交通费用(头等舱)",
  13383. UnitPrice = infoView.CityTranffic2,
  13384. Currency = "CNY",
  13385. Quantity = 1,
  13386. PplNum = pplNum,
  13387. TotalAmt = infoView.CityTranffic2 * pplNum,
  13388. Remark = "",
  13389. });
  13390. views.AddRange(intTravelCosts);
  13391. #endregion
  13392. var accomCosts = new List<QuoteSubItemInfo>();
  13393. #region 住宿费 1355
  13394. if (infoView.QuarterageData.Any())
  13395. {
  13396. int accomIndex = 1;
  13397. int accomItemTypeId = 1355;
  13398. var groupData = infoView.QuarterageData.GroupBy(x => x.NationalTravelFeeId);
  13399. foreach (var item in groupData)
  13400. {
  13401. string feeName = string.Empty;
  13402. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  13403. if (countryInfo != null)
  13404. {
  13405. feeName = countryInfo.Country;
  13406. var city = countryInfo.City;
  13407. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  13408. {
  13409. feeName += $"-{city}";
  13410. }
  13411. }
  13412. var hotelInfo = item.FirstOrDefault();
  13413. if (hotelInfo == null) continue;
  13414. var thisCurrency = currencys.FirstOrDefault(x => x.Id == hotelInfo.Currency)?.Name ?? "nuknow";
  13415. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  13416. int quantity = item.ToList().Count;
  13417. accomCosts.Add(new QuoteSubItemInfo
  13418. {
  13419. ItemId = accomItemTypeId,
  13420. Index = accomIndex,
  13421. FeeName = feeName,
  13422. UnitPrice = hotelInfo.Cost,
  13423. Currency = thisCurrency,
  13424. Quantity = quantity,
  13425. PplNum = pplNum,
  13426. TotalAmt = hotelInfo.Cost * thisRate * quantity * pplNum,
  13427. Remark = "",
  13428. });
  13429. accomIndex++;
  13430. }
  13431. views.AddRange(accomCosts);
  13432. }
  13433. #endregion
  13434. var mealCosts = new List<QuoteSubItemInfo>();
  13435. #region 餐饮费 1356
  13436. if (infoView.BoardWagesData.Any())
  13437. {
  13438. var mealIndex = 1;
  13439. int mealItemTypeId = 1356;
  13440. var groupData = infoView.BoardWagesData.GroupBy(x => x.NationalTravelFeeId);
  13441. foreach (var item in groupData)
  13442. {
  13443. string feeName = string.Empty;
  13444. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  13445. if (countryInfo != null)
  13446. {
  13447. feeName = countryInfo.Country;
  13448. var city = countryInfo.City;
  13449. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  13450. {
  13451. feeName += $"-{city}";
  13452. }
  13453. }
  13454. var mealInfo = item.FirstOrDefault();
  13455. if (mealInfo == null) continue;
  13456. var thisCurrency = currencys.FirstOrDefault(x => x.Id == mealInfo.Currency)?.Name ?? "nuknow";
  13457. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  13458. int quantity = item.ToList().Count;
  13459. mealCosts.Add(new QuoteSubItemInfo
  13460. {
  13461. ItemId = mealItemTypeId,
  13462. Index = mealIndex,
  13463. FeeName = feeName,
  13464. UnitPrice = mealInfo.Cost,
  13465. Currency = thisCurrency,
  13466. Quantity = quantity,
  13467. PplNum = pplNum,
  13468. TotalAmt = mealInfo.Cost * thisRate * quantity * pplNum,
  13469. Remark = "",
  13470. });
  13471. mealIndex++;
  13472. }
  13473. views.AddRange(mealCosts);
  13474. }
  13475. #endregion
  13476. var miscCosts = new List<QuoteSubItemInfo>();
  13477. #region 公杂费 1364
  13478. if (infoView.MiscellaneousFeeData.Any())
  13479. {
  13480. var miscIndex = 1;
  13481. int miscItemTypeId = 1364;
  13482. var groupData = infoView.MiscellaneousFeeData.GroupBy(x => x.NationalTravelFeeId);
  13483. foreach (var item in groupData)
  13484. {
  13485. string feeName = string.Empty;
  13486. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  13487. if (countryInfo != null)
  13488. {
  13489. feeName = countryInfo.Country;
  13490. var city = countryInfo.City;
  13491. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  13492. {
  13493. feeName += $"-{city}";
  13494. }
  13495. }
  13496. var miscInfo = item.FirstOrDefault();
  13497. if (miscInfo == null) continue;
  13498. var thisCurrency = currencys.FirstOrDefault(x => x.Id == miscInfo.Currency)?.Name ?? "nuknow";
  13499. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  13500. int quantity = item.ToList().Count;
  13501. miscCosts.Add(new QuoteSubItemInfo
  13502. {
  13503. ItemId = miscItemTypeId,
  13504. Index = miscIndex,
  13505. FeeName = feeName,
  13506. UnitPrice = miscInfo.Cost,
  13507. Currency = thisCurrency,
  13508. Quantity = quantity,
  13509. PplNum = pplNum,
  13510. TotalAmt = miscInfo.Cost * thisRate * quantity * pplNum,
  13511. Remark = "",
  13512. });
  13513. miscIndex++;
  13514. }
  13515. views.AddRange(miscCosts);
  13516. }
  13517. #endregion
  13518. #region 签证+保险 1362
  13519. int visaInsIndex = 1;
  13520. int visaInsItemTypeId = 1362;
  13521. if (infoView.Visa > 0)
  13522. {
  13523. views.Add(new QuoteSubItemInfo()
  13524. {
  13525. ItemId = visaInsItemTypeId,
  13526. Index = visaInsIndex,
  13527. FeeName = $"签证",
  13528. UnitPrice = infoView.Visa,
  13529. Currency = $"CNY",
  13530. Quantity = 1,
  13531. PplNum = pplNum,
  13532. TotalAmt = infoView.Visa * pplNum,
  13533. Remark = "",
  13534. });
  13535. visaInsIndex++;
  13536. }
  13537. if (infoView.Safe > 0)
  13538. {
  13539. views.Add(new QuoteSubItemInfo()
  13540. {
  13541. ItemId = visaInsItemTypeId,
  13542. Index = visaInsIndex,
  13543. FeeName = $"保险",
  13544. UnitPrice = infoView.Safe,
  13545. Currency = $"CNY",
  13546. Quantity = 1,
  13547. PplNum = pplNum,
  13548. TotalAmt = infoView.Safe * pplNum,
  13549. Remark = "",
  13550. });
  13551. }
  13552. #endregion
  13553. #region 服务费 1363
  13554. int serviceFeeIndex = 1;
  13555. int serviceFeeItemTypeId = 1363;
  13556. if (infoView.Service > 0)
  13557. {
  13558. views.Add(new QuoteSubItemInfo()
  13559. {
  13560. ItemId = serviceFeeItemTypeId,
  13561. Index = serviceFeeIndex,
  13562. FeeName = $"服务费",
  13563. UnitPrice = infoView.Service,
  13564. Currency = $"CNY",
  13565. Quantity = 1,
  13566. PplNum = pplNum,
  13567. TotalAmt = infoView.Service * pplNum,
  13568. Remark = "",
  13569. });
  13570. }
  13571. #endregion
  13572. #endregion
  13573. if (result.FeeItems.Any())
  13574. {
  13575. result.FeeItems.Select(x =>
  13576. {
  13577. var feeInfos = views.Where(y => y.ItemId == x.ItemId).OrderBy(y => y.Index).ToArray();
  13578. if (feeInfos.Any()) x.Infos = feeInfos;
  13579. return x;
  13580. }
  13581. ).OrderBy(x => x.Index)
  13582. .ToList();
  13583. if (!result.Rates.Any())
  13584. {
  13585. if (eecRates.Any()) result.Rates = eecRates?.ToArray() ?? Array.Empty<CurrencyInfo>();
  13586. else
  13587. {
  13588. var rates = await GeneralMethod.EnterExitCostInitRate();
  13589. rates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  13590. result.Rates = rates.ToArray();
  13591. }
  13592. }
  13593. }
  13594. return Ok(JsonView(result));
  13595. }
  13596. /// <summary>
  13597. /// 团组模块 - 出入境费用报价表 - Info
  13598. /// </summary>
  13599. /// <returns></returns>
  13600. [HttpPost]
  13601. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13602. public async Task<IActionResult> EnterExitCostQuoteInfo(EnterExitCostQuoteInfoDto dto)
  13603. {
  13604. var info = await _enterExitCostQuoteRep.InfoAsync(dto);
  13605. if (!info.Rates.Any())
  13606. {
  13607. var rates = await GeneralMethod.EnterExitCostInitRate();
  13608. rates.Add(new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  13609. info.Rates = rates.ToArray();
  13610. }
  13611. return Ok(JsonView(info));
  13612. }
  13613. /// <summary>
  13614. /// 团组模块 - 出入境费用报价表 - OP
  13615. /// </summary>
  13616. /// <returns></returns>
  13617. [HttpPost]
  13618. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13619. public async Task<IActionResult> EnterExitCostQuoteOp(EnterExitCostQuoteOpDto dto)
  13620. {
  13621. return Ok(await _enterExitCostQuoteRep.OpAsync(dto));
  13622. }
  13623. /// <summary>
  13624. /// 团组模块 - 出入境费用报价表 - 删除 项
  13625. /// </summary>
  13626. /// <returns></returns>
  13627. [HttpPost]
  13628. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13629. public async Task<IActionResult> EnterExitCostQuoteItemDel(EnterExitCostQuoteItemDelDto dto)
  13630. {
  13631. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  13632. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  13633. return Ok(await _enterExitCostQuoteRep.ItemDelAsync(dto));
  13634. }
  13635. /// <summary>
  13636. /// 团组模块 - 出入境费用报价表 - 导出
  13637. /// </summary>
  13638. /// <returns></returns>
  13639. [HttpPost]
  13640. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13641. public async Task<IActionResult> EnterExitCostQuoteExcelExport(EnterExitCostQuoteExcelExportDto dto)
  13642. {
  13643. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  13644. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  13645. var info = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { Id = dto.Id });
  13646. if (info == null) return Ok(JsonView(false, "报价信息未填写!"));
  13647. var rates = info.Rates;
  13648. var intTravelCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1354);//国际旅费
  13649. var accomCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1355); //住宿费
  13650. var mealCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1356); //餐饮费
  13651. var vehArranges = info.FeeItems.FirstOrDefault(x => x.ItemId == 1357); //车辆安排
  13652. var inviteTo = info.FeeItems.FirstOrDefault(x => x.ItemId == 1358); //邀请函发放对象
  13653. var inviteCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1359); //邀请函费用
  13654. var inviteTime = info.FeeItems.FirstOrDefault(x => x.ItemId == 1360); //邀请函发放时间
  13655. var officialActs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1361); //公务活动
  13656. var visaIns = info.FeeItems.FirstOrDefault(x => x.ItemId == 1362); //签证+保险
  13657. var serviceCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1363); //服务费
  13658. var pubMiscs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1364); //公杂费
  13659. var taxCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1365); //税费
  13660. //获取模板
  13661. string tempPath = AppSettingsHelper.Get("ExcelBasePath") + "Template/出入境费用明细报价表模板.xlsx";
  13662. var designer = new WorkbookDesigner();
  13663. designer.Workbook = new Workbook(tempPath);
  13664. designer.SetDataSource("QuoteName", info.Name);
  13665. designer.SetDataSource("CompanyTitle", "公司名称");
  13666. designer.SetDataSource("CompanyLabel", "");
  13667. #region 国际旅费
  13668. designer.SetDataSource("IntTravelTitle", intTravelCosts?.ItemWrapName ?? "国际旅费\r\n(公务舱和经济舱分别罗列)");
  13669. if (intTravelCosts != null && intTravelCosts.Infos.Any())
  13670. {
  13671. var cabClassFilter = new string[] { "经济舱", "公务舱", "头等舱" };
  13672. var label = new StringBuilder();
  13673. var infos = intTravelCosts.Infos.Where(x => cabClassFilter.Contains(x.FeeName)).ToArray();
  13674. if (infos.Any())
  13675. {
  13676. label.Append(infos.Sum(x => x.PplNum));
  13677. label.Append("人全程机票:");
  13678. label.Append(infos.Sum(x => x.TotalAmt).TruncDecimals(2));
  13679. label.AppendLine("元");
  13680. }
  13681. foreach (var item in intTravelCosts.Infos)
  13682. {
  13683. label.Append(item.FeeName);
  13684. label.Append(":");
  13685. label.Append(item.UnitPrice.TruncDecimals(2));
  13686. label.Append("元/人*");
  13687. label.Append(item.PplNum);
  13688. label.AppendLine("人");
  13689. }
  13690. if (label.HasValue())
  13691. {
  13692. label.Append("\r\n以上小计:");
  13693. label.Append(intTravelCosts.TotalAmt.TruncDecimals(2));
  13694. label.Append("元");
  13695. }
  13696. designer.SetDataSource("IntTravelLabel", label.ToString());
  13697. }
  13698. #endregion
  13699. #region 住宿费
  13700. designer.SetDataSource("AccomTitle", accomCosts?.ItemWrapName ?? "住宿费\r\n(请备注明酒店星级)");
  13701. if (accomCosts != null && accomCosts.Infos.Any())
  13702. {
  13703. string currencyName = string.Empty,
  13704. countryName = string.Empty;
  13705. decimal rate = 1.0000M;
  13706. var label = new StringBuilder();
  13707. label.AppendLine("全程五星酒店,每人1间房");
  13708. foreach (var item in accomCosts.Infos)
  13709. {
  13710. //乌兹别克斯坦: 塔什干:120美金/间/晚*2*6人
  13711. string name = string.Empty, thisCountryName = string.Empty;
  13712. if (item.FeeName.Contains('-'))
  13713. {
  13714. var feeName = item.FeeName.Split('-');
  13715. thisCountryName = feeName[0];
  13716. if (!thisCountryName.Equals(countryName)) countryName = feeName[0];
  13717. name = feeName[1];
  13718. }
  13719. else name = item.FeeName;
  13720. string thisFeeName = string.Empty;
  13721. if (!thisCountryName.Equals(countryName)) thisFeeName = $"{countryName}:\r\n{name}:";
  13722. else thisFeeName = $"\r\n{name}:";
  13723. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  13724. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  13725. rate = rateInfo?.Rate ?? 1.0000M;
  13726. string subLabel = string.Format("{0}{1}{2}/间/晚*{3}*{4}人", thisFeeName, item.UnitPrice.TruncDecimals(2), currencyName, item.Quantity.ToString("#0"), item.PplNum.ToString("#0"));
  13727. label.AppendLine(subLabel);
  13728. }
  13729. if (label.HasValue())
  13730. {
  13731. //以上小计:52440元(美金汇率:7.5 )
  13732. string subLabel = string.Format("\r\n以上小计:{0}元({1}汇率:{2})", accomCosts.TotalAmt.TruncDecimals(2), currencyName, rate.TruncDecimals(4));
  13733. label.AppendLine(subLabel);
  13734. }
  13735. designer.SetDataSource("AccomLabel", label.ToString());
  13736. }
  13737. #endregion
  13738. #region 餐饮费
  13739. designer.SetDataSource("MealTitle", mealCosts?.ItemWrapName ?? "餐饮费");
  13740. if (mealCosts != null && mealCosts.Infos.Any())
  13741. {
  13742. string currencyName = string.Empty;
  13743. decimal rate = 1.0000M;
  13744. var label = new StringBuilder();
  13745. label.Append("全程酒店含早,\r\n若因航班过早,\r\n酒店准备路早。\r\n\r\n");
  13746. foreach (var item in mealCosts.Infos)
  13747. {
  13748. string name = string.Empty;
  13749. if (item.FeeName.Contains('-'))
  13750. {
  13751. var feeName = item.FeeName.Split('-');
  13752. name = $"\r\n{feeName[0]}:\r\n{feeName[1]}:";
  13753. }
  13754. else name = $"\r\n{item.FeeName}:";
  13755. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  13756. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  13757. rate = rateInfo?.Rate ?? 1.0000M;
  13758. label.Append(name);
  13759. label.Append(item.UnitPrice.TruncDecimals(2));
  13760. label.Append(currencyName);
  13761. label.Append("/天*");
  13762. label.Append(item.Quantity.ToString("#0"));
  13763. label.Append('*');
  13764. label.Append(item.PplNum);
  13765. label.Append("人\r\n");
  13766. }
  13767. if (label.HasValue())
  13768. {
  13769. label.Append("\r\n以上小计:");
  13770. label.Append(accomCosts.TotalAmt.TruncDecimals(2));
  13771. label.Append("元\r\n(");
  13772. label.Append("汇率:");
  13773. label.Append(rate.TruncDecimals(4));
  13774. label.Append(')');
  13775. }
  13776. designer.SetDataSource("MealLabel", label.ToString());
  13777. }
  13778. #endregion
  13779. #region 车辆安排
  13780. designer.SetDataSource("VehArrangeTitle", vehArranges?.ItemWrapName ?? "车辆安排\r\n(司兼导分开的情况下,车辆品牌、座位及费用)");
  13781. if (vehArranges != null && vehArranges.Infos.Any())
  13782. {
  13783. string currencyName = string.Empty;
  13784. //decimal rate = 1.0000M;
  13785. var label = new StringBuilder();
  13786. foreach (var item in vehArranges.Infos)
  13787. {
  13788. label.AppendLine();
  13789. label.AppendLine();
  13790. label.Append(item.FeeName);
  13791. label.Append($"\r\n\r\n费用:{item.TotalAmt.TruncDecimals(2)}元");
  13792. }
  13793. designer.SetDataSource("VehArrangeLabel", label.ToString());
  13794. }
  13795. #endregion
  13796. #region 邀请函发放对象
  13797. designer.SetDataSource("InviteToTitle", inviteTo?.ItemWrapName ?? "邀请函发放对象");
  13798. designer.SetDataSource("InviteToContent", "");
  13799. #endregion
  13800. #region 邀请函费
  13801. designer.SetDataSource("InviteCostTitle", inviteCosts?.ItemWrapName ?? "邀请函费用");
  13802. var is_label = new StringBuilder();
  13803. if (inviteCosts != null && inviteCosts.Infos.Any())
  13804. {
  13805. string currencyName = string.Empty;
  13806. decimal rate = 1.0000M;
  13807. foreach (var item in inviteCosts.Infos)
  13808. {
  13809. //乌兹别克斯坦:2000美金
  13810. currencyName = item.Currency;
  13811. rate = rates.FirstOrDefault(x => currencyName.Equals(x.CurrencyCode))?.Rate ?? 1.0000M;
  13812. string label = string.Format("{0}:{1}{2}", item.FeeName, item.UnitPrice.TruncDecimals(2), currencyName);
  13813. is_label.AppendLine(label);
  13814. }
  13815. if (is_label.HasValue())
  13816. {
  13817. //以上小计:28500元(美金汇率:7.5)
  13818. string label = string.Format("以上小计:{0}{1}({2}汇率:{3})", inviteCosts.TotalAmt.TruncDecimals(2), "元", currencyName, rate.TruncDecimals(4));
  13819. is_label.AppendLine(label);
  13820. }
  13821. }
  13822. designer.SetDataSource("InviteCostContent", is_label.ToString());
  13823. #endregion
  13824. #region 邀请函发放时间
  13825. designer.SetDataSource("InviteToTimeTitle", inviteTime?.ItemWrapName ?? "邀请函发放时间");
  13826. designer.SetDataSource("InviteToTimeContent", "拿到团员名单10-15工作日");
  13827. #endregion
  13828. #region 公务活动(含翻译)
  13829. designer.SetDataSource("OfficialActsTitle", officialActs?.ItemWrapName ?? "公务活动(含翻译)");
  13830. var oa_label = new StringBuilder();
  13831. if (officialActs != null && officialActs.Infos.Any())
  13832. {
  13833. string currencyName = string.Empty;
  13834. decimal rate = 1.0000M;
  13835. string label_title = string.Empty, label_content = "超出报价部分需额付费:\r\n";
  13836. foreach (var item in officialActs.Infos)
  13837. {
  13838. //乌兹别克斯坦:1000美金/场
  13839. currencyName = item.Currency;
  13840. rate = rates.FirstOrDefault(x => currencyName.Equals(x.CurrencyCode))?.Rate ?? 1.0000M;
  13841. string label_remark = string.Empty;
  13842. if (!string.IsNullOrEmpty(item.Remark)) label_remark = $"({item.Remark})";
  13843. label_content += string.Format("{0}:{1}{2}/场{3}\r\n", item.FeeName, item.UnitPrice.TruncDecimals(2), currencyName, label_remark);
  13844. }
  13845. label_content += "*总费用中未含超出公务活动价格";
  13846. //8场公务活动(以上小计:60000元)
  13847. var quantity = officialActs.Infos.Sum(x => x.Quantity);
  13848. label_title = string.Format("{0}场公务活动(以上小计:{1}元)", quantity, officialActs.TotalAmt.TruncDecimals(2));
  13849. oa_label.AppendLine(label_title);
  13850. oa_label.AppendLine(label_content);
  13851. }
  13852. designer.SetDataSource("OfficialActsContent", oa_label.ToString());
  13853. #endregion
  13854. #region 签证+保险
  13855. designer.SetDataSource("VisaInsTitle", visaIns?.ItemWrapName ?? "签证+保险\r\n(单位:元)");
  13856. var vi_label = new StringBuilder();
  13857. if (visaIns != null && visaIns.Infos.Any())
  13858. {
  13859. foreach (var item in visaIns.Infos)
  13860. {
  13861. //签证:500元/人
  13862. string label = string.Format("{0}:{1}元/人*{2}人", item.FeeName, item.UnitPrice.TruncDecimals(2), item.PplNum);
  13863. vi_label.AppendLine(label);
  13864. }
  13865. if (vi_label.HasValue())
  13866. {
  13867. //以上小计:6000元
  13868. string label = string.Format("以上小计:{0}元", visaIns.TotalAmt.TruncDecimals(2));
  13869. vi_label.AppendLine(label);
  13870. }
  13871. }
  13872. designer.SetDataSource("VisaInsContent", vi_label.ToString());
  13873. #endregion
  13874. #region 服务费
  13875. designer.SetDataSource("ServiceCostTitle", serviceCosts?.ItemWrapName ?? "服务费");
  13876. designer.SetDataSource("ServiceCostContent", serviceCosts?.TotalAmt.TruncDecimals(2) ?? 0.00M);
  13877. #endregion
  13878. #region 公杂费
  13879. designer.SetDataSource("PubMiscsTitle", pubMiscs?.ItemWrapName ?? "公杂费\r\n(发给团组成员)");
  13880. var pm_label = new StringBuilder();
  13881. if (pubMiscs != null && pubMiscs.Infos.Any())
  13882. {
  13883. string currencyName = string.Empty,
  13884. countryName = string.Empty;
  13885. decimal rate = 1.0000M;
  13886. foreach (var item in pubMiscs.Infos)
  13887. {
  13888. //乌兹别克斯坦:塔什干:32美金 / 天 * 3 * 6人
  13889. string name = string.Empty, thisCountryName = string.Empty;
  13890. if (item.FeeName.Contains('-'))
  13891. {
  13892. var feeName = item.FeeName.Split('-');
  13893. thisCountryName = feeName[0];
  13894. if (!thisCountryName.Equals(countryName)) countryName = feeName[0];
  13895. name = feeName[1];
  13896. }
  13897. else name = item.FeeName;
  13898. string thisFeeName = string.Empty;
  13899. if (!thisCountryName.Equals(countryName)) thisFeeName = $"{countryName}:\r\n{name}:";
  13900. else thisFeeName = $"\r\n{name}:";
  13901. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  13902. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  13903. rate = rateInfo?.Rate ?? 1.0000M;
  13904. string label = string.Format("{0}:{1}{2}/天*{3}*{4}人", thisFeeName, item.UnitPrice.TruncDecimals(2), currencyName, item.Quantity, item.PplNum);
  13905. pm_label.AppendLine(label);
  13906. }
  13907. if (pm_label.HasValue())
  13908. {
  13909. //以上小计:13497.6元\r\n(美金汇率:7.5 )\r\n部分发放成员
  13910. pm_label.AppendLine(string.Format("以上小计:{0}元", pubMiscs.TotalAmt.TruncDecimals(2)));
  13911. pm_label.AppendLine(string.Format("({0}汇率:{1})", currencyName, rate.TruncDecimals(4)));
  13912. pm_label.AppendLine(string.Format("部分发放成员"));
  13913. }
  13914. }
  13915. designer.SetDataSource("PubMiscsContent", pm_label.ToString());
  13916. #endregion
  13917. #region 税费
  13918. designer.SetDataSource("TaxCostTitle", taxCosts?.ItemWrapName ?? "税费");
  13919. designer.SetDataSource("TaxCostContent", taxCosts?.TotalAmt.TruncDecimals(2) ?? 0.00M);
  13920. #endregion
  13921. #region 合计(单位:元)
  13922. designer.SetDataSource("CostTotalTitle", "合计\r\n(单位:元)");
  13923. designer.SetDataSource("CostTotalContent", info.FeeItems.Sum(x => x.TotalAmt).TruncDecimals(2));
  13924. #endregion
  13925. #region 汇率 Remark
  13926. var rate_label = new StringBuilder();
  13927. var rateGroups = rates.GroupBy(x => x.CurrencyName);
  13928. foreach (var item in rateGroups)
  13929. {
  13930. //美元汇率按\r\n1:7.5
  13931. string label = string.Format("{0}汇率按\r\n1:{1}", item.Key, item.FirstOrDefault()?.Rate.TruncDecimals(4) ?? 0.0000M);
  13932. rate_label.AppendLine(label);
  13933. }
  13934. designer.SetDataSource("RateLabel", rate_label.ToString());
  13935. #endregion
  13936. designer.Process();
  13937. //文件名
  13938. string fileName = $"{info.Name}{DateTime.Now:yyyyMMddHHmmss}.xls";
  13939. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + "EnterExitCostQuote/" + fileName);
  13940. string url = AppSettingsHelper.Get("ExcelBaseUrl") + "Office/Excel/EnterExitCostQuote/" + fileName;
  13941. return Ok(JsonView(true, "成功", url));
  13942. }
  13943. #endregion
  13944. #region 签证费用录入
  13945. /// <summary>
  13946. /// 根据diid查询签证费用列表
  13947. /// </summary>
  13948. /// <param name="dto"></param>
  13949. /// <returns></returns>
  13950. [HttpPost]
  13951. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13952. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  13953. {
  13954. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  13955. if (groupData.Code != 0)
  13956. {
  13957. return Ok(JsonView(false, groupData.Msg));
  13958. }
  13959. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  13960. }
  13961. /// <summary>
  13962. /// 根据签证费用Id查询单条数据及c表数据
  13963. /// </summary>
  13964. /// <param name="dto"></param>
  13965. /// <returns></returns>
  13966. [HttpPost]
  13967. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13968. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  13969. {
  13970. Result groupData = await _visaPriceRep.PostVisaById(dto);
  13971. if (groupData.Code != 0)
  13972. {
  13973. return Ok(JsonView(false, groupData.Msg));
  13974. }
  13975. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  13976. }
  13977. /// <summary>
  13978. /// 签证费用删除
  13979. /// </summary>
  13980. /// <param name="dto"></param>
  13981. /// <returns></returns>
  13982. [HttpPost]
  13983. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13984. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  13985. {
  13986. _sqlSugar.BeginTran();
  13987. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  13988. if (!res)
  13989. {
  13990. _sqlSugar.RollbackTran();
  13991. return Ok(JsonView(false, "删除失败"));
  13992. }
  13993. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  13994. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  13995. .SetColumns(a => new Grp_CreditCardPayment()
  13996. {
  13997. IsDel = 1,
  13998. DeleteUserId = dto.DeleteUserId,
  13999. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  14000. })
  14001. .ExecuteCommand();
  14002. if (resSub < 1)
  14003. {
  14004. _sqlSugar.RollbackTran();
  14005. return Ok(JsonView(false, "删除失败"));
  14006. }
  14007. _sqlSugar.CommitTran();
  14008. return Ok(JsonView(true, "删除成功!"));
  14009. }
  14010. /// <summary>
  14011. /// 签证费用录入下拉框初始化
  14012. /// </summary>
  14013. /// <returns></returns>
  14014. [HttpPost]
  14015. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14016. public async Task<IActionResult> VisaPriceAddSelect()
  14017. {
  14018. //支付方式
  14019. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  14020. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  14021. //币种
  14022. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  14023. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  14024. //乘客类型
  14025. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  14026. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  14027. //卡类型
  14028. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  14029. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  14030. //代办费类型
  14031. var agencyFeeTypeData = new List<dynamic>() {
  14032. new { id = 0 , Text = "未选择" },
  14033. new { id = 1 , Text = "小公务" },
  14034. new { id = 2 , Text = "大公务" },
  14035. };
  14036. //签证费用标准国家Data
  14037. var visaSql = string.Format(@"select
  14038. id,
  14039. case
  14040. when FeeType = 0 then Country+'(因公)'
  14041. when FeeType = 1 then Country+'(因私)'
  14042. else Country+'(未设置)'
  14043. end as 'country'
  14044. from Res_VisaFeeStandard where isdel = 0");
  14045. var visaCountryFeeData = _sqlSugar.SqlQueryable<dynamic>(visaSql).ToList();
  14046. var data = new
  14047. {
  14048. Payment = _Payment,
  14049. CurrencyList = _CurrencyList,
  14050. PassengerType = _PassengerType,
  14051. BankCard = _BankCard,
  14052. AgencyFeeType = agencyFeeTypeData,
  14053. CountryFeeData = visaCountryFeeData
  14054. };
  14055. return Ok(JsonView(true, "查询成功!", data));
  14056. }
  14057. /// <summary>
  14058. /// 签证费用录入操作(Status:1.新增,2.修改)
  14059. /// </summary>
  14060. /// <param name="dto"></param>
  14061. /// <returns></returns>
  14062. [HttpPost]
  14063. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14064. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  14065. {
  14066. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  14067. if (groupData.Code != 0)
  14068. {
  14069. return Ok(JsonView(false, groupData.Msg));
  14070. }
  14071. #region 应用推送
  14072. try
  14073. {
  14074. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  14075. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  14076. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  14077. //2024-10-21 新增LZ UID
  14078. var userIds = new List<int>() { 21 };
  14079. string title = $"系统通知";
  14080. string content = "";
  14081. var diId = dto.DiId;
  14082. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  14083. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  14084. if (dto.Status == 1) content = $"[新增-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  14085. else if (dto.Status == 2) content = $"[更新-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  14086. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  14087. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "80" };
  14088. await APNsTools.iOS_PushNotifications1("051", $"签证费用审核", "", content, true, "ExpenseAuditWebView", h5);
  14089. }
  14090. catch (Exception ex)
  14091. {
  14092. }
  14093. #endregion
  14094. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  14095. }
  14096. #endregion
  14097. #region 签证提成录入
  14098. /// <summary>
  14099. /// 签证提成录入
  14100. /// 基础数据
  14101. /// </summary>
  14102. /// <returns></returns>
  14103. [HttpGet]
  14104. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14105. public async Task<IActionResult> VisaCommissionInit()
  14106. {
  14107. return Ok(await _visaCommissionRep.Init());
  14108. }
  14109. /// <summary>
  14110. /// 签证提成录入
  14111. /// Item
  14112. /// </summary>
  14113. /// <param name="_dto"></param>
  14114. /// <returns></returns>
  14115. [HttpPost]
  14116. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14117. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
  14118. {
  14119. var validator = new VisaCommissionItemDtoValidator();
  14120. var validatorRes = await validator.ValidateAsync(_dto);
  14121. if (!validatorRes.IsValid)
  14122. {
  14123. var sb = new StringBuilder();
  14124. foreach (var item in validatorRes.Errors)
  14125. {
  14126. sb.AppendLine(item.ErrorMessage);
  14127. }
  14128. return Ok(JsonView(false, sb.ToString()));
  14129. }
  14130. return Ok(await _visaCommissionRep.Item(_dto));
  14131. }
  14132. /// <summary>
  14133. /// 签证提成录入
  14134. /// Save
  14135. /// </summary>
  14136. /// <param name="_dto"></param>
  14137. /// <returns></returns>
  14138. [HttpPost]
  14139. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14140. public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
  14141. {
  14142. //参数验证
  14143. if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
  14144. foreach (var item in _dto.Items)
  14145. {
  14146. if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
  14147. if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
  14148. if (string.IsNullOrEmpty(item.Country)) return Ok(JsonView(false, "国家为空!"));
  14149. //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
  14150. }
  14151. return Ok(await _visaCommissionRep.Save(_dto));
  14152. }
  14153. /// <summary>
  14154. /// 签证提成录入
  14155. /// Create
  14156. /// </summary>
  14157. /// <param name="_dto"></param>
  14158. /// <returns></returns>
  14159. [HttpPost]
  14160. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14161. public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
  14162. {
  14163. var validator = new VisaCommissionCreateDtoValidator();
  14164. var validatorRes = await validator.ValidateAsync(_dto);
  14165. if (!validatorRes.IsValid)
  14166. {
  14167. var sb = new StringBuilder();
  14168. foreach (var item in validatorRes.Errors)
  14169. {
  14170. sb.AppendLine(item.ErrorMessage);
  14171. }
  14172. return Ok(JsonView(false, sb.ToString()));
  14173. }
  14174. return Ok(await _visaCommissionRep.Create(_dto));
  14175. }
  14176. /// <summary>
  14177. /// 签证提成录入
  14178. /// Put(编辑)
  14179. /// </summary>
  14180. /// <param name="id"></param>
  14181. /// <param name="_dto"></param>
  14182. /// <returns></returns>
  14183. [HttpPut]
  14184. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14185. public async Task<IActionResult> VisaCommissionEdit(int id, VisaCommissionCreateDto _dto)
  14186. {
  14187. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  14188. var validator = new VisaCommissionCreateDtoValidator();
  14189. var validatorRes = await validator.ValidateAsync(_dto);
  14190. if (!validatorRes.IsValid)
  14191. {
  14192. var sb = new StringBuilder();
  14193. foreach (var item in validatorRes.Errors)
  14194. {
  14195. sb.AppendLine(item.ErrorMessage);
  14196. }
  14197. return Ok(JsonView(false, sb.ToString()));
  14198. }
  14199. return Ok(await _visaCommissionRep.Edit(id, _dto));
  14200. }
  14201. /// <summary>
  14202. /// 签证提成录入
  14203. /// Del
  14204. /// </summary>
  14205. /// <param name="id"></param>
  14206. /// <param name="currUserId"></param>
  14207. /// <returns></returns>
  14208. [HttpPost]
  14209. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14210. public async Task<IActionResult> VisaCommissionDel(int id, int currUserId)
  14211. {
  14212. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  14213. if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
  14214. return Ok(await _visaCommissionRep.Del(id, currUserId));
  14215. }
  14216. #endregion
  14217. #region op费用录入
  14218. /// <summary>
  14219. /// 根据diid查询op费用列表
  14220. /// </summary>
  14221. /// <param name="dto"></param>
  14222. /// <returns></returns>
  14223. [HttpPost]
  14224. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14225. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  14226. {
  14227. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  14228. if (groupData.Code != 0)
  14229. {
  14230. return Ok(JsonView(false, groupData.Msg));
  14231. }
  14232. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  14233. }
  14234. /// <summary>
  14235. /// 根据op费用Id查询单条数据及c表数据
  14236. /// </summary>
  14237. /// <param name="dto"></param>
  14238. /// <returns></returns>
  14239. [HttpPost]
  14240. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14241. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  14242. {
  14243. try
  14244. {
  14245. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  14246. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  14247. var data = new
  14248. {
  14249. CarTouristGuideGround = _groupData,
  14250. CreditCardPayment = _creditCardPayment
  14251. };
  14252. return Ok(JsonView(true, "查询成功!", data));
  14253. }
  14254. catch (Exception ex)
  14255. {
  14256. return Ok(JsonView(false, "程序错误!"));
  14257. }
  14258. }
  14259. /// <summary>
  14260. /// op费用删除
  14261. /// </summary>
  14262. /// <param name="dto"></param>
  14263. /// <returns></returns>
  14264. [HttpPost]
  14265. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14266. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  14267. {
  14268. try
  14269. {
  14270. _sqlSugar.BeginTran();
  14271. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  14272. if (!res)
  14273. {
  14274. return Ok(JsonView(false, "删除失败"));
  14275. }
  14276. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  14277. {
  14278. IsDel = 1,
  14279. DeleteUserId = dto.DeleteUserId,
  14280. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  14281. }).ExecuteCommandAsync();
  14282. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  14283. {
  14284. IsDel = 1,
  14285. DeleteUserId = dto.DeleteUserId,
  14286. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  14287. }).ExecuteCommandAsync();
  14288. #region 删除超支相关数据
  14289. //删除导入的超支数据
  14290. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  14291. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  14292. {
  14293. IsDel = 1,
  14294. DeleteUserId = dto.DeleteUserId,
  14295. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  14296. }).ExecuteCommand();
  14297. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  14298. {
  14299. IsDel = 1,
  14300. DeleteUserId = dto.DeleteUserId,
  14301. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  14302. }).ExecuteCommand();
  14303. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  14304. {
  14305. IsDel = 1,
  14306. DeleteUserId = dto.DeleteUserId,
  14307. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  14308. }).ExecuteCommand();
  14309. #endregion
  14310. _sqlSugar.CommitTran();
  14311. return Ok(JsonView(true, "删除成功!"));
  14312. }
  14313. catch (Exception ex)
  14314. {
  14315. _sqlSugar.RollbackTran();
  14316. return Ok(JsonView(false, "程序错误!" + ex.Message));
  14317. }
  14318. }
  14319. /// <summary>
  14320. /// op费用录入操作(Status:1.新增,2.修改)
  14321. /// </summary>
  14322. /// <param name="dto"></param>
  14323. /// <returns></returns>
  14324. [HttpPost]
  14325. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14326. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  14327. {
  14328. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  14329. if (groupData.Code != 0)
  14330. {
  14331. return Ok(JsonView(false, groupData.Msg));
  14332. }
  14333. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  14334. }
  14335. /// <summary>
  14336. /// 填写费用详细页面初始化绑定
  14337. /// </summary>
  14338. /// <param name="dto"></param>
  14339. /// <returns></returns>
  14340. [HttpPost]
  14341. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14342. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  14343. {
  14344. try
  14345. {
  14346. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  14347. if (groupData.Code != 0)
  14348. {
  14349. return Ok(JsonView(false, groupData.Msg));
  14350. }
  14351. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  14352. }
  14353. catch (Exception ex)
  14354. {
  14355. return Ok(JsonView(false, ex.Message));
  14356. }
  14357. }
  14358. /// <summary>
  14359. /// 根据op费用Id查询详细数据
  14360. /// </summary>
  14361. /// <param name="dto"></param>
  14362. /// <returns></returns>
  14363. [HttpPost]
  14364. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14365. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  14366. {
  14367. try
  14368. {
  14369. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  14370. if (groupData.Code != 0)
  14371. {
  14372. return Ok(JsonView(false, groupData.Msg));
  14373. }
  14374. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  14375. }
  14376. catch (Exception ex)
  14377. {
  14378. return Ok(JsonView(false, ex.Message));
  14379. }
  14380. }
  14381. /// <summary>
  14382. /// OP费用录入填写详情
  14383. /// </summary>
  14384. /// <param name="dto"></param>
  14385. /// <returns></returns>
  14386. [HttpPost]
  14387. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14388. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  14389. {
  14390. try
  14391. {
  14392. #region 参数校验
  14393. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  14394. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  14395. if (di == null) return Ok(JsonView(false, "团组错误!"));
  14396. #endregion
  14397. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  14398. if (groupData.Code != 0)
  14399. {
  14400. return Ok(JsonView(false, groupData.Msg));
  14401. }
  14402. //自动审核
  14403. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  14404. #region 尾款自动审核
  14405. var opinfos = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>()
  14406. .First(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Id == dto.CTGGRId);
  14407. if (opinfos.PriceType == 1062)
  14408. {
  14409. var isAuto = false;
  14410. //找对应的首付款
  14411. var firstPrice = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>()
  14412. .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))
  14413. .First(x => x.IsDel == 0 && x.DiId == dto.DiId && x.PriceName == opinfos.PriceName &&
  14414. x.ServiceStartTime == opinfos.ServiceStartTime && x.ServiceEndTime == opinfos.ServiceEndTime && x.Area == opinfos.Area &&
  14415. x.PriceType == 1061 && x.DiId == dto.DiId);
  14416. if (firstPrice != null && !(opinfos.SelectCheck.Contains("超时") || opinfos.SelectCheck.Contains("超支")) && firstPrice.CId == opinfos.CId)
  14417. {
  14418. var cprice = _sqlSugar.Queryable<Grp_CreditCardPayment>().First(x => x.IsDel == 0 && x.CId == firstPrice.Id && x.CTable == 79);
  14419. var balance = firstPrice.ServiceQuotedPrice * (100 - cprice.PayPercentage) / 100;
  14420. //合计中排除城市税
  14421. var cityPrice = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent>()
  14422. .Where(x => x.SId == 1452 && x.IsDel == 0 && x.DiId == dto.DiId && x.CTGGRId == dto.CTGGRId)
  14423. .Sum(x => x.Price * x.Count);
  14424. opinfos.ServiceQuotedPrice = opinfos.ServiceQuotedPrice - cityPrice;
  14425. if (balance >= opinfos.ServiceQuotedPrice)
  14426. {
  14427. isAuto = true;
  14428. }
  14429. }
  14430. if (isAuto)
  14431. {
  14432. var execCount = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  14433. .SetColumns(a => new Grp_CreditCardPayment
  14434. {
  14435. IsAuditGM = 3, //自动审核通过
  14436. AuditGMOperate = 4,
  14437. AuditGMDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  14438. })
  14439. .Where(a => a.CId == dto.CTGGRId && a.CTable == 79 && a.DIId == dto.DiId)
  14440. .ExecuteCommand();
  14441. }
  14442. }
  14443. #endregion
  14444. #region 应用推送
  14445. try
  14446. {
  14447. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  14448. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  14449. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  14450. //2024-10-21 新增LZ UID
  14451. var userIds = new List<int>() { 21 };
  14452. string title = $"系统通知";
  14453. var diId = dto.DiId;
  14454. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  14455. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  14456. string content = $"[更新-OP费用录入填写详情({groupInfo?.TeamName ?? "-"})]一项费用:{(((ccpInfo.PayMoney * ccpInfo.DayRate) / 100) * ccpInfo.PayPercentage):#0.00} CNY;";
  14457. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  14458. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "79" };
  14459. await APNsTools.iOS_PushNotifications1("051", $"OP费用审核", "", content, true, "ExpenseAuditWebView", h5);
  14460. }
  14461. catch (Exception ex)
  14462. {
  14463. }
  14464. #endregion
  14465. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  14466. }
  14467. catch (Exception ex)
  14468. {
  14469. return Ok(JsonView(false, ex.Message));
  14470. }
  14471. }
  14472. /// <summary>
  14473. /// 获取三公详细所有城市
  14474. /// </summary>
  14475. /// <returns></returns>
  14476. [HttpGet]
  14477. public IActionResult OpCarCityResult()
  14478. {
  14479. var jw = JsonView(false);
  14480. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  14481. {
  14482. x.Id,
  14483. x.Country,
  14484. x.City,
  14485. }).ToList();
  14486. if (data.Count > 0)
  14487. {
  14488. jw = JsonView(true, "获取成功!", data);
  14489. }
  14490. else
  14491. {
  14492. jw.Msg = "城市数据为空!";
  14493. jw.Data = Array.Empty<string>();
  14494. }
  14495. return Ok(jw);
  14496. }
  14497. /// <summary>
  14498. /// 导出地接费用明细
  14499. /// </summary>
  14500. /// <param name="dto"></param>
  14501. /// <returns></returns>
  14502. [HttpPost]
  14503. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  14504. {
  14505. var jw = JsonView(false);
  14506. if (dto.Diid < 1)
  14507. {
  14508. jw.Msg = "请输入正确的diid!";
  14509. return Ok(jw);
  14510. }
  14511. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  14512. if (group == null)
  14513. {
  14514. jw.Msg = "未找到团组信息!";
  14515. return Ok(jw);
  14516. }
  14517. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  14518. if (localGuideArr.Count == 0)
  14519. {
  14520. jw.Msg = "该团组暂无地接信息!";
  14521. return Ok(jw);
  14522. }
  14523. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  14524. var overspendSoure = new Dictionary<int, int>
  14525. {
  14526. { 91, 982 }, //车
  14527. { 92 , 1059} ,//导游
  14528. { 994 , 1073}, //翻译
  14529. { 988 , 1074 }, //早餐
  14530. { 93 , 1075 }, //午餐
  14531. { 989 , 1076 }, //晚餐
  14532. };
  14533. var Zips = new Dictionary<string, Stream>();
  14534. foreach (var groupArr in localGroup)
  14535. {
  14536. var keyValue = groupArr.Key;
  14537. if (int.TryParse(keyValue, out int cityid))
  14538. {
  14539. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  14540. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  14541. }
  14542. var contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  14543. foreach (var item in groupArr)
  14544. {
  14545. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  14546. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  14547. new Grp_CarTouristGuideGroundReservationsContentExtend
  14548. {
  14549. Count = a.Count,
  14550. CreateTime = a.CreateTime,
  14551. CreateUserId = a.CreateUserId,
  14552. CTGGRId = a.CTGGRId,
  14553. Currency = a.Currency,
  14554. DatePrice = a.DatePrice,
  14555. DeleteTime = a.DeleteTime,
  14556. DeleteUserId = a.DeleteUserId,
  14557. DiId = a.DiId,
  14558. Id = a.Id,
  14559. IsDel = a.IsDel,
  14560. Price = a.Price,
  14561. PriceContent = a.PriceContent,
  14562. Remark = a.Remark,
  14563. SId = a.SId,
  14564. SidName = b.Name,
  14565. Units = a.Units,
  14566. }
  14567. ).ToList();
  14568. if (content.Count > 0)
  14569. {
  14570. contentArr.Add(content);
  14571. }
  14572. }
  14573. //open excel
  14574. //set excel
  14575. //save excel
  14576. try
  14577. {
  14578. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  14579. IWorkbook workbook;
  14580. if (Path.GetExtension(filePath).ToLower() == ".xls")
  14581. {
  14582. workbook = new NPOI.HSSF.UserModel.HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  14583. }
  14584. else
  14585. {
  14586. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  14587. }
  14588. ISheet sheet = workbook.GetSheetAt(0);
  14589. var rowStartIndex = 2;
  14590. var clounmCount = 10;
  14591. var initStyleRow = sheet.GetRow(2);
  14592. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  14593. //var overspendArrDetail =
  14594. var existsId = new List<CarCompare>();
  14595. var lastElem = arr.Last();
  14596. var thisSid = -1;
  14597. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  14598. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  14599. {
  14600. Name = "未知币种!",
  14601. Remark = "未知币种!",
  14602. };
  14603. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  14604. Action cloneRowFn = () =>
  14605. {
  14606. rowStartIndex++;
  14607. var cloneRow = sheet.CreateRow(rowStartIndex);
  14608. // 复制样式
  14609. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  14610. {
  14611. ICell sourceCell = initStyleRow.GetCell(i);
  14612. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  14613. // 确保单元格存在样式
  14614. if (sourceCell.CellStyle != null)
  14615. {
  14616. targetCell.CellStyle = sourceCell.CellStyle;
  14617. }
  14618. }
  14619. };
  14620. var mergeRow = () =>
  14621. {
  14622. for (int i = 2; i < sheet.LastRowNum; i++)
  14623. {
  14624. var row = sheet.GetRow(i);
  14625. var cellFirst = row.GetCell(0);
  14626. var thisIndex = i + 1;
  14627. while (thisIndex < sheet.LastRowNum)
  14628. {
  14629. var nextRow = sheet.GetRow(thisIndex);
  14630. var nextCellFirst = nextRow.GetCell(0);
  14631. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  14632. {
  14633. thisIndex++;
  14634. }
  14635. else
  14636. {
  14637. break;
  14638. }
  14639. }
  14640. thisIndex--;
  14641. if (thisIndex != i)
  14642. {
  14643. //合并row
  14644. var cellRangeAddress = new CellRangeAddress(
  14645. i, // 起始行索引(0-based)
  14646. thisIndex, // 结束行索引(0-based)
  14647. 0, // 起始列索引(0-based)
  14648. 0 // 结束列索引(0-based)
  14649. );
  14650. sheet.AddMergedRegion(cellRangeAddress);
  14651. i = thisIndex;
  14652. }
  14653. }
  14654. };
  14655. var chaoshiNumber = 0;
  14656. var totalNumber = 0.00M;
  14657. string lastStr = "";
  14658. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  14659. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  14660. {
  14661. b.IsAuditGM,
  14662. x.Id,
  14663. x.Area,
  14664. b.PayPercentage,
  14665. b.PayMoney,
  14666. }).ToList();
  14667. string yesPayment = "", noPayment = "";
  14668. foreach (var item in queryCarArrByCityAndDiid)
  14669. {
  14670. if (item.IsAuditGM == 1)
  14671. {
  14672. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  14673. }
  14674. else
  14675. {
  14676. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  14677. }
  14678. }
  14679. lastStr = yesPayment + noPayment;
  14680. foreach (var item in arr)
  14681. {
  14682. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.ContainsValue(item.SId))
  14683. {
  14684. if (thisSid != item.SId)
  14685. {
  14686. if (thisSid == -1)
  14687. {
  14688. thisSid = item.SId;
  14689. }
  14690. else
  14691. {
  14692. //合并小计行
  14693. //创建合并区域的实例
  14694. var cellRangeAddress = new CellRangeAddress(
  14695. rowStartIndex, // 起始行索引(0-based)
  14696. rowStartIndex, // 结束行索引(0-based)
  14697. 0, // 起始列索引(0-based)
  14698. 3 // 结束列索引(0-based)
  14699. );
  14700. sheet.AddMergedRegion(cellRangeAddress);
  14701. var CellStyle = workbook.CreateCellStyle();
  14702. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  14703. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  14704. CellStyle.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground; // 填充方式
  14705. for (int i = 0; i <= clounmCount; i++)
  14706. {
  14707. if (i > 6)
  14708. {
  14709. var CellStyle1 = workbook.CreateCellStyle();
  14710. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  14711. IFont Font = workbook.CreateFont(); // 创建字体
  14712. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  14713. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  14714. CellStyle1.SetFont(Font);
  14715. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  14716. }
  14717. else
  14718. {
  14719. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  14720. }
  14721. }
  14722. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  14723. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  14724. //超时合计
  14725. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  14726. //超时数
  14727. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  14728. //超时合计费用
  14729. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  14730. thisSid = item.SId;
  14731. cloneRowFn();
  14732. chaoshiNumber = 0;
  14733. totalNumber = 0;
  14734. }
  14735. }
  14736. IRow row = sheet.GetRow(rowStartIndex);
  14737. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  14738. var isOpenOverspendSoure = overspendSoure.ContainsKey(item.SId);
  14739. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  14740. if (isOpenOverspendSoure)
  14741. {
  14742. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  14743. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  14744. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  14745. }
  14746. for (int i = 0; i <= clounmCount; i++)
  14747. {
  14748. var cell = row.GetCell(i);
  14749. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  14750. if (cell == null)
  14751. {
  14752. cell = row.CreateCell(i);
  14753. }
  14754. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  14755. fontRed.CloneStyleFrom(cell.CellStyle);
  14756. IFont Font = workbook.CreateFont(); // 创建字体
  14757. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  14758. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  14759. fontRed.SetFont(Font);
  14760. byte[] rgb = new byte[3] { 255, 242, 204 };
  14761. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  14762. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  14763. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  14764. if (workbook is XSSFWorkbook)
  14765. {
  14766. BackgroundColor255_242_204.FillForegroundColor = 0;
  14767. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  14768. BackgroundColor255_242_204.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground;
  14769. }
  14770. else
  14771. {
  14772. BackgroundColor255_242_204.FillForegroundColor = (((NPOI.HSSF.UserModel.HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  14773. }
  14774. if (i == 1 || i > 6)
  14775. {
  14776. if (i > 6)
  14777. {
  14778. fontRed.FillForegroundColor = 0;
  14779. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  14780. fontRed.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground;
  14781. }
  14782. cell.CellStyle = fontRed;
  14783. }
  14784. if (i > 2 && i < 7)
  14785. {
  14786. cell.CellStyle = BackgroundColor255_242_204;
  14787. }
  14788. cell.SetCellValue(setCellValue); //写入单元格
  14789. }
  14790. if (overspendSoure.ContainsKey(thisSid))
  14791. {
  14792. var overspendId = overspendSoure[thisSid];
  14793. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  14794. }
  14795. cloneRowFn();
  14796. existsId.Add(new CarCompare
  14797. {
  14798. DataPrice = item.DatePrice.ObjToDate(),
  14799. Sid = item.SId
  14800. });
  14801. }
  14802. if (item.Equals(lastElem))
  14803. {
  14804. //合并小计行
  14805. //创建合并区域的实例
  14806. var cellRangeAddress = new CellRangeAddress(
  14807. rowStartIndex, // 起始行索引(0-based)
  14808. rowStartIndex, // 结束行索引(0-based)
  14809. 0, // 起始列索引(0-based)
  14810. 3 // 结束列索引(0-based)
  14811. );
  14812. sheet.AddMergedRegion(cellRangeAddress);
  14813. var CellStyle = workbook.CreateCellStyle();
  14814. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  14815. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  14816. CellStyle.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground; // 填充方式
  14817. for (int i = 0; i <= clounmCount; i++)
  14818. {
  14819. if (i > 6)
  14820. {
  14821. var CellStyle1 = workbook.CreateCellStyle();
  14822. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  14823. IFont Font = workbook.CreateFont(); // 创建字体
  14824. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  14825. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  14826. CellStyle1.SetFont(Font);
  14827. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  14828. }
  14829. else
  14830. {
  14831. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  14832. }
  14833. }
  14834. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  14835. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  14836. //超时合计
  14837. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  14838. //超时数
  14839. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  14840. //超时合计费用
  14841. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  14842. cloneRowFn();
  14843. // 创建合并区域的实例
  14844. cellRangeAddress = new CellRangeAddress(
  14845. rowStartIndex, // 起始行索引(0-based)
  14846. rowStartIndex, // 结束行索引(0-based)
  14847. 0, // 起始列索引(0-based)
  14848. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  14849. );
  14850. // 添加合并区域
  14851. sheet.AddMergedRegion(cellRangeAddress);
  14852. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  14853. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  14854. }
  14855. }
  14856. mergeRow();
  14857. // 保存修改后的Excel文件到新文件
  14858. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  14859. // new FileStream(newFilePath, FileMode.CreateNew)
  14860. using (var stream = new MemoryStream())
  14861. {
  14862. workbook.Write(stream, true);
  14863. stream.Flush();
  14864. stream.Seek(0, SeekOrigin.Begin);
  14865. var memoryStream = new MemoryStream();
  14866. stream.CopyTo(memoryStream);
  14867. memoryStream.Seek(0, SeekOrigin.Begin);
  14868. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  14869. }
  14870. workbook.Close();
  14871. workbook.Dispose();
  14872. }
  14873. catch (Exception ex)
  14874. {
  14875. jw.Msg = "出现异常!" + ex.Message;
  14876. return Ok(jw);
  14877. }
  14878. }
  14879. if (Zips.Count > 0)
  14880. {
  14881. var io = new IOOperatorHelper();
  14882. var byts = io.ConvertZipStream(Zips);
  14883. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  14884. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  14885. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  14886. }
  14887. else
  14888. {
  14889. jw.Msg = "暂无生成文件!";
  14890. }
  14891. return Ok(jw);
  14892. }
  14893. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  14894. {
  14895. string outStr = string.Empty;
  14896. switch (i)
  14897. {
  14898. case 0:
  14899. outStr = arr[0].SidName;
  14900. break;
  14901. case 1:
  14902. outStr = arr[0].DataPriceStr;
  14903. break;
  14904. case 2:
  14905. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  14906. break;
  14907. case 4:
  14908. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  14909. break;
  14910. case 7:
  14911. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  14912. {
  14913. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  14914. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  14915. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  14916. }
  14917. break;
  14918. case 8:
  14919. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  14920. {
  14921. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  14922. }
  14923. break;
  14924. case 9:
  14925. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  14926. {
  14927. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  14928. }
  14929. break;
  14930. case 10:
  14931. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  14932. {
  14933. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  14934. }
  14935. break;
  14936. }
  14937. return outStr;
  14938. }
  14939. #region OP行程单
  14940. /// <summary>
  14941. /// OP行程单初始化
  14942. /// </summary>
  14943. /// <param name="dto"></param>
  14944. /// <returns></returns>
  14945. [HttpPost]
  14946. public IActionResult InitOpTravel(InitOpTravelDto dto)
  14947. {
  14948. var jw = JsonView(false);
  14949. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  14950. var group = groupList.First();
  14951. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  14952. if (group == null)
  14953. {
  14954. jw.Msg = "暂无团组!";
  14955. return Ok(jw);
  14956. }
  14957. group = groupList.Find(x => x.Id == diid);
  14958. if (group == null)
  14959. {
  14960. jw.Msg = "请输入正确的团组ID!";
  14961. return Ok(jw);
  14962. }
  14963. string city = string.Empty;
  14964. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  14965. if (blackCode.Count > 0)
  14966. {
  14967. var black = blackCode.First();
  14968. black.BlackCode = black.BlackCode ?? "";
  14969. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  14970. if (blackSp.Length > 0)
  14971. {
  14972. try
  14973. {
  14974. var cityArrCode = new List<string>(20);
  14975. foreach (var item in blackSp)
  14976. {
  14977. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  14978. var IndexSelect = itemSp[2];
  14979. var cityArrCodeLength = cityArrCode.Count - 1;
  14980. var startCity = IndexSelect.Substring(0, 3);
  14981. if (cityArrCodeLength > 0)
  14982. {
  14983. var arrEndCity = cityArrCode[cityArrCodeLength];
  14984. if (arrEndCity != startCity)
  14985. {
  14986. cityArrCode.Add(startCity.ToUpper());
  14987. }
  14988. }
  14989. else
  14990. {
  14991. cityArrCode.Add(startCity.ToUpper());
  14992. }
  14993. var endCity = IndexSelect.Substring(3, 3);
  14994. cityArrCode.Add(endCity.ToUpper());
  14995. }
  14996. var cityThree = string.Empty;
  14997. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  14998. cityThree = cityThree.TrimEnd(',');
  14999. if (string.IsNullOrWhiteSpace(cityThree))
  15000. {
  15001. throw new
  15002. Exception("error");
  15003. }
  15004. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  15005. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  15006. foreach (var item in cityArrCode)
  15007. {
  15008. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  15009. if (find != null)
  15010. {
  15011. city += find.City + "/";
  15012. }
  15013. else
  15014. {
  15015. city += item + "三字码未收入/";
  15016. }
  15017. }
  15018. city = city.TrimEnd('/');
  15019. }
  15020. catch (Exception e)
  15021. {
  15022. city = "黑屏代码格式不正确!";
  15023. }
  15024. }
  15025. }
  15026. else
  15027. {
  15028. city = "未录入黑屏代码";
  15029. }
  15030. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  15031. {
  15032. Date = x.Date,
  15033. Days = x.Days,
  15034. Diffgroup = x.Diffgroup,
  15035. Diid = x.Diid,
  15036. Traffic_First = x.Traffic_First,
  15037. Traffic_Second = x.Traffic_Second,
  15038. Trip = x.Trip,
  15039. WeekDay = x.WeekDay,
  15040. Id = x.Id
  15041. }).ToList();
  15042. jw.Data = new
  15043. {
  15044. groupList = groupList.Select(x => new
  15045. {
  15046. x.Id,
  15047. x.TeamName,
  15048. x.TourCode
  15049. }).ToList(),
  15050. groupInfo = new
  15051. {
  15052. group.VisitDays,
  15053. group.TourCode,
  15054. group.VisitPNumber,
  15055. group.TeamName,
  15056. city
  15057. },
  15058. OpTravelList
  15059. };
  15060. jw.Code = 200;
  15061. jw.Msg = "操作成功!";
  15062. return Ok(jw);
  15063. }
  15064. /// <summary>
  15065. /// 删除团组行程单
  15066. /// </summary>
  15067. /// <returns></returns>
  15068. [HttpPost]
  15069. public IActionResult DelTravel(DelOpTravelDto dto)
  15070. {
  15071. var jw = JsonView(false);
  15072. if (dto.UserId <= 0 || dto.Diid <= 0)
  15073. {
  15074. jw.Msg = "请输入正确的参数!";
  15075. return Ok(jw);
  15076. }
  15077. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  15078. .SetColumns(x => new Grp_TravelList
  15079. {
  15080. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  15081. DeleteUserId = dto.UserId,
  15082. IsDel = 1,
  15083. }).ExecuteCommand();
  15084. jw = JsonView(true);
  15085. return Ok(jw);
  15086. }
  15087. /// <summary>
  15088. /// 行程单保存
  15089. /// </summary>
  15090. /// <returns></returns>
  15091. [HttpPost]
  15092. public IActionResult TravelSave(TravelSaveDto dto)
  15093. {
  15094. var jw = JsonView(false);
  15095. if (dto.Arr.Count > 0)
  15096. {
  15097. try
  15098. {
  15099. var travelList_DB = _sqlSugar.Queryable<Grp_TravelList>()
  15100. .Where(x => dto.Arr.Select(x => x.Id).Contains(x.Id))
  15101. .ToList();
  15102. _sqlSugar.BeginTran();
  15103. foreach (var item in dto.Arr)
  15104. {
  15105. if (item.Id == 0)
  15106. {
  15107. throw new Exception("请传入正确的Id");
  15108. }
  15109. //比较上一次的差异
  15110. var findTravel = travelList_DB.Find(x => x.Id == item.Id);
  15111. if (findTravel != null)
  15112. {
  15113. item.Trip = item.Trip.Replace("[++]", string.Empty);
  15114. findTravel.Trip = findTravel.Trip.Replace("[++]", string.Empty);
  15115. item.Trip = CheckStr(findTravel.Trip, item.Trip);
  15116. }
  15117. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  15118. .SetColumns(x => new Grp_TravelList
  15119. {
  15120. Trip = item.Trip
  15121. }).ExecuteCommand();
  15122. }
  15123. _sqlSugar.CommitTran();
  15124. jw = JsonView(true);
  15125. }
  15126. catch (Exception ex)
  15127. {
  15128. _sqlSugar.RollbackTran();
  15129. jw.Msg = "程序异常!" + ex.Message;
  15130. }
  15131. }
  15132. else
  15133. {
  15134. jw.Msg = "请传入正确的参数!";
  15135. }
  15136. return Ok(jw);
  15137. }
  15138. private static string CheckStr(string original, string changed)
  15139. {
  15140. // 创建diff_match_patch对象
  15141. var dmp = new diff_match_patch();
  15142. // 计算差异
  15143. List<Diff> diffs = dmp.diff_main(original, changed);
  15144. // 清理和合并差异
  15145. dmp.diff_cleanupSemantic(diffs);
  15146. // 使用StringBuilder构建最终的字符串
  15147. var finalString = new StringBuilder();
  15148. // 输出差异结果,并构建变动后的字符串
  15149. foreach (Diff diff in diffs)
  15150. {
  15151. switch (diff.operation)
  15152. {
  15153. case Operation.EQUAL:
  15154. // 相等的部分,直接添加到最终字符串
  15155. finalString.Append(diff.text);
  15156. break;
  15157. case Operation.INSERT:
  15158. // 插入的部分,添加标记并添加到最终字符串
  15159. finalString.Append("[++]" + diff.text + "[++]");
  15160. break;
  15161. case Operation.DELETE:
  15162. // 删除的部分,不添加到最终字符串
  15163. //finalString.Append("[++]" + diff.text + "[++]");
  15164. break;
  15165. }
  15166. }
  15167. // 输出变动后的字符串
  15168. return finalString.ToString();
  15169. }
  15170. private class tagContent
  15171. {
  15172. public DateTime Date { get; set; }
  15173. public string StartTag { get; set; }
  15174. public string EndTag { get; set; }
  15175. public string Content { get; set; }
  15176. public static int tagLength { get { return 3; } }
  15177. public static Tuple<string, string> TagFormat { get { return new Tuple<string, string>("【#", "#】"); } }
  15178. public string QueryTag { get { return this.StartTag + this.EndTag; } }
  15179. public bool IsFinally { get; set; }
  15180. }
  15181. private static List<string> ExtractContentBetweenTags(string input, string tag)
  15182. {
  15183. var results = new List<string>();
  15184. // 构造正则表达式,匹配形如 [++]内容[++] 的部分
  15185. string pattern = $@"{Regex.Escape(tag)}(.*?){Regex.Escape(tag)}";
  15186. // 添加 RegexOptions.Singleline 选项使 . 匹配包括换行符在内的所有字符
  15187. MatchCollection matches = Regex.Matches(input, pattern, RegexOptions.Singleline);
  15188. string[] strValueArr = new string[1];
  15189. foreach (System.Text.RegularExpressions.Match match in matches)
  15190. {
  15191. var strValue = match.Groups[1].Value;
  15192. strValueArr = Regex.Split(strValue, @"\r\n|\n");
  15193. }
  15194. results.AddRange(strValueArr.Where(x => !string.IsNullOrWhiteSpace(x)));
  15195. return results;
  15196. }
  15197. /// <summary>
  15198. /// 导出行程单
  15199. /// </summary>
  15200. /// <param name="dto"></param>
  15201. /// <returns></returns>
  15202. [HttpPost]
  15203. public IActionResult ExportTravel(ExportTravelDto dto)
  15204. {
  15205. var jw = JsonView(false);
  15206. jw.Data = "";
  15207. int diid = 0;
  15208. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  15209. if (Find == null)
  15210. {
  15211. jw.Msg = "请选择正确的团组!";
  15212. return Ok(jw);
  15213. }
  15214. else
  15215. {
  15216. diid = Find.Id;
  15217. }
  15218. //数据源
  15219. var _travelList = new List<Grp_TravelList>();
  15220. DataTable dtBlack = null;
  15221. try
  15222. {
  15223. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  15224. }
  15225. catch (Exception)
  15226. {
  15227. jw.Msg = "机票黑屏代码有误!";
  15228. return Ok(jw);
  15229. }
  15230. string CityStr = string.Empty;
  15231. if (dtBlack.Rows.Count == 0)
  15232. {
  15233. jw.Msg = "机票黑屏代码有误!";
  15234. return Ok(jw);
  15235. }
  15236. else
  15237. {
  15238. foreach (DataRow row in dtBlack.Rows)
  15239. {
  15240. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  15241. {
  15242. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  15243. return Ok(jw);
  15244. }
  15245. }
  15246. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  15247. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  15248. }
  15249. // 指定的文字
  15250. var targetTextDic = new Dictionary<string, List<string>>();
  15251. //创建数据源Table
  15252. var dtSource = new DataTable();
  15253. dtSource.Columns.Add("Days", typeof(string));
  15254. dtSource.Columns.Add("Date", typeof(string));
  15255. dtSource.Columns.Add("Week", typeof(string));
  15256. dtSource.Columns.Add("Traffic", typeof(string));
  15257. dtSource.Columns.Add("Trip", typeof(string));
  15258. //获取数据,放到datatable
  15259. foreach (var item in _travelList)
  15260. {
  15261. targetTextDic.Add(item.Date, ExtractContentBetweenTags(item.Trip, "[++]"));
  15262. item.Trip = item.Trip.Replace(tagContent.TagFormat.Item1, string.Empty)
  15263. .Replace(tagContent.TagFormat.Item2, string.Empty)
  15264. .Replace("[++]", string.Empty);
  15265. DataRow dr = dtSource.NewRow();
  15266. dr["Days"] = item.Days;
  15267. dr["Date"] = item.Date;
  15268. dr["Week"] = item.WeekDay;
  15269. dr["Traffic"] = item.Traffic_First
  15270. + "\r\n"
  15271. + item.Traffic_Second;
  15272. dr["Trip"] = item.Trip;
  15273. dtSource.Rows.Add(dr);
  15274. }
  15275. var dic = new Dictionary<string, string>
  15276. {
  15277. { "Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()) },
  15278. { "City", CityStr },
  15279. { "Days", Find.VisitDays.ToString() },
  15280. { "DeleCode", Find.TourCode },
  15281. { "Pnum", Find.VisitPNumber.ToString() }
  15282. };
  15283. //模板路径
  15284. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  15285. //载入模板
  15286. Document doc = null;
  15287. DocumentBuilder builder = null;
  15288. try
  15289. {
  15290. //载入模板
  15291. doc = new Document(tempPath);
  15292. builder = new DocumentBuilder(doc);
  15293. }
  15294. catch (Exception)
  15295. {
  15296. jw.Msg = "模板位置不存在!";
  15297. return Ok(jw);
  15298. }
  15299. foreach (var key in dic.Keys)
  15300. {
  15301. Bookmark bookmark = doc.Range.Bookmarks[key];
  15302. if (bookmark != null)
  15303. {
  15304. builder.MoveToBookmark(key);
  15305. builder.Write(dic[key]);
  15306. }
  15307. }
  15308. //获取word里所有表格
  15309. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  15310. //获取所填表格的序数
  15311. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  15312. try
  15313. {
  15314. //循环赋值
  15315. for (int i = 0; i < dtSource.Rows.Count; i++)
  15316. {
  15317. builder.MoveToCell(0, i + 1, 0, 0);
  15318. builder.Write(dtSource.Rows[i]["Days"].ToString());
  15319. builder.MoveToCell(0, i + 1, 1, 0);
  15320. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  15321. builder.MoveToCell(0, i + 1, 2, 0);
  15322. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  15323. var trip = dtSource.Rows[i]["Trip"].ToString();
  15324. builder.MoveToCell(0, i + 1, 3, 0);
  15325. builder.Write(trip);
  15326. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  15327. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  15328. // 获取特定索引的段落
  15329. Paragraph paragraph = (Paragraph)paragraphs[0];
  15330. Run run = paragraph.Runs[0];
  15331. Aspose.Words.Font font = run.Font;
  15332. font.Name = "黑体";
  15333. //设置双休红色
  15334. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  15335. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  15336. paragraph = (Paragraph)paragraphs[1];
  15337. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  15338. {
  15339. run = paragraph.Runs[0];
  15340. font = run.Font;
  15341. font.Color = Color.Red;
  15342. }
  15343. }
  15344. }
  15345. catch (Exception ex)
  15346. {
  15347. }
  15348. //删除多余行
  15349. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  15350. {
  15351. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  15352. }
  15353. var targetTextList = new List<string>();
  15354. // 遍历文档中的表格
  15355. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  15356. {
  15357. foreach (Aspose.Words.Tables.Row row in table.Rows)
  15358. {
  15359. var cellIndex = 0;
  15360. foreach (Cell cell in row.Cells)
  15361. {
  15362. if (cellIndex == 1 && row.Cells.Count == 4)
  15363. {
  15364. foreach (var target in targetTextDic.Keys)
  15365. {
  15366. if (cell.GetText().Contains(target))
  15367. {
  15368. targetTextList = targetTextDic[target];
  15369. break;
  15370. }
  15371. }
  15372. }
  15373. // 遍历单元格中的所有段落
  15374. foreach (Paragraph paragraph in cell.Paragraphs)
  15375. {
  15376. // 使用临时列表存储原始 Runs,避免修改时影响遍历
  15377. var runs = new List<Run>();
  15378. foreach (Run run in paragraph.Runs)
  15379. {
  15380. runs.Add(run);
  15381. }
  15382. foreach (Run run in runs)
  15383. {
  15384. foreach (var targetText in targetTextList)
  15385. {
  15386. // 检查文字是否包含指定文字
  15387. if (run.Text.Contains(targetText))
  15388. {
  15389. // 将包含的部分设置为红色
  15390. HighlightText(run, targetText, Color.Red);
  15391. }
  15392. }
  15393. }
  15394. }
  15395. cellIndex++;
  15396. }
  15397. }
  15398. }
  15399. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  15400. if (!Directory.Exists(savePath))
  15401. {
  15402. try
  15403. {
  15404. Directory.CreateDirectory(savePath);
  15405. }
  15406. catch
  15407. {
  15408. }
  15409. }
  15410. string path = savePath + Find.TeamName + "出访日程";
  15411. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  15412. try
  15413. {
  15414. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  15415. string postfix = ".docx";
  15416. if (dto.IsPDF == 1)
  15417. {
  15418. saveFormat = Aspose.Words.SaveFormat.Pdf;
  15419. postfix = ".pdf";
  15420. }
  15421. doc.Save(path + postfix, saveFormat);
  15422. jw = JsonView(true, "导出成功", ftpPath + postfix);
  15423. }
  15424. catch (Exception)
  15425. {
  15426. jw = JsonView(false);
  15427. }
  15428. return Ok(jw);
  15429. }
  15430. /// <summary>
  15431. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  15432. /// </summary>
  15433. /// <param name="num"></param>
  15434. /// <returns></returns>
  15435. static string GetNum(string num)
  15436. {
  15437. string str = "";
  15438. switch (num)
  15439. {
  15440. case "1":
  15441. str = "一";
  15442. break;
  15443. case "2":
  15444. str = "二";
  15445. break;
  15446. case "3":
  15447. str = "三";
  15448. break;
  15449. case "4":
  15450. str = "四";
  15451. break;
  15452. case "5":
  15453. str = "五";
  15454. break;
  15455. case "6":
  15456. str = "六";
  15457. break;
  15458. case "7":
  15459. str = "七";
  15460. break;
  15461. case "8":
  15462. str = "八";
  15463. break;
  15464. case "9":
  15465. str = "九";
  15466. break;
  15467. case "10":
  15468. str = "十";
  15469. break;
  15470. case "11":
  15471. str = "十一";
  15472. break;
  15473. case "12":
  15474. str = "十二";
  15475. break;
  15476. case "一":
  15477. str = "1";
  15478. break;
  15479. case "二":
  15480. str = "2";
  15481. break;
  15482. case "三":
  15483. str = "3";
  15484. break;
  15485. case "四":
  15486. str = "4";
  15487. break;
  15488. case "五":
  15489. str = "5";
  15490. break;
  15491. case "六":
  15492. str = "6";
  15493. break;
  15494. case "七":
  15495. str = "7";
  15496. break;
  15497. case "八":
  15498. str = "8";
  15499. break;
  15500. case "九":
  15501. str = "9";
  15502. break;
  15503. case "十":
  15504. str = "10";
  15505. break;
  15506. case "十一":
  15507. str = "11";
  15508. break;
  15509. case "十二":
  15510. str = "12";
  15511. break;
  15512. }
  15513. return str;
  15514. }
  15515. /// <summary>
  15516. /// 高亮包含指定文字的部分
  15517. /// </summary>
  15518. /// <param name="run"></param>
  15519. /// <param name="targetText"></param>
  15520. /// <param name="color"></param>
  15521. static void HighlightText(Run run, string targetText, Color color)
  15522. {
  15523. string text = run.Text;
  15524. int startIndex = text.IndexOf(targetText, StringComparison.Ordinal);
  15525. if (startIndex >= 0)
  15526. {
  15527. Paragraph parentParagraph = (Paragraph)run.ParentNode;
  15528. // 前部分
  15529. if (startIndex > 0)
  15530. {
  15531. Run beforeRun = (Run)run.Clone(true);
  15532. beforeRun.Text = text.Substring(0, startIndex);
  15533. parentParagraph.InsertBefore(beforeRun, run);
  15534. }
  15535. // 匹配部分
  15536. Run matchRun = (Run)run.Clone(true);
  15537. matchRun.Text = text.Substring(startIndex, targetText.Length);
  15538. matchRun.Font.Color = color;
  15539. parentParagraph.InsertBefore(matchRun, run);
  15540. // 后部分
  15541. if (startIndex + targetText.Length < text.Length)
  15542. {
  15543. Run afterRun = (Run)run.Clone(true);
  15544. afterRun.Text = text.Substring(startIndex + targetText.Length);
  15545. parentParagraph.InsertBefore(afterRun, run);
  15546. }
  15547. // 删除原始Run
  15548. run.Remove();
  15549. }
  15550. }
  15551. #endregion
  15552. #endregion
  15553. #region 团组成本
  15554. /// <summary>
  15555. /// 团组成本数据初始化
  15556. /// </summary>
  15557. /// <param name="dto"></param>
  15558. /// <returns></returns>
  15559. [HttpPost]
  15560. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  15561. {
  15562. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  15563. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  15564. WHEN COUNT(*) >= 0 THEN 'True'
  15565. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  15566. Where TeamName != '' And IsDel = 0 Order By a.VisitStartDate Desc
  15567. ").ToList(); //团组列表
  15568. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  15569. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  15570. var visaCountryInfoArr = new ArrayList();
  15571. var groupinfoValue = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == diid && x.IsDel == 0);
  15572. if (groupinfoValue != null)
  15573. {
  15574. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  15575. var dicity = _sqlSugar.Queryable<Sys_Cities>().First(x => x.IsDel == 0 && x.Id == groupinfoValue.CityId);
  15576. dicity ??= new Sys_Cities()
  15577. {
  15578. ParentId = 122
  15579. };
  15580. var diparent = _sqlSugar.Queryable<Sys_Cities>().First(x => x.IsDel == 0 && x.Id == dicity.ParentId);
  15581. var spArr = new string[1] { countryArr };
  15582. if (countryArr.Contains("|"))
  15583. {
  15584. spArr = countryArr.Split("|");
  15585. }
  15586. else if (countryArr.Contains("、"))
  15587. {
  15588. spArr = countryArr.Split("、");
  15589. }
  15590. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  15591. {
  15592. try
  15593. {
  15594. var visa = _sqlSugar.Queryable<Res_VisaFeeStandard>()
  15595. .Where(x => x.IsDel == 0 && x.Country == item)
  15596. .ToList();
  15597. if (!visa.Any())
  15598. {
  15599. visa = _sqlSugar.Queryable<Res_VisaFeeStandard>()
  15600. .Where(x => x.IsDel == 0 && x.Country.Contains(item))
  15601. .ToList();
  15602. }
  15603. if (visa.Any())
  15604. {
  15605. var visainfo = _sqlSugar.Queryable<Res_VisaFeeStandardDetails>()
  15606. .Where(x => x.IsDel == 0 && visa.Select(x => x.Id).Contains(x.ParentId))
  15607. .ToList();
  15608. var visaMain = visainfo.FirstOrDefault(x => x.ProvinceId == diparent.Id);
  15609. var visayinsiValue = visainfo.FirstOrDefault(x => x.ParentId == visa.FirstOrDefault(x => x.FeeType == 1)?.Id);
  15610. visaCountryInfoArr.Add(new
  15611. {
  15612. country = item,
  15613. yinsi = new
  15614. {
  15615. Id = visayinsiValue.Id,
  15616. value = visayinsiValue.SmallVisaPrice
  15617. },
  15618. visaMain = new
  15619. {
  15620. Id = visaMain.Id,
  15621. IsVisaOnArrival = visaMain.IsVisaOnArrival ? "是" : "否",
  15622. IsElectronicSign = visaMain.IsElectronicSign ? "是" : "否",
  15623. VisaTime = visaMain.VisaTime,
  15624. IsVisaExemptionLarge = visaMain.IsVisaExemptionLarge ? "是" : "否",
  15625. LargeVisaPrice = visaMain.LargeVisaPrice,
  15626. LargeAgencyFee = visaMain.LargeAgencyFee,
  15627. IsVisaExemptionSmall = visaMain.IsVisaExemptionSmall ? "是" : "否",
  15628. SmallVisaPrice = visaMain.SmallVisaPrice,
  15629. SmallAgencyFee = visaMain.SmallAgencyFee,
  15630. NormExtFee = visaMain.NormExtFee,
  15631. UrgExtFee = visaMain.UrgExtFee,
  15632. IsUrgent = visaMain.IsUrgent ? "是" : "否",
  15633. UrgentTime = visaMain.UrgentTime,
  15634. UrgentPrice = visaMain.UrgentPrice,
  15635. UrgentPriceDesc = visaMain.UrgentPriceDesc,
  15636. Remark = visaMain.Remark,
  15637. }
  15638. });
  15639. }
  15640. }
  15641. catch (Exception ex)
  15642. {
  15643. //写入日志
  15644. _logger.LogError(ex, "团组成本解析签证异常!");
  15645. }
  15646. }
  15647. }
  15648. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  15649. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  15650. #region 屏蔽黑屏代码生成
  15651. //var create = _GroupCostRepository.
  15652. // CreateGroupCostByBlackCode(dto.Diid);
  15653. //if (groupCost.Count == 0 && create.Code == 0)
  15654. //{
  15655. // groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  15656. //}
  15657. #endregion
  15658. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  15659. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  15660. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  15661. groupCostMap = groupCostMap.Select(x =>
  15662. {
  15663. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  15664. {
  15665. x.Date = dataForamt.ToString("yyyy-MM-dd");
  15666. }
  15667. return x;
  15668. }).ToList();
  15669. //GroupCostParameter.Add(new
  15670. // Grp_GroupCostParameter());
  15671. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  15672. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == diid && x.IsDel == 0).Count() > 0;
  15673. var groupModuleOperators = GeneralMethod.GetGroupModuleOperators(diid);
  15674. return Ok(JsonView(new
  15675. {
  15676. groupList,
  15677. groupInfo,
  15678. groupChecks,
  15679. groupCost = groupCostMap,
  15680. hotelNumber,
  15681. GroupCostParameter = GroupCostParameterMap,
  15682. visaCountryInfoArr = visaCountryInfoArr,
  15683. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  15684. blackCodeIsTrue = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).Any(), //create.Code == 0 ? true : false,
  15685. hotelIsTrue,
  15686. groupModuleOperators
  15687. }));
  15688. }
  15689. /// <summary>
  15690. /// 团组成本信息保存
  15691. /// </summary>
  15692. /// <param name="dto"></param>
  15693. /// <returns></returns>
  15694. [HttpPost]
  15695. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  15696. {
  15697. if (dto.Diid <= 0 || dto.Userid <= 0)
  15698. {
  15699. return Ok(JsonView(false));
  15700. }
  15701. JsonView jw = null;
  15702. bool isTrue = false;
  15703. #region 复制团组成本
  15704. //if (dto.Diid == 2581)
  15705. //{
  15706. // dto.Diid = 2599;
  15707. // dto.CheckBoxs.ForEach(x =>
  15708. // {
  15709. // x.Diid = 2599;
  15710. // });
  15711. // dto.GroupCosts.ForEach(x =>
  15712. // {
  15713. // x.Diid = 2599;
  15714. // });
  15715. // dto.CostTypeHotelNumbers.ForEach(x =>
  15716. // {
  15717. // x.Diid = 2599;
  15718. // });
  15719. // dto.GroupCostParameters.ForEach(x =>
  15720. // {
  15721. // x.DiId = 2599;
  15722. // });
  15723. //}
  15724. #endregion
  15725. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  15726. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  15727. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  15728. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  15729. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  15730. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  15731. try
  15732. {
  15733. _sqlSugar.BeginTran();
  15734. isTrue = await _GroupCostRepository.
  15735. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  15736. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  15737. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  15738. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  15739. _sqlSugar.CommitTran();
  15740. jw = JsonView(true, "保存成功!", isTrue);
  15741. }
  15742. catch (Exception)
  15743. {
  15744. _sqlSugar.RollbackTran();
  15745. jw = JsonView(false);
  15746. }
  15747. return Ok(jw);
  15748. }
  15749. /// <summary>
  15750. /// 复制团组成本信息
  15751. /// </summary>
  15752. /// <param name="dto"></param>
  15753. /// <returns></returns>
  15754. [HttpPost]
  15755. public async Task<IActionResult> CopyGroupCost(CopyGroupCostDto dto)
  15756. {
  15757. if (dto.Diid <= 0 || dto.Userid <= 0 || dto.ToGroupId <= 0)
  15758. {
  15759. return Ok(JsonView(false, "参数有误!"));
  15760. }
  15761. #region 复制团组成本
  15762. dto.Diid = dto.ToGroupId;
  15763. dto.CheckBoxs.ForEach(x =>
  15764. {
  15765. x.Diid = dto.ToGroupId;
  15766. });
  15767. dto.GroupCosts.ForEach(x =>
  15768. {
  15769. x.Diid = dto.ToGroupId;
  15770. });
  15771. dto.CostTypeHotelNumbers.ForEach(x =>
  15772. {
  15773. x.Diid = dto.ToGroupId;
  15774. });
  15775. dto.GroupCostParameters.ForEach(x =>
  15776. {
  15777. x.DiId = dto.ToGroupId;
  15778. });
  15779. #endregion
  15780. JsonView jw = null;
  15781. bool isTrue = false;
  15782. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  15783. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  15784. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  15785. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  15786. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  15787. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  15788. try
  15789. {
  15790. _sqlSugar.BeginTran();
  15791. isTrue = await _GroupCostRepository.
  15792. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  15793. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  15794. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  15795. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  15796. _sqlSugar.CommitTran();
  15797. jw = JsonView(true, "保存成功!", isTrue);
  15798. }
  15799. catch (Exception)
  15800. {
  15801. _sqlSugar.RollbackTran();
  15802. jw = JsonView(false);
  15803. }
  15804. return Ok(jw);
  15805. }
  15806. /// <summary>
  15807. /// 司兼导数据
  15808. /// </summary>
  15809. /// <param name="dto"></param>
  15810. /// <returns></returns>
  15811. [HttpPost]
  15812. public IActionResult GetCarGuides(CarGuidesDto dto)
  15813. {
  15814. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  15815. return Ok(JsonView(true, "获取成功!", Data));
  15816. }
  15817. /// <summary>
  15818. /// 导游数据
  15819. /// </summary>
  15820. /// <param name="dto"></param>
  15821. /// <returns></returns>
  15822. [HttpPost]
  15823. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  15824. {
  15825. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  15826. // 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
  15827. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  15828. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  15829. return Ok(JsonView(true, "获取成功!", Data));
  15830. }
  15831. /// <summary>
  15832. /// 成本车数据
  15833. /// </summary>
  15834. /// <param name="dto"></param>
  15835. /// <returns></returns>
  15836. [HttpPost]
  15837. public IActionResult GetCarInfo(CarGuidesDto dto)
  15838. {
  15839. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  15840. return Ok(JsonView(true, "获取成功!", Data));
  15841. }
  15842. /// <summary>
  15843. /// 景点数据
  15844. /// </summary>
  15845. /// <param name="dto"></param>
  15846. /// <returns></returns>
  15847. [HttpPost]
  15848. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  15849. {
  15850. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  15851. return Ok(JsonView(true, "获取成功!", Data));
  15852. }
  15853. /// <summary>
  15854. /// 成本通知
  15855. /// </summary>
  15856. /// <param name="dto"></param>
  15857. /// <returns></returns>
  15858. [HttpPost]
  15859. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  15860. {
  15861. if (dto.Diid < 0)
  15862. {
  15863. return Ok(JsonView(false));
  15864. }
  15865. JsonView jw;
  15866. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  15867. if (GroupCostParameter != null)
  15868. {
  15869. int IsShare = 0;
  15870. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  15871. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  15872. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  15873. string msg = string.Empty;
  15874. if (isTrue)
  15875. {
  15876. if (IsShare == 0)
  15877. {
  15878. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  15879. }
  15880. else
  15881. {
  15882. #region 企微通知对应岗位用户
  15883. try
  15884. {
  15885. await AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  15886. //机票预算群通知
  15887. await AppNoticeLibrary.SendChatMsg_AirCostChat(dto.Diid, QiyeWeChatEnum.AirCostChat01);
  15888. }
  15889. catch (Exception)
  15890. {
  15891. }
  15892. #endregion
  15893. msg = "通知成功,其他模块操作人员可见此成本信息!";
  15894. }
  15895. jw = JsonView(isTrue, msg, new { IsShare });
  15896. }
  15897. else
  15898. {
  15899. msg = "修改失败!";
  15900. jw = JsonView(isTrue, msg);
  15901. }
  15902. }
  15903. else
  15904. {
  15905. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  15906. }
  15907. return Ok(jw);
  15908. }
  15909. /// <summary>
  15910. /// 导出报价单
  15911. /// </summary>
  15912. /// <param name="dto"></param>
  15913. /// <returns></returns>
  15914. [HttpPost]
  15915. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  15916. {
  15917. if (dto.Diid == 0)
  15918. {
  15919. return Ok(JsonView(false, "请传递团组id"));
  15920. }
  15921. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  15922. if (deleInfo.Code != 0)
  15923. {
  15924. return Ok(JsonView(false, "团组信息查询失败!"));
  15925. }
  15926. var di = deleInfo.Data as DelegationInfoWebView;
  15927. if (di != null)
  15928. {
  15929. di.TeamName = di.TeamName.Replace("|", "、");
  15930. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  15931. //文件名
  15932. string strFileName = di.TeamName + "-收款账单.doc";
  15933. //获取模板
  15934. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  15935. //载入模板
  15936. Document doc = new Document(tmppath);
  15937. decimal TotalPrice = 0.00M;
  15938. string itemStr = string.Empty;
  15939. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  15940. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  15941. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  15942. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  15943. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  15944. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  15945. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  15946. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  15947. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  15948. foreach (var cost in groupCostType)
  15949. {
  15950. var List = cost.ToList();
  15951. if (cost.Key == "A")
  15952. {
  15953. foreach (var ListItem in List)
  15954. {
  15955. if (ListItem.number > 0)
  15956. {
  15957. if (ListItem.code.Contains("TBR"))
  15958. {
  15959. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  15960. }
  15961. else
  15962. {
  15963. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  15964. }
  15965. TotalPrice += (ListItem.number * ListItem.price);
  15966. }
  15967. }
  15968. }
  15969. else
  15970. {
  15971. itemStr = itemStr.Insert(0, "A段\r\n");
  15972. itemStr += "B段\r\n";
  15973. foreach (var ListItem in List)
  15974. {
  15975. if (ListItem.number > 0)
  15976. {
  15977. if (ListItem.code.Contains("TBR"))
  15978. {
  15979. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  15980. }
  15981. else
  15982. {
  15983. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  15984. }
  15985. TotalPrice += (ListItem.number * ListItem.price);
  15986. }
  15987. }
  15988. }
  15989. }
  15990. #region 替换Word模板书签内容
  15991. Dictionary<string, string> marks = new Dictionary<string, string>();
  15992. marks.Add("To", di.ClientUnit);//付款方
  15993. marks.Add("ToTel", di.TellPhone);//付款方电话
  15994. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  15995. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  15996. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  15997. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  15998. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  15999. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  16000. marks.Add("PayItemContent", itemStr);//详细信息
  16001. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  16002. #endregion
  16003. ////注
  16004. //if (doc.Range.Bookmarks["Attention"] != null)
  16005. //{
  16006. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  16007. // mark.Text = frList[0].Attention;
  16008. //}
  16009. foreach (var item in marks.Keys)
  16010. {
  16011. if (doc.Range.Bookmarks[item] != null)
  16012. {
  16013. Bookmark mark = doc.Range.Bookmarks[item];
  16014. mark.Text = marks[item];
  16015. }
  16016. }
  16017. byte[] bytes = null;
  16018. using (MemoryStream stream = new MemoryStream())
  16019. {
  16020. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  16021. bytes = stream.ToArray();
  16022. }
  16023. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  16024. return Ok(JsonView(true, "", new
  16025. {
  16026. Data = bytes,
  16027. strFileName,
  16028. }));
  16029. }
  16030. else
  16031. {
  16032. return Ok(JsonView(false, "团组信息不存在!"));
  16033. }
  16034. }
  16035. /// <summary>
  16036. /// 导出团组成本
  16037. /// </summary>
  16038. /// <param name="dto"></param>
  16039. /// <returns></returns>
  16040. [HttpPost]
  16041. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  16042. {
  16043. var jw = JsonView(false);
  16044. if (dto.Diid == 0)
  16045. {
  16046. return Ok(JsonView(false, "请传递团组id"));
  16047. }
  16048. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  16049. if (deleInfo.Code != 0)
  16050. {
  16051. return Ok(JsonView(false, "团组信息查询失败!"));
  16052. }
  16053. var di = deleInfo.Data as DelegationInfoWebView;
  16054. if (di == null)
  16055. {
  16056. return Ok(JsonView(false, "团组信息查询失败!"));
  16057. }
  16058. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  16059. WorkbookDesigner designer = new WorkbookDesigner();
  16060. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  16061. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  16062. List<int> hideColumnList = new List<int>();
  16063. var ColumnSetting = new[]
  16064. {
  16065. new { tag = "VF", Index = 4, P = "CarCost" },
  16066. new { tag = "VN", Index = 5, P = "CarNumber" },
  16067. new { tag = "VRD", Index = 6, P = "CarTiming" },
  16068. new { tag = "T/G S", Index = 7, P = "TGS" },
  16069. new { tag = "TGWH", Index = 8, P = "TGWH" },
  16070. new { tag = "T/G OF", Index = 9, P = "TGOF" },
  16071. new { tag = "T/G M", Index = 10, P = "TGM" },
  16072. new { tag = "T/G A", Index = 11, P = "TGA" },
  16073. new { tag = "T/G TF", Index = 12, P = "TGTF" },
  16074. new { tag = "T/G EF", Index = 13, P = "TGEF" },
  16075. new { tag = "C/F S", Index = 14, P = "CFS" },
  16076. new { tag = "C/F M", Index = 15, P = "CFM" },
  16077. new { tag = "C/F OF", Index = 16, P = "CFOF" },
  16078. new { tag = "B", Index = 17, P = "B" },
  16079. new { tag = "L", Index = 18, P = "L" },
  16080. new { tag = "D", Index = 19, P = "D" },
  16081. new { tag = "TBR", Index = 20, P = "TBR" },
  16082. new { tag = "SGR", Index = 21, P = "SGR" },
  16083. new { tag = "JS/ES", Index = 22, P = "JS_ES" },
  16084. new { tag = "Suite", Index = 23, P = "Suite" },
  16085. new { tag = "ACCO N", Index = 24, P = "ACCON" },
  16086. new { tag = "T/V", Index = 25, P = "TV" },
  16087. new { tag = "1/L", Index = 26, P = "iL" },
  16088. new { tag = "I/F", Index = 27, P = "IF" },
  16089. new { tag = "EF", Index = 28, P = "EF" },
  16090. new { tag = "B/R/F", Index = 29, P = "B_R_F" },
  16091. new { tag = "TE", Index = 30, P = "TE" },
  16092. new { tag = "T/G T", Index = 31, P = "TGTips" },
  16093. new { tag = "DRV T", Index = 32, P = "DRVTips" },
  16094. new { tag = "P/C", Index = 33, P = "PC" },
  16095. new { tag = "T/L F", Index = 34, P = "TLF" },
  16096. new { tag = "E/C T", Index = 35, P = "ECT" }
  16097. };
  16098. Func<string, bool> isEmpty = (str) =>
  16099. {
  16100. if (decimal.TryParse(str, out decimal str_De) && str_De == 0)
  16101. {
  16102. return true;
  16103. }
  16104. if (string.IsNullOrWhiteSpace(str))
  16105. {
  16106. return true;
  16107. }
  16108. return false;
  16109. };
  16110. for (int i = 0; i < List_GC.Count; i++)
  16111. {
  16112. GroupCost_Excel gc = new GroupCost_Excel();
  16113. gc.Id = List_GC[i].Id;
  16114. gc.Diid = List_GC[i].Diid.ToString();
  16115. gc.DAY = List_GC[i].DAY;
  16116. string week = "";
  16117. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  16118. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  16119. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  16120. gc.ITIN = List_GC[i].ITIN;
  16121. gc.CarType = List_GC[i].CarType;
  16122. gc.CarTiming = isEmpty(List_GC[i].CarTiming.ToString()) ? "" : List_GC[i].CarTiming.ToString();
  16123. gc.CarCost = isEmpty(List_GC[i].CarCost.ToString()) ? "" : List_GC[i].CarCost.ToString();
  16124. gc.CarNumber = isEmpty(List_GC[i].CarNumber.ToString()) ? "" : List_GC[i].CarNumber.ToString();
  16125. gc.TGS = isEmpty(List_GC[i].TGS.ToString()) ? "" : List_GC[i].TGS.ToString();
  16126. gc.TGWH = isEmpty(List_GC[i].TGWH.ToString()) ? "" : List_GC[i].TGWH.ToString();
  16127. gc.TGN = isEmpty(List_GC[i].TGN.ToString()) ? "" : List_GC[i].TGN.ToString();
  16128. gc.TGOF = isEmpty(List_GC[i].TGOF.ToString()) ? "" : List_GC[i].TGOF.ToString();
  16129. gc.TGM = isEmpty(List_GC[i].TGM.ToString()) ? "" : List_GC[i].TGM.ToString();
  16130. gc.TGA = isEmpty(List_GC[i].TGA.ToString()) ? "" : List_GC[i].TGA.ToString();
  16131. gc.TGTF = isEmpty(List_GC[i].TGTF.ToString()) ? "" : List_GC[i].TGTF.ToString();
  16132. gc.TGEF = isEmpty(List_GC[i].TGEF.ToString()) ? "" : List_GC[i].TGEF.ToString();
  16133. gc.CFS = isEmpty(List_GC[i].CFS.ToString()) ? "" : List_GC[i].CFS.ToString();
  16134. gc.CFM = isEmpty(List_GC[i].CFM.ToString()) ? "" : List_GC[i].CFM.ToString();
  16135. gc.CFOF = isEmpty(List_GC[i].CFOF.ToString()) ? "" : List_GC[i].CFOF.ToString();
  16136. gc.B = isEmpty(List_GC[i].B.ToString()) ? "" : List_GC[i].B.ToString();
  16137. gc.L = isEmpty(List_GC[i].L.ToString()) ? "" : List_GC[i].L.ToString();
  16138. gc.D = isEmpty(List_GC[i].D.ToString()) ? "" : List_GC[i].D.ToString();
  16139. gc.TBR = isEmpty(List_GC[i].TBR.ToString()) ? "" : List_GC[i].TBR.ToString();
  16140. gc.SGR = isEmpty(List_GC[i].SGR.ToString()) ? "" : List_GC[i].SGR.ToString();
  16141. gc.JS_ES = isEmpty(List_GC[i].JS_ES.ToString()) ? "" : List_GC[i].JS_ES.ToString();
  16142. gc.Suite = isEmpty(List_GC[i].Suite.ToString()) ? "" : List_GC[i].Suite.ToString();
  16143. gc.ACCON = isEmpty(List_GC[i].ACCON.ToString()) ? "" : List_GC[i].ACCON.ToString();
  16144. gc.TV = isEmpty(List_GC[i].TV.ToString()) ? "" : List_GC[i].TV.ToString();
  16145. gc.iL = isEmpty(List_GC[i].iL.ToString()) ? "" : List_GC[i].iL.ToString();
  16146. gc.IF = isEmpty(List_GC[i].IF.ToString()) ? "" : List_GC[i].IF.ToString();
  16147. gc.EF = isEmpty(List_GC[i].EF.ToString()) ? "" : List_GC[i].EF.ToString();
  16148. gc.B_R_F = isEmpty(List_GC[i].B_R_F.ToString()) ? "" : List_GC[i].B_R_F.ToString();
  16149. gc.TE = isEmpty(List_GC[i].TE.ToString()) ? "" : List_GC[i].TE.ToString();
  16150. gc.TGTips = isEmpty(List_GC[i].TGTips.ToString()) ? "" : List_GC[i].TGTips.ToString();
  16151. gc.DRVTips = isEmpty(List_GC[i].DRVTips.ToString()) ? "" : List_GC[i].DRVTips.ToString();
  16152. gc.PC = isEmpty(List_GC[i].PC.ToString()) ? "" : List_GC[i].PC.ToString();
  16153. gc.TLF = isEmpty(List_GC[i].TLF.ToString()) ? "" : List_GC[i].TLF.ToString();
  16154. gc.ECT = isEmpty(List_GC[i].ECT.ToString()) ? "" : List_GC[i].ECT.ToString();
  16155. gc.EFR = List_GC[i].EFR;
  16156. List_GC1.Add(gc);
  16157. }
  16158. if (List_GC1.Count > 0)
  16159. {
  16160. var p = List_GC1[0];
  16161. var prs = p.GetType().GetProperties();
  16162. foreach (var item in prs)
  16163. {
  16164. var tp = item.PropertyType;
  16165. if (tp == typeof(int))
  16166. {
  16167. var val = List_GC1.Sum(x => (int)x.GetType().GetProperty(item.Name).GetValue(x));
  16168. if (val == 0)
  16169. {
  16170. var columnSetting = ColumnSetting.FirstOrDefault(x => x.P == item.Name);
  16171. if (columnSetting != null)
  16172. {
  16173. hideColumnList.Add(columnSetting.Index);
  16174. }
  16175. }
  16176. }
  16177. if (tp == typeof(decimal))
  16178. {
  16179. var val = List_GC1.Sum(x => (decimal)x.GetType().GetProperty(item.Name).GetValue(x));
  16180. if (val == 0)
  16181. {
  16182. var columnSetting = ColumnSetting.FirstOrDefault(x => x.P == item.Name);
  16183. if (columnSetting != null)
  16184. {
  16185. hideColumnList.Add(columnSetting.Index);
  16186. }
  16187. }
  16188. }
  16189. if (tp == typeof(string))
  16190. {
  16191. var val = List_GC1.Sum(x =>
  16192. {
  16193. var str = (string)x.GetType().GetProperty(item.Name).GetValue(x);
  16194. if (decimal.TryParse(str, out decimal str_De))
  16195. {
  16196. return str_De;
  16197. }
  16198. else
  16199. {
  16200. return string.IsNullOrEmpty((string)x.GetType().GetProperty(item.Name).GetValue(x)) ? 0 : 1;
  16201. }
  16202. });
  16203. if (val == 0)
  16204. {
  16205. var columnSetting = ColumnSetting.FirstOrDefault(x => x.P == item.Name);
  16206. if (columnSetting != null)
  16207. {
  16208. hideColumnList.Add(columnSetting.Index);
  16209. }
  16210. }
  16211. }
  16212. }
  16213. }
  16214. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  16215. dt.TableName = "TB";
  16216. //报表标题等不用dt的值
  16217. designer.SetDataSource("TeamName", dto.title.TeamName);
  16218. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  16219. designer.SetDataSource("Tax", dto.title.Tax);
  16220. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  16221. designer.SetDataSource("Currency", dto.title.Currency);
  16222. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  16223. designer.SetDataSource("Rate", dto.title.Rate);
  16224. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  16225. var Aparams = hotels.Find(x => x.Type == "Default");
  16226. if (Aparams == null)
  16227. {
  16228. return Ok(jw);
  16229. }
  16230. //酒店数量
  16231. var txtSGRNumber = Aparams.SGR.ToString();
  16232. var txtTBRNumber = Aparams.TBR.ToString();
  16233. var txtJSESNumber = Aparams.JSES.ToString();
  16234. var txtSUITENumbe = Aparams.SUITE.ToString();
  16235. if (dto.costType == "B")
  16236. {
  16237. Aparams = hotels.Find(x => x.Type == "A");
  16238. var Bparams = hotels.Find(x => x.Type == "B");
  16239. if (Aparams == null || Bparams == null)
  16240. {
  16241. return Ok(jw);
  16242. }
  16243. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  16244. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  16245. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  16246. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  16247. }
  16248. designer.SetDataSource("SGRNumber", txtSGRNumber);
  16249. designer.SetDataSource("TBRNumber", txtTBRNumber);
  16250. designer.SetDataSource("JSESNumber", txtJSESNumber);
  16251. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  16252. var ws = designer.Workbook.Worksheets[1];
  16253. int Row = List_GC.Count;
  16254. int startIndex = 0;
  16255. int HideRows = 0;
  16256. Row = 0;
  16257. List<int> hideRowsList = new List<int>();
  16258. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  16259. #region A段left数据
  16260. var left = dto.leftInfo.Find(x => x.Type == "A");
  16261. if (left == null)
  16262. {
  16263. return Ok(jw);
  16264. }
  16265. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  16266. if (leftBindData != null)
  16267. {
  16268. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  16269. designer.SetDataSource("VisaRS", leftBindData.rs);
  16270. designer.SetDataSource("VisaXS", leftBindData.xs);
  16271. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16272. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16273. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16274. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16275. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16276. }
  16277. else
  16278. {
  16279. hideRowsList.Add(Row + startIndex + HideRows);
  16280. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  16281. }
  16282. HideRows += 2;
  16283. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  16284. if (leftBindData != null)
  16285. {
  16286. designer.SetDataSource("BXDRCB", leftBindData.cb);
  16287. designer.SetDataSource("BXRS", leftBindData.rs);
  16288. designer.SetDataSource("BXXS", leftBindData.xs);
  16289. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16290. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16291. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16292. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16293. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16294. }
  16295. else
  16296. {
  16297. hideRowsList.Add(Row + startIndex + HideRows);
  16298. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  16299. }
  16300. HideRows += 2;
  16301. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  16302. if (leftBindData != null)
  16303. {
  16304. designer.SetDataSource("HSDRCB", leftBindData.cb);
  16305. designer.SetDataSource("HSRS", leftBindData.rs);
  16306. designer.SetDataSource("HSXS", leftBindData.xs);
  16307. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16308. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16309. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16310. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16311. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16312. }
  16313. else
  16314. {
  16315. hideRowsList.Add(Row + startIndex + HideRows);
  16316. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  16317. }
  16318. HideRows += 2;
  16319. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  16320. if (leftBindData != null)
  16321. {
  16322. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  16323. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  16324. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  16325. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16326. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16327. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16328. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16329. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16330. }
  16331. else
  16332. {
  16333. hideRowsList.Add(Row + startIndex + HideRows);
  16334. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  16335. }
  16336. HideRows += 2;
  16337. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  16338. if (leftBindData != null)
  16339. {
  16340. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  16341. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  16342. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  16343. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16344. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16345. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16346. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16347. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16348. }
  16349. else
  16350. {
  16351. hideRowsList.Add(Row + startIndex + HideRows);
  16352. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  16353. }
  16354. HideRows += 2;
  16355. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  16356. if (leftBindData != null)
  16357. {
  16358. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  16359. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  16360. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  16361. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16362. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16363. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16364. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16365. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16366. }
  16367. else
  16368. {
  16369. hideRowsList.Add(Row + startIndex + HideRows);
  16370. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  16371. }
  16372. HideRows += 2;
  16373. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  16374. if (leftBindData != null)
  16375. {
  16376. ////TBR
  16377. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  16378. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  16379. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  16380. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16381. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16382. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16383. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16384. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16385. }
  16386. else
  16387. {
  16388. hideRowsList.Add(Row + startIndex + HideRows);
  16389. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  16390. }
  16391. HideRows += 2;
  16392. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  16393. if (leftBindData != null)
  16394. {
  16395. ////SGR
  16396. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  16397. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  16398. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  16399. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16400. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16401. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16402. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16403. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16404. }
  16405. else
  16406. {
  16407. hideRowsList.Add(Row + startIndex + HideRows);
  16408. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  16409. }
  16410. HideRows += 2;
  16411. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  16412. if (leftBindData != null)
  16413. {
  16414. ////JS/ES
  16415. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  16416. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  16417. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  16418. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16419. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16420. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16421. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16422. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16423. }
  16424. else
  16425. {
  16426. hideRowsList.Add(Row + startIndex + HideRows);
  16427. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  16428. }
  16429. HideRows += 2;
  16430. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  16431. if (leftBindData != null)
  16432. {
  16433. ////SUITE
  16434. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  16435. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  16436. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  16437. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16438. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16439. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16440. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16441. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16442. }
  16443. else
  16444. {
  16445. hideRowsList.Add(Row + startIndex + HideRows);
  16446. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  16447. }
  16448. HideRows += 2;
  16449. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  16450. if (leftBindData != null)
  16451. {
  16452. designer.SetDataSource("DJDRCB", leftBindData.cb);
  16453. designer.SetDataSource("DJRS", leftBindData.rs);
  16454. designer.SetDataSource("DJXS", leftBindData.xs);
  16455. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16456. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16457. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16458. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16459. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16460. }
  16461. else
  16462. {
  16463. hideRowsList.Add(Row + startIndex + HideRows);
  16464. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  16465. }
  16466. HideRows += 2;
  16467. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  16468. if (leftBindData != null)
  16469. {
  16470. designer.SetDataSource("HCPCB", leftBindData.cb);
  16471. designer.SetDataSource("HCPRS", leftBindData.rs);
  16472. designer.SetDataSource("HCPXS", leftBindData.xs);
  16473. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16474. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16475. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16476. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16477. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16478. }
  16479. else
  16480. {
  16481. hideRowsList.Add(Row + startIndex + HideRows);
  16482. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  16483. }
  16484. HideRows += 2;
  16485. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  16486. if (leftBindData != null)
  16487. {
  16488. designer.SetDataSource("CPCB", leftBindData.cb);
  16489. designer.SetDataSource("CPRS", leftBindData.rs);
  16490. designer.SetDataSource("CPXS", leftBindData.xs);
  16491. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16492. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16493. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16494. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16495. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16496. }
  16497. else
  16498. {
  16499. hideRowsList.Add(Row + startIndex + HideRows);
  16500. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  16501. }
  16502. HideRows += 2;
  16503. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  16504. if (leftBindData != null)
  16505. {
  16506. designer.SetDataSource("GWDRCD", leftBindData.cb);
  16507. designer.SetDataSource("GWRS", leftBindData.rs);
  16508. designer.SetDataSource("GWXS", leftBindData.xs);
  16509. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16510. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16511. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16512. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16513. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16514. }
  16515. else
  16516. {
  16517. hideRowsList.Add(Row + startIndex + HideRows);
  16518. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  16519. }
  16520. HideRows += 2;
  16521. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  16522. if (leftBindData != null)
  16523. {
  16524. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  16525. designer.SetDataSource("LYJRS", leftBindData.rs);
  16526. designer.SetDataSource("LYJXS", leftBindData.xs);
  16527. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16528. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16529. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16530. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16531. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16532. }
  16533. else
  16534. {
  16535. hideRowsList.Add(Row + startIndex + HideRows);
  16536. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  16537. }
  16538. #endregion
  16539. #region A段Right信息
  16540. var right = dto.rightInfo.Find(x => x.Type == "A");
  16541. if (right == null)
  16542. {
  16543. return Ok(jw);
  16544. }
  16545. HideRows += 4;
  16546. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  16547. if (rightBindData != null)
  16548. {
  16549. //经济舱 + 双人间 TBR
  16550. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  16551. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  16552. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16553. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  16554. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16555. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16556. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16557. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16558. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16559. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16560. }
  16561. else
  16562. {
  16563. hideRowsList.Add(Row + startIndex + HideRows);
  16564. }
  16565. HideRows += 2;
  16566. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  16567. if (rightBindData != null)
  16568. {
  16569. //经济舱 + 单人间 SGR
  16570. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  16571. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  16572. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16573. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  16574. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16575. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16576. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16577. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16578. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16579. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16580. }
  16581. else
  16582. {
  16583. hideRowsList.Add(Row + startIndex + HideRows);
  16584. }
  16585. HideRows += 2;
  16586. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  16587. if (rightBindData != null)
  16588. {
  16589. //公务舱 + 单人间 SGR
  16590. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  16591. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  16592. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16593. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  16594. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16595. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16596. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16597. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16598. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16599. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16600. }
  16601. else
  16602. {
  16603. hideRowsList.Add(Row + startIndex + HideRows);
  16604. }
  16605. HideRows += 2;
  16606. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  16607. if (rightBindData != null)
  16608. {
  16609. //公务舱 + 小套房 JSES
  16610. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  16611. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  16612. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16613. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  16614. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16615. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16616. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16617. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16618. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16619. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16620. }
  16621. else
  16622. {
  16623. hideRowsList.Add(Row + startIndex + HideRows);
  16624. }
  16625. HideRows += 2;
  16626. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  16627. if (rightBindData != null)
  16628. {
  16629. //公务舱 + 小套房 JSES
  16630. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  16631. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  16632. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16633. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  16634. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16635. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16636. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16637. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16638. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16639. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16640. }
  16641. else
  16642. {
  16643. hideRowsList.Add(Row + startIndex + HideRows);
  16644. }
  16645. HideRows += 2;
  16646. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  16647. if (rightBindData != null)
  16648. {
  16649. //经济舱 + 大套房
  16650. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  16651. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  16652. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16653. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  16654. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16655. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16656. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16657. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16658. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16659. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16660. }
  16661. else
  16662. {
  16663. hideRowsList.Add(Row + startIndex + HideRows);
  16664. }
  16665. HideRows += 2;
  16666. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  16667. if (rightBindData != null)
  16668. {
  16669. //头等舱 + 小套房 JSES
  16670. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  16671. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  16672. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16673. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  16674. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16675. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16676. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16677. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16678. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16679. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16680. }
  16681. else
  16682. {
  16683. hideRowsList.Add(Row + startIndex + HideRows);
  16684. }
  16685. HideRows += 2;
  16686. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  16687. if (rightBindData != null)
  16688. {
  16689. //头等舱 + 大套房
  16690. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  16691. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  16692. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16693. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  16694. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16695. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16696. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16697. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16698. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16699. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16700. }
  16701. else
  16702. {
  16703. hideRowsList.Add(Row + startIndex + HideRows);
  16704. }
  16705. #endregion
  16706. #region B段标题清空
  16707. designer.SetDataSource("CostBDRCB", "");
  16708. designer.SetDataSource("CostBRS", "");
  16709. designer.SetDataSource("CostBXS", "");
  16710. designer.SetDataSource("CostBZCB", "");
  16711. designer.SetDataSource("CostBDRBJ", "");
  16712. designer.SetDataSource("CostBZBJ", "");
  16713. designer.SetDataSource("CostBDRLR", "");
  16714. designer.SetDataSource("CostBZLR", "");
  16715. designer.SetDataSource("CostBDRCBOM", "");
  16716. designer.SetDataSource("CostBRSOM", "");
  16717. designer.SetDataSource("CostBZCBOM", "");
  16718. designer.SetDataSource("CostBDRBJOM", "");
  16719. designer.SetDataSource("CostBZBJOM", "");
  16720. designer.SetDataSource("CostBDRLROM", "");
  16721. designer.SetDataSource("CostBZLROM", "");
  16722. #endregion
  16723. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  16724. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  16725. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  16726. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  16727. designer.SetDataSource("DJName", "地接(CNY)");
  16728. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  16729. designer.SetDataSource("CPName", "地接-船票(CNY)");
  16730. designer.SetDataSource("GWName", "公务(CNY)");
  16731. designer.SetDataSource("YQHName", "邀请函(CNY)");
  16732. designer.SetDataSource("LYJName", "零用金(CNY)");
  16733. designer.SetDataSource("HSName", "核酸检测(CNY)");
  16734. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  16735. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  16736. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  16737. designer.SetDataSource("BXName", "保险(CNY)");
  16738. designer.SetDataSource("VisaName", "签证(CNY)");
  16739. #region B段基本数据
  16740. if (dto.costType == "B")
  16741. {
  16742. left = dto.leftInfo.Find(x => x.Type == "B");
  16743. if (left == null)
  16744. {
  16745. return Ok(jw);
  16746. }
  16747. #region B段left数据
  16748. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  16749. if (leftBindData != null)
  16750. {
  16751. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  16752. designer.SetDataSource("BHSRS", leftBindData.rs);
  16753. designer.SetDataSource("BHSXS", leftBindData.xs);
  16754. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16755. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16756. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16757. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16758. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16759. }
  16760. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  16761. if (leftBindData != null)
  16762. {
  16763. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  16764. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  16765. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  16766. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16767. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16768. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16769. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16770. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16771. }
  16772. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  16773. if (leftBindData != null)
  16774. {
  16775. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  16776. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  16777. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  16778. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16779. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16780. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16781. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16782. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16783. }
  16784. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  16785. if (leftBindData != null)
  16786. {
  16787. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  16788. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  16789. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  16790. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16791. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16792. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16793. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16794. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16795. }
  16796. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  16797. if (leftBindData != null)
  16798. {
  16799. designer.SetDataSource("BHCPCB", leftBindData.cb);
  16800. designer.SetDataSource("BHCPRS", leftBindData.rs);
  16801. designer.SetDataSource("BHCPXS", leftBindData.xs);
  16802. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16803. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16804. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16805. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16806. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16807. }
  16808. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  16809. if (leftBindData != null)
  16810. {
  16811. designer.SetDataSource("BCPCB", leftBindData.cb);
  16812. designer.SetDataSource("BCPRS", leftBindData.rs);
  16813. designer.SetDataSource("BCPXS", leftBindData.xs);
  16814. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16815. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16816. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16817. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16818. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16819. }
  16820. //TBR
  16821. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  16822. if (leftBindData != null)
  16823. {
  16824. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  16825. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  16826. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  16827. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16828. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16829. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16830. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16831. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16832. }
  16833. //SGR
  16834. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  16835. if (leftBindData != null)
  16836. {
  16837. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  16838. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  16839. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  16840. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16841. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16842. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16843. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16844. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16845. }
  16846. //JS/ES
  16847. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  16848. if (leftBindData != null)
  16849. {
  16850. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  16851. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  16852. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  16853. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16854. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16855. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16856. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16857. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16858. }
  16859. //SUITE
  16860. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  16861. if (leftBindData != null)
  16862. {
  16863. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  16864. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  16865. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  16866. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16867. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16868. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16869. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16870. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16871. }
  16872. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  16873. if (leftBindData != null)
  16874. {
  16875. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  16876. designer.SetDataSource("BDJRS", leftBindData.rs);
  16877. designer.SetDataSource("BDJXS", leftBindData.xs);
  16878. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16879. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16880. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16881. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16882. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16883. }
  16884. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  16885. if (leftBindData != null)
  16886. {
  16887. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  16888. designer.SetDataSource("BGWRS", leftBindData.rs);
  16889. designer.SetDataSource("BGWXS", leftBindData.xs);
  16890. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16891. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16892. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16893. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16894. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16895. }
  16896. #region 优化方案
  16897. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  16898. //excelBind.Add("零用金", new {
  16899. //cb="",
  16900. //rs="",
  16901. //xs ="",
  16902. //zcb = "",
  16903. //});
  16904. #endregion
  16905. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  16906. if (leftBindData != null)
  16907. {
  16908. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  16909. designer.SetDataSource("BLYJRS", leftBindData.rs);
  16910. designer.SetDataSource("BLYJXS", leftBindData.xs);
  16911. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16912. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16913. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16914. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16915. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16916. }
  16917. #endregion
  16918. #region B段Right信息
  16919. right = dto.rightInfo.Find(x => x.Type == "B");
  16920. if (right == null)
  16921. {
  16922. return Ok(jw);
  16923. }
  16924. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  16925. if (rightBindData != null)
  16926. {
  16927. //经济舱 + 双人间 TBR
  16928. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  16929. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  16930. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16931. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  16932. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16933. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16934. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16935. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16936. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16937. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16938. }
  16939. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  16940. if (rightBindData != null)
  16941. {
  16942. //经济舱 + 单人间 SGR
  16943. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  16944. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  16945. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16946. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  16947. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16948. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16949. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16950. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16951. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16952. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16953. }
  16954. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  16955. if (rightBindData != null)
  16956. {
  16957. //公务舱 + 单人间 SGR
  16958. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  16959. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  16960. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16961. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  16962. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16963. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16964. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16965. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16966. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16967. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16968. }
  16969. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  16970. if (rightBindData != null)
  16971. {
  16972. //公务舱 + 小套房 JSES
  16973. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  16974. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  16975. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16976. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  16977. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16978. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16979. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16980. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16981. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16982. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16983. }
  16984. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  16985. if (rightBindData != null)
  16986. {
  16987. //公务舱 + 小套房 JSES
  16988. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  16989. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  16990. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16991. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  16992. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16993. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16994. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16995. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16996. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16997. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16998. }
  16999. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  17000. if (rightBindData != null)
  17001. {
  17002. //经济舱 + 大套房
  17003. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  17004. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  17005. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  17006. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  17007. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  17008. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  17009. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  17010. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  17011. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  17012. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  17013. }
  17014. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  17015. if (rightBindData != null)
  17016. {
  17017. //头等舱 + 小套房 JSES
  17018. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  17019. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  17020. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  17021. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  17022. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  17023. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  17024. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  17025. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  17026. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  17027. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  17028. }
  17029. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  17030. if (rightBindData != null)
  17031. {
  17032. //头等舱 + 大套房
  17033. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  17034. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  17035. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  17036. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  17037. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  17038. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  17039. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  17040. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  17041. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  17042. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  17043. }
  17044. #endregion
  17045. #region 标题
  17046. designer.SetDataSource("CostBDRCB", "单人成本");
  17047. designer.SetDataSource("CostBRS", "人数");
  17048. designer.SetDataSource("CostBXS", "系数");
  17049. designer.SetDataSource("CostBZCB", "总成本");
  17050. designer.SetDataSource("CostBDRBJ", "单人报价");
  17051. designer.SetDataSource("CostBZBJ", "总报价");
  17052. designer.SetDataSource("CostBDRLR", "单人利润");
  17053. designer.SetDataSource("CostBZLR", "总利润");
  17054. designer.SetDataSource("CostBDRCBOM", "单人成本");
  17055. designer.SetDataSource("CostBRSOM", "人数");
  17056. designer.SetDataSource("CostBZCBOM", "总成本");
  17057. designer.SetDataSource("CostBDRBJOM", "单人报价");
  17058. designer.SetDataSource("CostBZBJOM", "总报价");
  17059. designer.SetDataSource("CostBDRLROM", "单人利润");
  17060. designer.SetDataSource("CostBZLROM", "总利润");
  17061. #endregion
  17062. }
  17063. #endregion
  17064. designer.SetDataSource("TzZCB2", TzZCB2);
  17065. designer.SetDataSource("TzZBJ2", TzZBJ2);
  17066. designer.SetDataSource("TzZLR2", TzZLR2);
  17067. string[] dataSourceKeys = new string[]
  17068. {
  17069. "VF",
  17070. "TGS",
  17071. "TGOF",
  17072. "TGM",
  17073. "TGA",
  17074. "TGTF",
  17075. "TGEF",
  17076. "CFM",
  17077. "CFOF",
  17078. "B",
  17079. "L",
  17080. "D",
  17081. "TBR",
  17082. "SGR",
  17083. "JSES",
  17084. "Suite",
  17085. "TV",
  17086. "1L",
  17087. "IF",
  17088. "EF",
  17089. "BRF",
  17090. "TE",
  17091. "TGT",
  17092. "DRVT",
  17093. "PC",
  17094. "TLF",
  17095. "ECT"
  17096. };
  17097. foreach (var item in dataSourceKeys)
  17098. {
  17099. Func<TitleModel, bool> expr = x => x.label.Replace(" ", "").Replace("/", "") == item
  17100. || x.label.Replace(" ", "").Replace("/", "").ToUpper() == item.ToUpper();
  17101. var find = dto.titleModel.FirstOrDefault(expr);
  17102. if (find != null)
  17103. {
  17104. designer.SetDataSource(item, find.text);
  17105. }
  17106. else
  17107. {
  17108. designer.SetDataSource(item, 0);
  17109. }
  17110. }
  17111. designer.SetDataSource(dt);
  17112. //根据数据源处理生成报表内容
  17113. designer.Process();
  17114. designer.Workbook.Worksheets[0].Name = "费用明细";
  17115. designer.Workbook.Worksheets[1].Name = "费用总核算";
  17116. Worksheet sheet = designer.Workbook.Worksheets[0];
  17117. #region 隐藏舱位
  17118. var settingAir = new[]
  17119. {
  17120. new { key = "经济舱", index = 7 },
  17121. new { key = "公务舱", index = 19 },
  17122. new { key = "头等舱", index = 11 }
  17123. };
  17124. var airType = _sqlSugar.Queryable<Grp_TourClientList>()
  17125. .LeftJoin<Sys_SetData>((c, s) => s.IsDel == 0 && c.ShippingSpaceTypeId == s.Id)
  17126. .Where((c, s) => c.IsDel == 0 && c.DiId == di.Id)
  17127. .Select((c, s) => s.Name)
  17128. .ToList()
  17129. .GroupBy(x => x)
  17130. .Select(x => x.Key);
  17131. foreach (var item in settingAir)
  17132. {
  17133. if (!airType.Contains(item.key))
  17134. {
  17135. hideRowsList.Add(item.index);
  17136. }
  17137. }
  17138. #endregion
  17139. foreach (var Rowindex in hideRowsList)
  17140. {
  17141. ws.Cells.HideRows(Rowindex, 2);
  17142. }
  17143. ws = designer.Workbook.Worksheets[0];
  17144. foreach (var Column in hideColumnList)
  17145. {
  17146. ws.Cells.HideColumns(Column, 1);
  17147. }
  17148. byte[] bytes = null;
  17149. string strFileName = di.TeamName + "-团组-成本.xls";
  17150. using (MemoryStream stream = new MemoryStream())
  17151. {
  17152. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  17153. bytes = stream.ToArray();
  17154. }
  17155. return Ok(JsonView(true, "", new
  17156. {
  17157. Data = bytes,
  17158. strFileName,
  17159. }));
  17160. }
  17161. /// <summary>
  17162. /// 导出客户报表
  17163. /// </summary>
  17164. /// <returns></returns>
  17165. [HttpPost]
  17166. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  17167. {
  17168. var jw = JsonView(false);
  17169. if (dto.Diid == 0)
  17170. {
  17171. return Ok(JsonView(false, "请传递团组id"));
  17172. }
  17173. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  17174. if (deleInfo.Code != 0)
  17175. {
  17176. return Ok(JsonView(false, "团组信息查询失败!"));
  17177. }
  17178. var di = deleInfo.Data as DelegationInfoWebView;
  17179. if (di == null)
  17180. {
  17181. return Ok(JsonView(false, "团组信息查询失败!"));
  17182. }
  17183. //文件名
  17184. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  17185. //获取模板
  17186. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  17187. //载入模板
  17188. Document doc = new Document(tmppath);
  17189. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  17190. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  17191. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  17192. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  17193. var AParameter = ParameterList.Find(x => x.CostType == "A");
  17194. var BParameter = ParameterList.Find(x => x.CostType == "B");
  17195. if (AParameter == null)
  17196. {
  17197. return Ok(JsonView(false, "系数不存在!"));
  17198. }
  17199. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  17200. , TzAirDesc, TzZCost;
  17201. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  17202. = TzAirDesc = TzZCost = string.Empty;
  17203. TzNumber = AParameter.CostTypenumber.ToString();
  17204. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  17205. CarGuides1 = dto.CarGuides1;
  17206. Meal = dto.Meal;
  17207. SubsidizedMeals = dto.SubsidizedMeals;
  17208. NightRepair = dto.NightRepair;
  17209. AttractionsTickets = dto.AttractionsTickets;
  17210. MiscellaneousFees = dto.MiscellaneousFees;
  17211. ATip = dto.ATip;
  17212. TzHotelDesc = "";
  17213. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  17214. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  17215. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  17216. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  17217. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  17218. TzAirDesc = "";
  17219. TzZCost = dto.TzZCost;
  17220. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  17221. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  17222. var index = 1;
  17223. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  17224. foreach (var item in TzHotelDescArr)
  17225. {
  17226. if (AinfoArr != null)
  17227. {
  17228. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  17229. if (Ainfo != null)
  17230. {
  17231. if (int.Parse(Ainfo.rs) <= 0)
  17232. {
  17233. continue;
  17234. }
  17235. var hotelText = string.Empty;
  17236. switch (item)
  17237. {
  17238. case "SGR":
  17239. hotelText = "单人间";
  17240. break;
  17241. case "JSES":
  17242. hotelText = "小套房";
  17243. break;
  17244. case "SUITE":
  17245. hotelText = "套房";
  17246. break;
  17247. case "TBR":
  17248. hotelText = "双人间";
  17249. break;
  17250. }
  17251. if (item != "TBR")
  17252. {
  17253. 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";
  17254. }
  17255. else
  17256. {
  17257. 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";
  17258. }
  17259. index++;
  17260. }
  17261. }
  17262. }
  17263. index = 1;
  17264. foreach (var item in TzAirDescArr)
  17265. {
  17266. if (AinfoArr != null)
  17267. {
  17268. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  17269. if (Ainfo != null)
  17270. {
  17271. if (int.Parse(Ainfo.rs) <= 0)
  17272. {
  17273. continue;
  17274. }
  17275. 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";
  17276. index++;
  17277. }
  17278. }
  17279. }
  17280. if (dto.costType == "B")
  17281. {
  17282. if (BParameter == null)
  17283. {
  17284. return Ok(JsonView(false, "B段系数不存在!"));
  17285. }
  17286. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  17287. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  17288. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  17289. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  17290. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  17291. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  17292. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  17293. foreach (var item in TzHotelDescArr)
  17294. {
  17295. if (AinfoArr != null)
  17296. {
  17297. TzHotelDesc += "B段信息 \r\n";
  17298. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  17299. if (Ainfo != null)
  17300. {
  17301. if (int.Parse(Ainfo.rs) <= 0)
  17302. {
  17303. continue;
  17304. }
  17305. var hotelText = string.Empty;
  17306. switch (item)
  17307. {
  17308. case "SGR":
  17309. hotelText = "单人间";
  17310. break;
  17311. case "JSES":
  17312. hotelText = "小套房";
  17313. break;
  17314. case "SUITE":
  17315. hotelText = "套房";
  17316. break;
  17317. case "TBR":
  17318. hotelText = "双人间";
  17319. break;
  17320. }
  17321. if (item != "TBR")
  17322. {
  17323. 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";
  17324. }
  17325. else
  17326. {
  17327. 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";
  17328. }
  17329. index++;
  17330. }
  17331. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  17332. }
  17333. }
  17334. index = 1;
  17335. foreach (var item in TzAirDescArr)
  17336. {
  17337. if (AinfoArr != null)
  17338. {
  17339. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  17340. if (Ainfo != null)
  17341. {
  17342. if (int.Parse(Ainfo.rs) <= 0)
  17343. {
  17344. continue;
  17345. }
  17346. 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";
  17347. index++;
  17348. }
  17349. }
  17350. }
  17351. }
  17352. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  17353. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  17354. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  17355. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  17356. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  17357. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  17358. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  17359. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  17360. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  17361. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  17362. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  17363. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  17364. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  17365. DickeyValue.Add("Visa", Visa); // 签证单人报价
  17366. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  17367. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  17368. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  17369. DickeyValue.Add("TzZCost", TzZCost);
  17370. foreach (var key in DickeyValue.Keys)
  17371. {
  17372. if (doc.Range.Bookmarks[key] != null)
  17373. {
  17374. Bookmark mark = doc.Range.Bookmarks[key];
  17375. mark.Text = DickeyValue[key];
  17376. }
  17377. }
  17378. byte[] bytes = null;
  17379. string strFileName = di.TeamName + "-客户报价.doc";
  17380. using (MemoryStream stream = new MemoryStream())
  17381. {
  17382. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  17383. bytes = stream.ToArray();
  17384. }
  17385. return Ok(JsonView(true, "", new
  17386. {
  17387. Data = bytes,
  17388. strFileName,
  17389. }));
  17390. }
  17391. /// <summary>
  17392. /// 团组成本 各模块(酒店,地接,机票)成本提示
  17393. /// </summary>
  17394. /// <param name="dto"></param>
  17395. /// <returns></returns>
  17396. [HttpPost]
  17397. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17398. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  17399. {
  17400. try
  17401. {
  17402. #region 参数验证
  17403. if (dto.DiId < 0)
  17404. {
  17405. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  17406. }
  17407. List<int> cTableIds = new List<int>() {
  17408. 76 ,//酒店预订
  17409. 77 ,//行程
  17410. 79 ,//车/导游地接
  17411. 80 ,//签证
  17412. 81 ,//邀请/公务活
  17413. 82 ,//团组客户保险
  17414. 85 ,//机票预订
  17415. 98 ,//其他款项
  17416. 285 ,//收款退还
  17417. 751 ,//酒店早餐
  17418. 1015 // 超支费用
  17419. };
  17420. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  17421. {
  17422. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  17423. }
  17424. #endregion
  17425. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  17426. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  17427. if (_GroupCostParameters.Count <= 0)
  17428. {
  17429. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  17430. }
  17431. if (_GroupCostParameters[0].IsShare == 0)
  17432. {
  17433. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  17434. }
  17435. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  17436. //处理date为空问题
  17437. if (_GroupCosts.Count > 0)
  17438. {
  17439. for (int i = 0; i < _GroupCosts.Count; i++)
  17440. {
  17441. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  17442. {
  17443. if (i > 0)
  17444. {
  17445. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  17446. }
  17447. }
  17448. }
  17449. }
  17450. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  17451. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  17452. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  17453. string currCode = "";
  17454. #region currCode 验证
  17455. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  17456. if (isInt)
  17457. {
  17458. var currData = currDatas.Find(it => it.Id == intCurrency);
  17459. if (currData != null)
  17460. {
  17461. currCode = currData.Name;
  17462. }
  17463. }
  17464. else
  17465. {
  17466. currCode = _GroupCostParameters[0].Currency.Trim();
  17467. }
  17468. #endregion
  17469. //op,酒店单段模式存储
  17470. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  17471. {
  17472. CurrencyCode = currCode,
  17473. Rate = _GroupCostParameters[0].Rate,
  17474. CostType = _GroupCostParameters[0].CostType,
  17475. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  17476. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  17477. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  17478. };
  17479. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  17480. if (_GroupCostParameters.Count == 2)
  17481. {
  17482. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  17483. }
  17484. foreach (var item in _GroupCostParameters)
  17485. {
  17486. decimal _rate = 1;
  17487. decimal _rate1 = item.Rate;
  17488. decimal _scale = 1;
  17489. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  17490. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  17491. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  17492. //if (userInfo != null)
  17493. //{
  17494. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  17495. // {
  17496. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  17497. // {
  17498. // _scale = 1.00M;
  17499. // }
  17500. // }
  17501. //}
  17502. #endregion
  17503. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  17504. {
  17505. CurrencyCode = currCode,
  17506. Rate = _rate1,
  17507. CostType = item.CostType,
  17508. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  17509. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  17510. CostTypeNumber = item.CostTypenumber
  17511. };
  17512. if (_GroupCostParameters.Count > 1)
  17513. {
  17514. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  17515. }
  17516. else
  17517. {
  17518. modulePromptInfo.CostTypeNumber = item.LYJRS;
  17519. }
  17520. if (dto.CTable == 79)//
  17521. {
  17522. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  17523. modulePromptInfo.TotalCost = item.DJCB;
  17524. }
  17525. List<string> costTypes = new List<string>() { "A", "B" };
  17526. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  17527. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  17528. if (_GroupCostsDuplicates.Count() == 1)
  17529. {
  17530. _GroupCostsTypeData = _GroupCosts;
  17531. }
  17532. else
  17533. {
  17534. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  17535. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  17536. }
  17537. /*
  17538. * 76 酒店预订
  17539. * 77 行程
  17540. * 79 车/导游地接
  17541. * 80 签证
  17542. * 81 邀请/公务活动
  17543. * 82 团组客户保险
  17544. * 85 机票预订
  17545. * 98 其他款项
  17546. * 285 收款退还
  17547. * 751 酒店早餐
  17548. * 1015 超支费用
  17549. */
  17550. switch (dto.CTable)
  17551. {
  17552. case 76: // 酒店预订
  17553. _ModuleSubPromptInfo.AddRange(
  17554. _GroupCostsTypeData.Select(it => new
  17555. {
  17556. it.DAY,
  17557. it.Date,
  17558. it.ACCON,
  17559. it.ITIN,
  17560. it.SGR,
  17561. it.TBR,
  17562. it.JS_ES,
  17563. it.Suite
  17564. })
  17565. );
  17566. break;
  17567. case 79: // 车/导游地接
  17568. _ModuleSubPromptInfo.AddRange(
  17569. _GroupCostsTypeData.Select(it => new
  17570. {
  17571. Date = it.Date, //日期
  17572. CarFee = it.CarCost * _rate * _scale, //车费用
  17573. CarType = it.CarType, //车型
  17574. DriverFee = it.CFS * _rate * _scale, //司机工资
  17575. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  17576. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  17577. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  17578. GuideFee = it.TGS * _rate * _scale, //导游费用
  17579. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  17580. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  17581. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  17582. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  17583. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  17584. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  17585. Breakfast = it.B * _rate * _scale, //早餐费
  17586. Lunch = it.L * _rate * _scale, //午餐费
  17587. Dinner = it.D * _rate * _scale, //晚餐费
  17588. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  17589. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  17590. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  17591. TicketFee = it.EF * _rate * _scale, //门票费
  17592. TicketRemark = it.EFR, //门票费描述
  17593. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  17594. TravelSupplies = it.TE * _rate * _scale, //出行物资
  17595. SpentCash = it.PC * _rate * _scale, //零用金
  17596. LeadersFee = it.TLF * _rate * _scale, //领队费
  17597. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  17598. })
  17599. );
  17600. break;
  17601. case 85: // 机票
  17602. List<dynamic> datas = new List<dynamic>();
  17603. datas.Add(
  17604. new
  17605. {
  17606. AirType = "经济舱",
  17607. AirNum = item.JJCRS,
  17608. AirDRCB = item.JJCCB,
  17609. AirZCB = (item.JJCRS * item.JJCCB)
  17610. }
  17611. );
  17612. datas.Add(
  17613. new
  17614. {
  17615. AirType = "公务舱",
  17616. AirNum = item.GWCRS,
  17617. AirDRCB = item.GWCCB,
  17618. AirZCB = (item.GWCRS * item.GWCCB)
  17619. }
  17620. );
  17621. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  17622. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  17623. modulePromptInfo.Data = new
  17624. {
  17625. airFeeData = datas,
  17626. airInitData = initDatas
  17627. };
  17628. _ModulePromptInfos.Add(modulePromptInfo);
  17629. break;
  17630. default:
  17631. break;
  17632. }
  17633. }
  17634. if (dto.CTable != 85)
  17635. {
  17636. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  17637. _ModulePromptInfos.Add(_ModulePromptInfo);
  17638. }
  17639. _view.ModulePromptInfos = _ModulePromptInfos;
  17640. return Ok(JsonView(true, "操作成功!", _view));
  17641. }
  17642. catch (Exception ex)
  17643. {
  17644. return Ok(JsonView(false, ex.Message));
  17645. }
  17646. }
  17647. /// <summary>
  17648. /// 根据黑屏代码重新生成行程
  17649. /// </summary>
  17650. /// <param name="dto"></param>
  17651. /// <returns></returns>
  17652. [HttpPost]
  17653. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  17654. {
  17655. var jw = JsonView(false, "Error");
  17656. var Create = _sqlSugar.Queryable<Air_TicketBlackCode>()
  17657. .Where(x => x.IsDel == 0 && x.DiId == dto.Diid)
  17658. .Select(x => new
  17659. {
  17660. x.Id,
  17661. x.Title
  17662. })
  17663. .ToList();
  17664. if (Create.Any())
  17665. {
  17666. jw.Msg = "获取成功!";
  17667. jw.Code = 200;
  17668. jw.Data = new
  17669. {
  17670. BlackCodeListSelect = Create,
  17671. blackCodeIsTrue = true
  17672. };
  17673. }
  17674. else
  17675. {
  17676. jw.Code = 400;
  17677. jw.Data = new
  17678. {
  17679. BlackCodeListSelect = Create,
  17680. blackCodeIsTrue = false,
  17681. };
  17682. }
  17683. return Ok(jw);
  17684. }
  17685. /// <summary>
  17686. /// 根据黑屏代码Id重新生成行程
  17687. /// </summary>
  17688. /// <param name="dto"></param>
  17689. /// <returns></returns>
  17690. [HttpPost]
  17691. public IActionResult CraeteGroupCostTravelById(CraeteGroupCostTravelByIdDto dto)
  17692. {
  17693. var jw = JsonView(false, "Error");
  17694. var result = _GroupCostRepository.CreateGroupCostByBlackCode(dto.DiId, dto.BlackCodeId);
  17695. if (result.Code == 0)
  17696. {
  17697. jw.Msg = "获取成功!";
  17698. jw.Code = 200;
  17699. jw.Data = new
  17700. {
  17701. groupCost = result.Data,
  17702. blackCodeIsTrue = true
  17703. };
  17704. }
  17705. else
  17706. {
  17707. jw.Code = 400;
  17708. jw.Data = new
  17709. {
  17710. groupCost = result.Data,
  17711. blackCodeIsTrue = false,
  17712. };
  17713. }
  17714. return Ok(jw);
  17715. }
  17716. /// <summary>
  17717. /// 成本获取OP历史车费用
  17718. /// </summary>
  17719. /// <param name="dto"></param>
  17720. /// <returns></returns>
  17721. [HttpPost]
  17722. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  17723. {
  17724. var jw = JsonView(false);
  17725. try
  17726. {
  17727. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  17728. //获取现有所有车的数据
  17729. if (!dto.Param.IsNullOrWhiteSpace())
  17730. {
  17731. string sql = $@"
  17732. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  17733. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  17734. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  17735. 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
  17736. AND gctggr.ServiceEndTime is not NULL
  17737. ORDER by gctggrc.id DESC
  17738. ";
  17739. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  17740. var numeberResult = await Task.Run(() =>
  17741. {
  17742. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  17743. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  17744. return numberArr;
  17745. });
  17746. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  17747. foreach (var item in numeberResult)
  17748. {
  17749. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  17750. {
  17751. Country = "数据异常!",
  17752. City = string.Empty,
  17753. };
  17754. item.Area = find.Country + " " + find.City;
  17755. }
  17756. dbResult.AddRange(numeberResult);
  17757. if (dto.Param.Contains("、"))
  17758. {
  17759. var sp = dto.Param.Split("、");
  17760. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  17761. .Where(x =>
  17762. {
  17763. return System.Array.Exists(sp, e =>
  17764. {
  17765. bool where = false;
  17766. if (x.Area != null)
  17767. {
  17768. where = x.Area.Contains(e);
  17769. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  17770. {
  17771. return false;
  17772. }
  17773. }
  17774. if (x.PriceName != null && !where)
  17775. {
  17776. where = x.PriceName.Contains(e);
  17777. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  17778. {
  17779. return false;
  17780. }
  17781. }
  17782. return where;
  17783. });
  17784. }).ToList();
  17785. }
  17786. else
  17787. {
  17788. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  17789. .Where(x =>
  17790. {
  17791. bool where = false;
  17792. if (x.Area != null)
  17793. {
  17794. where = x.Area.Contains(dto.Param);
  17795. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  17796. {
  17797. return false;
  17798. }
  17799. }
  17800. if (x.PriceName != null && !where)
  17801. {
  17802. where = x.PriceName.Contains(dto.Param);
  17803. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  17804. {
  17805. return false;
  17806. }
  17807. }
  17808. return where;
  17809. }
  17810. )
  17811. .ToList();
  17812. }
  17813. }
  17814. var view = dbResult.Select(x =>
  17815. {
  17816. decimal dp = 0.00M;
  17817. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  17818. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  17819. if (string.IsNullOrWhiteSpace(x.DatePrice))
  17820. {
  17821. if (startB && endB)
  17822. {
  17823. var timesp = endD.Subtract(startD);
  17824. if ((timesp.Days + 1) != 0)
  17825. {
  17826. dp = x.Price / (timesp.Days + 1);
  17827. }
  17828. }
  17829. }
  17830. else
  17831. {
  17832. dp = x.Price;
  17833. }
  17834. return new
  17835. {
  17836. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  17837. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  17838. x.Area,
  17839. x.id,
  17840. price = x.Price.ToString("F2"),
  17841. x.PriceName,
  17842. x.PriceContent,
  17843. x.TeamName,
  17844. x.DatePrice,
  17845. dayPrice = dp.ToString("F2"),
  17846. };
  17847. }).OrderByDescending(x => x.id).ToList();
  17848. jw = JsonView(true, "获取成功!", view);
  17849. }
  17850. catch (Exception e)
  17851. {
  17852. jw = JsonView(false, e.Message);
  17853. }
  17854. return Ok(jw);
  17855. }
  17856. [HttpPost]
  17857. public async Task<IActionResult> SearchGroupByKeyword(SearchGroupByKeywordDto dto)
  17858. {
  17859. var jw = JsonView(true);
  17860. List<DelegationInfoAndIsTrueView> matches = new List<DelegationInfoAndIsTrueView>();
  17861. #region SQL语句
  17862. //if (string.IsNullOrWhiteSpace(dto.Keyword))
  17863. //{
  17864. // matches = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  17865. // Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  17866. // WHEN COUNT(*) >= 0 THEN 'True'
  17867. // ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  17868. // Where TeamName != '' And IsDel = 0 Order By a.VisitStartDate Desc
  17869. // ")
  17870. // .ToList();
  17871. //}
  17872. //else
  17873. //{
  17874. // string likeKey = string.Empty;
  17875. // foreach (var item in dto.Keyword)
  17876. // {
  17877. // likeKey += "%" + item;
  17878. // }
  17879. // likeKey += "%";
  17880. // matches = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  17881. // Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  17882. // WHEN COUNT(*) >= 0 THEN 'True'
  17883. // ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  17884. // Where TeamName != '' And IsDel = 0 And TeamName LIKE '{likeKey}' Order By a.VisitStartDate Desc
  17885. // ")
  17886. // .ToList();
  17887. //}
  17888. #endregion
  17889. var table = _sqlSugar.Ado.UseStoredProcedure().GetDataTable("SearchGroupByKeyword", new
  17890. {
  17891. @KeyWord = dto.Keyword
  17892. });
  17893. if (table != null && table.Rows.Count > 0)
  17894. {
  17895. foreach (DataRow row in table.Rows)
  17896. {
  17897. matches.Add(new DelegationInfoAndIsTrueView
  17898. {
  17899. Id = row.Field<int>("Id"),
  17900. GroupName = row.Field<string>("GroupName"),
  17901. isTrue = row.Field<string>("isTrue")
  17902. });
  17903. }
  17904. }
  17905. if (matches.Any())
  17906. {
  17907. jw.Data = matches;
  17908. }
  17909. else
  17910. {
  17911. jw.Code = 201;
  17912. jw.Msg = "empty list";
  17913. jw.Data = new List<string>(1);
  17914. }
  17915. return Ok(jw);
  17916. }
  17917. /// <summary>
  17918. /// 报价Word下载
  17919. /// </summary>
  17920. /// <param name="dto"></param>
  17921. /// <returns></returns>
  17922. [HttpPost]
  17923. public async Task<IActionResult> GroupQuotationsFileDown(GroupQuotationsFileDownDto dto)
  17924. {
  17925. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  17926. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  17927. if (di == null)
  17928. {
  17929. return Ok(JsonView(false, "团组不存在!"));
  17930. }
  17931. var mainPrice = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  17932. if (mainPrice == null || mainPrice.IsShare == 0)
  17933. {
  17934. return Ok(JsonView(false, "团组成本不存在!"));
  17935. }
  17936. var costTypeHotelNumbers = await _sqlSugar.Queryable<Grp_CostTypeHotelNumber>()
  17937. .FirstAsync(x => x.Type == "Default" && x.Diid == dto.Diid && x.IsDel == 0);
  17938. if (costTypeHotelNumbers == null)
  17939. {
  17940. return Ok(JsonView(false, "团组成本不存在!"));
  17941. }
  17942. //文件名
  17943. string strFileName = di.TeamName + "-收款账单.doc";
  17944. //获取模板
  17945. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  17946. //载入模板
  17947. Document doc = new Document(tmppath);
  17948. decimal allPrice = 0.00M;
  17949. string itemStr = string.Empty;
  17950. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  17951. airSouer.Add("经济舱TBR", "经济舱及酒店双人间");
  17952. airSouer.Add("经济舱SGR", "经济舱及酒店单人间");
  17953. airSouer.Add("公务舱SGR", "公务舱及酒店单人间");
  17954. airSouer.Add("公务舱JSES", "公务舱及酒店小套房");
  17955. airSouer.Add("公务舱SUITE", "公务舱及酒店套房");
  17956. airSouer.Add("经济舱SUITE", "经济舱及酒店套房");
  17957. airSouer.Add("头等舱JSES", "头等舱及酒店小套房");
  17958. airSouer.Add("头等舱SUITE", "头等舱及酒店套房");
  17959. airSouer.Add("经济舱JSES", "经济舱及酒店小套房");
  17960. var priceDataList = new List<(string rsName, string cbName, string xsName, string prefix)>
  17961. {
  17962. ("VisaRS", "VisaCB", "VisaXS", "qz"),
  17963. ("BXRS", "BXCB", "BXXS", "bx"),
  17964. ("HCPRS", "HCPCB", "HCPXS", "hcp"),
  17965. ("JJCRS", "JJCCB", "JJCXS", "jjc"),
  17966. ("GWCRS", "GWCCB", "GWCXS", "gwc"),
  17967. ("TDCRS", "TDCCB", "TDCXS", "tdc"),
  17968. ("CPRS", "CPCB", "CPXS", "cp"),
  17969. ("HSRS", "HSCB", "HSXS", "hsjc"),
  17970. ("TBRNumber", "TBRCB", "TBRXS", "tbr"),
  17971. ("SGRNumber", "SGRCB", "SGRXS", "sgr"),
  17972. ("JSESNumber", "JSESCB", "JSESXS", "jses"),
  17973. ("SUITENumber", "SUITECB", "SUITEXS", "suite"),
  17974. ("DJRS", "DJCB", "DJXS", "dj"),
  17975. ("GWRS", "GWCB", "GWXS", "gw"),
  17976. ("LYJRS", "LYJCB", "LYJXS", "lyj"),
  17977. };
  17978. var OtherCostPropertyBJ = new string[] { "qz", "hcp", "cp", "bx", "hsjc", "dj", "gw", "lyj" };
  17979. var rightSum = 0.00M;
  17980. foreach (var (rsName, cbName, xsName, prefix) in priceDataList)
  17981. {
  17982. var rsValue = (int)mainPrice.GetType().GetProperty(rsName).GetValue(mainPrice);
  17983. var cbValue = (decimal)mainPrice.GetType().GetProperty(cbName).GetValue(mainPrice);
  17984. var xsValue = (decimal)mainPrice.GetType().GetProperty(xsName).GetValue(mainPrice);
  17985. if (prefix == "tbr")
  17986. {
  17987. rsValue *= 2;
  17988. cbValue /= 2;
  17989. }
  17990. if (OtherCostPropertyBJ.Contains(prefix))
  17991. {
  17992. rightSum += cbValue * xsValue;
  17993. }
  17994. }
  17995. var hotelRooms = new Dictionary<string, int>
  17996. {
  17997. { "SGR", costTypeHotelNumbers.SGR },
  17998. { "TBR", costTypeHotelNumbers.TBR },
  17999. { "JSES", costTypeHotelNumbers.JSES },
  18000. { "SUITE", costTypeHotelNumbers.SUITE }
  18001. };
  18002. var flights = new Dictionary<string, int>
  18003. {
  18004. { "经济舱", mainPrice.JJCRS },
  18005. { "公务舱", mainPrice.GWCRS },
  18006. { "头等舱", mainPrice.TDCRS }
  18007. };
  18008. var flightRoomMatchingRules = new Dictionary<string, string[]>
  18009. {
  18010. { "经济舱", new[] { "TBR", "SGR", "JSES", "SUITE" } },
  18011. { "公务舱", new[] { "SUITE", "JSES", "SGR" } },
  18012. { "头等舱", new[] { "SUITE", "JSES" } }
  18013. };
  18014. var result = new Dictionary<string, int>();
  18015. List<AirHotelPrice> airHotelPriceList = new List<AirHotelPrice>();
  18016. foreach (var flight in flights.Keys)
  18017. {
  18018. // 获取当前舱位的匹配规则
  18019. if (flightRoomMatchingRules.TryGetValue(flight, out string[] roomTypes))
  18020. {
  18021. MatchRooms(ref hotelRooms, ref flights, roomTypes, flight, ref result);
  18022. }
  18023. }
  18024. #region right计算
  18025. if (result.Keys.Contains("经济舱TBR") && result["经济舱TBR"] > 0)
  18026. {
  18027. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  18028. var hotel = (mainPrice.TBRCB * mainPrice.TBRXS) / 2;
  18029. airHotelPriceList.Add(new
  18030. AirHotelPrice
  18031. {
  18032. Name = "经济舱TBR",
  18033. Price = rightSum + air + hotel,
  18034. Count = result["经济舱TBR"] * 2
  18035. });
  18036. allPrice += (rightSum + air + hotel) * result["经济舱TBR"] * 2;
  18037. }
  18038. if (result.Keys.Contains("经济舱SGR") && result["经济舱SGR"] > 0)
  18039. {
  18040. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  18041. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  18042. airHotelPriceList.Add(new
  18043. AirHotelPrice
  18044. {
  18045. Name = "经济舱SGR",
  18046. Price = rightSum + air + hotel,
  18047. Count = result["经济舱SGR"]
  18048. });
  18049. allPrice += (rightSum + air + hotel) * result["经济舱SGR"];
  18050. }
  18051. if (result.Keys.Contains("公务舱SGR") && result["公务舱SGR"] > 0)
  18052. {
  18053. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  18054. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  18055. airHotelPriceList.Add(new
  18056. AirHotelPrice
  18057. {
  18058. Name = "公务舱SGR",
  18059. Price = rightSum + air + hotel,
  18060. Count = result["公务舱SGR"]
  18061. });
  18062. allPrice += (rightSum + air + hotel) * result["公务舱SGR"];
  18063. }
  18064. if (result.Keys.Contains("公务舱JSES") && result["公务舱JSES"] > 0)
  18065. {
  18066. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  18067. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  18068. airHotelPriceList.Add(new
  18069. AirHotelPrice
  18070. {
  18071. Name = "公务舱JSES",
  18072. Price = rightSum + air + hotel,
  18073. Count = result["公务舱JSES"]
  18074. });
  18075. allPrice += (rightSum + air + hotel) * result["公务舱JSES"];
  18076. }
  18077. if (result.Keys.Contains("公务舱SUITE") && result["公务舱SUITE"] > 0)
  18078. {
  18079. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  18080. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  18081. airHotelPriceList.Add(new
  18082. AirHotelPrice
  18083. {
  18084. Name = "公务舱SUITE",
  18085. Price = rightSum + air + hotel,
  18086. Count = result["公务舱SUITE"]
  18087. });
  18088. allPrice += (rightSum + air + hotel) * result["公务舱SUITE"];
  18089. }
  18090. if (result.Keys.Contains("经济舱SUITE") && result["经济舱SUITE"] > 0)
  18091. {
  18092. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  18093. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  18094. airHotelPriceList.Add(new
  18095. AirHotelPrice
  18096. {
  18097. Name = "经济舱SUITE",
  18098. Price = rightSum + air + hotel,
  18099. Count = result["经济舱SUITE"]
  18100. });
  18101. allPrice += (rightSum + air + hotel) * result["经济舱SUITE"];
  18102. }
  18103. if (result.Keys.Contains("头等舱JSES") && result["头等舱JSES"] > 0)
  18104. {
  18105. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  18106. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  18107. airHotelPriceList.Add(new
  18108. AirHotelPrice
  18109. {
  18110. Name = "头等舱JSES",
  18111. Price = rightSum + air + hotel,
  18112. Count = result["头等舱JSES"]
  18113. });
  18114. allPrice += (rightSum + air + hotel) * result["头等舱JSES"];
  18115. }
  18116. if (result.Keys.Contains("头等舱SUITE") && result["头等舱SUITE"] > 0)
  18117. {
  18118. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  18119. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  18120. airHotelPriceList.Add(new
  18121. AirHotelPrice
  18122. {
  18123. Name = "头等舱SUITE",
  18124. Price = rightSum + air + hotel,
  18125. Count = result["头等舱SUITE"]
  18126. });
  18127. allPrice += (rightSum + air + hotel) * result["头等舱SUITE"];
  18128. }
  18129. if (result.Keys.Contains("经济舱JSES") && result["经济舱JSES"] > 0)
  18130. {
  18131. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  18132. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  18133. airHotelPriceList.Add(new
  18134. AirHotelPrice
  18135. {
  18136. Name = "经济舱JSES",
  18137. Price = rightSum + air + hotel,
  18138. Count = result["经济舱JSES"]
  18139. });
  18140. allPrice += (rightSum + air + hotel) * result["经济舱JSES"];
  18141. }
  18142. #endregion
  18143. foreach (var item in airSouer.Keys)
  18144. {
  18145. var find = airHotelPriceList.FirstOrDefault(x => x.Name == item);
  18146. if (find != null && find.Count > 0)
  18147. {
  18148. if (item.Contains("TBR"))
  18149. {
  18150. itemStr += "团费(" + airSouer[item] + ") RMB " + find.Price.ToString("F2") + "/人*" + find.Count + "(" + (find.Count / 2) + "间) ............合计 RMB " + (find.Count * find.Price).ToString("#0.00") + "\n";
  18151. }
  18152. else
  18153. {
  18154. itemStr += "团费(" + airSouer[item] + ") RMB " + find.Price.ToString("F2") + "/人*" + find.Count + "(" + find.Count + "间) ............合计 RMB " + (find.Count * find.Price).ToString("#0.00") + "\n";
  18155. }
  18156. }
  18157. }
  18158. #region 替换Word模板书签内容
  18159. Dictionary<string, string> marks = new Dictionary<string, string>();
  18160. marks.Add("To", di.ClientUnit);//付款方
  18161. marks.Add("ToTel", di.TellPhone);//付款方电话
  18162. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  18163. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  18164. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  18165. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  18166. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  18167. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  18168. marks.Add("PayItemContent", itemStr);//详细信息
  18169. marks.Add("Total", allPrice.ToString("F2"));//合计
  18170. #endregion
  18171. foreach (var item in marks.Keys)
  18172. {
  18173. if (doc.Range.Bookmarks[item] != null)
  18174. {
  18175. Bookmark mark = doc.Range.Bookmarks[item];
  18176. mark.Text = marks[item];
  18177. }
  18178. }
  18179. string savePaht = $"{AppSettingsHelper.Get("WordBasePath")}GroupCostQuotations/{di.TeamName}_报批费用.doc";
  18180. doc.Save(savePaht);
  18181. var jw = new JsonView();
  18182. jw.Msg = "生成成功!";
  18183. jw.Code = 200;
  18184. jw.Data = new { Url = AppSettingsHelper.Get("WordBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("WordBasePath"), AppSettingsHelper.Get("WordFtpPath")) };
  18185. return Ok(jw);
  18186. }
  18187. /// <summary>
  18188. /// 详细报价费用Excel下载
  18189. /// </summary>
  18190. /// <param name="dto"></param>
  18191. /// <returns></returns>
  18192. [HttpPost]
  18193. public async Task<IActionResult> GroupQuotationsDetailFileDown(GroupQuotationsFileDownDto dto)
  18194. {
  18195. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  18196. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  18197. if (di == null)
  18198. {
  18199. return Ok(JsonView(false, "团组不存在!"));
  18200. }
  18201. var mainPrice = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  18202. if (mainPrice == null || mainPrice.IsShare == 0)
  18203. {
  18204. return Ok(JsonView(false, "团组成本不存在!"));
  18205. }
  18206. var costTypeHotelNumbers = await _sqlSugar.Queryable<Grp_CostTypeHotelNumber>()
  18207. .FirstAsync(x => x.Type == "Default" && x.Diid == dto.Diid && x.IsDel == 0);
  18208. if (costTypeHotelNumbers == null)
  18209. {
  18210. return Ok(JsonView(false, "团组成本不存在!"));
  18211. }
  18212. WorkbookDesigner designer = new WorkbookDesigner();
  18213. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/报价详细表.xls"));
  18214. List<int> hideRowsList = new List<int>();
  18215. int conterStartIndex = 3;
  18216. int rowIndex = conterStartIndex;
  18217. designer.SetDataSource("GroupName", di.TeamName);
  18218. var priceDataList = new List<(string rsName, string cbName, string xsName, string prefix)>
  18219. {
  18220. ("VisaRS", "VisaCB", "VisaXS", "qz"),
  18221. ("BXRS", "BXCB", "BXXS", "bx"),
  18222. ("HCPRS", "HCPCB", "HCPXS", "hcp"),
  18223. ("JJCRS", "JJCCB", "JJCXS", "jjc"),
  18224. ("GWCRS", "GWCCB", "GWCXS", "gwc") ,
  18225. ("TDCRS", "TDCCB", "TDCXS", "tdc") ,
  18226. ("CPRS", "CPCB", "CPXS", "cp") ,
  18227. ("HSRS", "HSCB", "HSXS", "hsjc") ,
  18228. ("TBRNumber", "TBRCB", "TBRXS", "tbr") ,
  18229. ("SGRNumber", "SGRCB", "SGRXS", "sgr") ,
  18230. ("JSESNumber", "JSESCB", "JSESXS", "jses") ,
  18231. ("SUITENumber", "SUITECB", "SUITEXS", "suite") ,
  18232. ("DJRS", "DJCB", "DJXS", "dj") ,
  18233. ("GWRS", "GWCB", "GWXS", "gw") ,
  18234. ("LYJRS", "LYJCB", "LYJXS", "lyj") ,
  18235. };
  18236. var OtherCostPropertyBJ = new string[] { "qz", "hcp", "cp", "bx", "hsjc", "dj", "gw", "lyj" };
  18237. var rightSum = 0.00M;
  18238. foreach (var (rsName, cbName, xsName, prefix) in priceDataList)
  18239. {
  18240. var rsValue = (int)mainPrice.GetType().GetProperty(rsName).GetValue(mainPrice);
  18241. var cbValue = (decimal)mainPrice.GetType().GetProperty(cbName).GetValue(mainPrice);
  18242. var xsValue = (decimal)mainPrice.GetType().GetProperty(xsName).GetValue(mainPrice);
  18243. if (prefix == "tbr")
  18244. {
  18245. rsValue *= 2;
  18246. cbValue /= 2;
  18247. }
  18248. if (OtherCostPropertyBJ.Contains(prefix))
  18249. {
  18250. rightSum += cbValue * xsValue;
  18251. }
  18252. if (rsValue == 0)
  18253. {
  18254. hideRowsList.Add(rowIndex);
  18255. }
  18256. else
  18257. {
  18258. designer.SetDataSource($"{prefix}rs", rsValue);
  18259. designer.SetDataSource($"{prefix}bj", cbValue * xsValue);
  18260. designer.SetDataSource($"{prefix}zbj", cbValue * xsValue * rsValue);
  18261. }
  18262. rowIndex += 2;
  18263. }
  18264. var hotelRooms = new Dictionary<string, int>
  18265. {
  18266. { "SGR", costTypeHotelNumbers.SGR },
  18267. { "TBR", costTypeHotelNumbers.TBR },
  18268. { "JSES", costTypeHotelNumbers.JSES },
  18269. { "SUITE", costTypeHotelNumbers.SUITE }
  18270. };
  18271. var flights = new Dictionary<string, int>
  18272. {
  18273. { "经济舱", mainPrice.JJCRS },
  18274. { "公务舱", mainPrice.GWCRS },
  18275. { "头等舱", mainPrice.TDCRS }
  18276. };
  18277. var flightRoomMatchingRules = new Dictionary<string, string[]>
  18278. {
  18279. { "经济舱", new[] { "TBR", "SGR", "JSES", "SUITE" } },
  18280. { "公务舱", new[] { "SUITE", "JSES", "SGR" } },
  18281. { "头等舱", new[] { "SUITE", "JSES" } }
  18282. };
  18283. var result = new Dictionary<string, int>();
  18284. foreach (var flight in flights.Keys)
  18285. {
  18286. // 获取当前舱位的匹配规则
  18287. if (flightRoomMatchingRules.TryGetValue(flight, out string[] roomTypes))
  18288. {
  18289. MatchRooms(ref hotelRooms, ref flights, roomTypes, flight, ref result);
  18290. }
  18291. }
  18292. var allPrice = 0.00M;
  18293. #region right计算
  18294. int airRowIndex = 35;
  18295. if (result.Keys.Contains("经济舱TBR") && result["经济舱TBR"] > 0)
  18296. {
  18297. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  18298. var hotel = (mainPrice.TBRCB * mainPrice.TBRXS) / 2;
  18299. designer.SetDataSource("jjctbrrs", result["经济舱TBR"] * 2);
  18300. designer.SetDataSource("jjctbrbj", rightSum + air + hotel);
  18301. designer.SetDataSource("jjctbrzbj", (rightSum + air + hotel) * result["经济舱TBR"] * 2);
  18302. allPrice += (rightSum + air + hotel) * result["经济舱TBR"] * 2;
  18303. }
  18304. else
  18305. {
  18306. hideRowsList.Add(airRowIndex);
  18307. }
  18308. airRowIndex += 2;
  18309. if (result.Keys.Contains("经济舱SGR") && result["经济舱SGR"] > 0)
  18310. {
  18311. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  18312. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  18313. designer.SetDataSource("jjcsgrrs", result["经济舱SGR"]);
  18314. designer.SetDataSource("jjcsgrbj", rightSum + air + hotel);
  18315. designer.SetDataSource("jjcsgrzbj", (rightSum + air + hotel) * result["经济舱SGR"]);
  18316. allPrice += (rightSum + air + hotel) * result["经济舱SGR"];
  18317. }
  18318. else
  18319. {
  18320. hideRowsList.Add(airRowIndex);
  18321. }
  18322. airRowIndex += 2;
  18323. if (result.Keys.Contains("公务舱SGR") && result["公务舱SGR"] > 0)
  18324. {
  18325. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  18326. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  18327. designer.SetDataSource("gwcsgrrs", result["公务舱SGR"]);
  18328. designer.SetDataSource("gwcsgrbj", rightSum + air + hotel);
  18329. designer.SetDataSource("gwcsgrzbj", (rightSum + air + hotel) * result["公务舱SGR"]);
  18330. allPrice += (rightSum + air + hotel) * result["公务舱SGR"];
  18331. }
  18332. else
  18333. {
  18334. hideRowsList.Add(airRowIndex);
  18335. }
  18336. airRowIndex += 2;
  18337. if (result.Keys.Contains("公务舱JSES") && result["公务舱JSES"] > 0)
  18338. {
  18339. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  18340. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  18341. designer.SetDataSource("gwcjsesrs", result["公务舱JSES"]);
  18342. designer.SetDataSource("gwcjsesbj", rightSum + air + hotel);
  18343. designer.SetDataSource("gwcjseszbj", (rightSum + air + hotel) * result["公务舱JSES"]);
  18344. allPrice += (rightSum + air + hotel) * result["公务舱JSES"];
  18345. }
  18346. else
  18347. {
  18348. hideRowsList.Add(airRowIndex);
  18349. }
  18350. airRowIndex += 2;
  18351. if (result.Keys.Contains("公务舱SUITE") && result["公务舱SUITE"] > 0)
  18352. {
  18353. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  18354. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  18355. designer.SetDataSource("gwcsuiters", result["公务舱SUITE"]);
  18356. designer.SetDataSource("gwcsuitebj", rightSum + air + hotel);
  18357. designer.SetDataSource("gwcsuitezbj", (rightSum + air + hotel) * result["公务舱SUITE"]);
  18358. allPrice += (rightSum + air + hotel) * result["公务舱SUITE"];
  18359. }
  18360. else
  18361. {
  18362. hideRowsList.Add(airRowIndex);
  18363. }
  18364. airRowIndex += 2;
  18365. if (result.Keys.Contains("经济舱SUITE") && result["经济舱SUITE"] > 0)
  18366. {
  18367. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  18368. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  18369. designer.SetDataSource("jjcsuiters", result["经济舱SUITE"]);
  18370. designer.SetDataSource("jjcsuitebj", rightSum + air + hotel);
  18371. designer.SetDataSource("jjcsuitezbj", (rightSum + air + hotel) * result["经济舱SUITE"]);
  18372. allPrice += (rightSum + air + hotel) * result["经济舱SUITE"];
  18373. }
  18374. else
  18375. {
  18376. hideRowsList.Add(airRowIndex);
  18377. }
  18378. airRowIndex += 2;
  18379. if (result.Keys.Contains("头等舱JSES") && result["头等舱JSES"] > 0)
  18380. {
  18381. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  18382. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  18383. designer.SetDataSource("tdcjsesrs", result["头等舱JSES"]);
  18384. designer.SetDataSource("tdcjsesbj", rightSum + air + hotel);
  18385. designer.SetDataSource("tdcjseszbj", (rightSum + air + hotel) * result["头等舱JSES"]);
  18386. allPrice += (rightSum + air + hotel) * result["头等舱JSES"];
  18387. }
  18388. else
  18389. {
  18390. hideRowsList.Add(airRowIndex);
  18391. }
  18392. airRowIndex += 2;
  18393. if (result.Keys.Contains("头等舱SUITE") && result["头等舱SUITE"] > 0)
  18394. {
  18395. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  18396. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  18397. designer.SetDataSource("tdcsuiters", result["头等舱SUITE"]);
  18398. designer.SetDataSource("tdcsuitebj", rightSum + air + hotel);
  18399. designer.SetDataSource("tdcsuitezbj", (rightSum + air + hotel) * result["头等舱SUITE"]);
  18400. allPrice += (rightSum + air + hotel) * result["头等舱SUITE"];
  18401. }
  18402. else
  18403. {
  18404. hideRowsList.Add(airRowIndex);
  18405. }
  18406. airRowIndex += 2;
  18407. if (result.Keys.Contains("经济舱JSES") && result["经济舱JSES"] > 0)
  18408. {
  18409. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  18410. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  18411. designer.SetDataSource("jjcjsesrs", result["经济舱JSES"]);
  18412. designer.SetDataSource("jjcjsesbj", rightSum + air + hotel);
  18413. designer.SetDataSource("jjcjseszbj", (rightSum + air + hotel) * result["经济舱JSES"]);
  18414. allPrice += (rightSum + air + hotel) * result["经济舱JSES"];
  18415. }
  18416. else
  18417. {
  18418. hideRowsList.Add(airRowIndex);
  18419. }
  18420. #endregion
  18421. designer.SetDataSource("AllPrice", "总金额:" + allPrice.ToString("#0.00"));
  18422. string savePaht = AppSettingsHelper.Get("ExcelBasePath") + "GroupCostQuotations/" + di.TeamName + "_详细报批费用.xls";
  18423. var ws = designer.Workbook.Worksheets[0];
  18424. foreach (var Rowindex in hideRowsList)
  18425. {
  18426. ws.Cells.HideRows(Rowindex, 2);
  18427. }
  18428. designer.Process();
  18429. designer.Workbook.Save(savePaht);
  18430. return Ok(JsonView(true, "生成成功!", new
  18431. {
  18432. Url = AppSettingsHelper.Get("ExcelBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("ExcelBasePath"), AppSettingsHelper.Get("ExcelFtpPath"))
  18433. }));
  18434. }
  18435. private void MatchRooms(ref Dictionary<string, int> hotelRooms, ref Dictionary<string, int> flights, string[] roomTypes, string flightType, ref Dictionary<string, int> result)
  18436. {
  18437. foreach (var roomType in roomTypes)
  18438. {
  18439. while (hotelRooms[roomType] > 0 && flights[flightType] > 0)
  18440. {
  18441. hotelRooms[roomType]--;
  18442. flights[flightType]--;
  18443. if (roomType == "TBR")
  18444. {
  18445. flights[flightType]--; // 双人间在减少1
  18446. }
  18447. string key = flightType + roomType;
  18448. if (result.Keys.Contains(key))
  18449. {
  18450. result[key]++;
  18451. }
  18452. else
  18453. {
  18454. result.Add(key, 1);
  18455. }
  18456. }
  18457. }
  18458. }
  18459. private class AirHotelPrice
  18460. {
  18461. public string Name { get; set; }
  18462. public decimal Price { get; set; }
  18463. public int Count { get; set; }
  18464. }
  18465. /// <summary>
  18466. /// 团组系数设置
  18467. /// </summary>
  18468. /// <param name="dto"></param>
  18469. /// <returns></returns>
  18470. [HttpPost]
  18471. public async Task<IActionResult> QueryGroupCostCoefficient(QueryGroupCostCoefficientDto dto)
  18472. {
  18473. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  18474. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  18475. if (di == null)
  18476. {
  18477. return Ok(JsonView(false, "团组不存在!"));
  18478. }
  18479. //var firstExpression = Expressionable.Create<Grp_GroupCostParameter>()
  18480. // .And(x => x.CostType == "A" && x.DiId == di.Id && x.IsDel == 0);
  18481. //var groupCostMainPrice = await _sqlSugar.Queryable<Grp_GroupCostParameter>().
  18482. // FirstAsync(firstExpression.ToExpression());
  18483. #region JSON
  18484. string hcpJson = @"
  18485. [
  18486. {
  18487. ""min"": 1,
  18488. ""max"": 500,
  18489. ""value"": 1.50
  18490. },
  18491. {
  18492. ""min"": 501,
  18493. ""max"": 1000,
  18494. ""value"": 1.40
  18495. },
  18496. {
  18497. ""min"": 1001,
  18498. ""max"": 2000,
  18499. ""value"": 1.35
  18500. }
  18501. ]";
  18502. #endregion
  18503. var hcpPriceRange = Newtonsoft.Json.JsonConvert.DeserializeObject<List<PriceRange>>(hcpJson);
  18504. List<(Predicate<decimal>, decimal)> hcpSwitchDictionary = hcpPriceRange
  18505. .Select(pr => (new Predicate<decimal>(x => x >= pr.Min && x <= pr.Max), pr.Value))
  18506. .ToList();
  18507. List<(Predicate<decimal>, List<(Predicate<decimal>, decimal)>)> jjcSwitchDictionary =
  18508. new List<(Predicate<decimal>, List<(Predicate<decimal>, decimal)>)>();
  18509. //jjcSwitchDictionary.Add((new Predicate<decimal>(x => x >= 1 && x <= 3),
  18510. // new List<(Predicate<decimal>, decimal)>()
  18511. // {
  18512. // (new Predicate<decimal>(y => y >= 1000 && y <= 3000), 2.6M),
  18513. // (new Predicate<decimal>(y => y > 3000), 2.5M)
  18514. // }
  18515. // ));
  18516. #region 签证系数
  18517. var visaXS = 0.00M;
  18518. switch (dto.VisaCB)
  18519. {
  18520. case decimal n when (n > 1 && n < 500):
  18521. switch (dto.VisaRS)
  18522. {
  18523. case 2 or 3:
  18524. visaXS = 1.35M;
  18525. break;
  18526. case 4 or 5:
  18527. visaXS = 1.30M;
  18528. break;
  18529. case 6 or 7:
  18530. visaXS = 1.25M;
  18531. break;
  18532. case 8 or 9 or 10:
  18533. visaXS = 1.20M;
  18534. break;
  18535. case > 10:
  18536. visaXS = 1.15M;
  18537. break;
  18538. default:
  18539. visaXS = 0.00M;
  18540. break;
  18541. }
  18542. break;
  18543. case decimal n when (n >= 500 && n < 1000):
  18544. switch (dto.VisaRS)
  18545. {
  18546. case 2 or 3 or 4:
  18547. visaXS = 1.30M;
  18548. break;
  18549. case 5 or 6 or 7 or 8:
  18550. visaXS = 1.25M;
  18551. break;
  18552. case 9 or 10:
  18553. visaXS = 1.20M;
  18554. break;
  18555. case > 10:
  18556. visaXS = 1.15M;
  18557. break;
  18558. default:
  18559. visaXS = 0.00M;
  18560. break;
  18561. }
  18562. break;
  18563. default:
  18564. switch (dto.VisaRS)
  18565. {
  18566. case 2 or 3 or 4:
  18567. visaXS = 1.30M;
  18568. break;
  18569. case 5 or 6 or 7 or 8:
  18570. visaXS = 1.25M;
  18571. break;
  18572. case 9 or 10:
  18573. visaXS = 1.20M;
  18574. break;
  18575. case > 10:
  18576. visaXS = 1.15M;
  18577. break;
  18578. default:
  18579. visaXS = 0.00M;
  18580. break;
  18581. }
  18582. break;
  18583. }
  18584. #endregion
  18585. #region 火车系数
  18586. var hcpXS = 0.00M;
  18587. foreach (var (condition, result) in hcpSwitchDictionary)
  18588. {
  18589. if (condition(dto.HCPCB))
  18590. {
  18591. hcpXS = result;
  18592. break;
  18593. }
  18594. }
  18595. #endregion
  18596. #region 机票系数
  18597. #region 经济舱系数
  18598. var jjcXS = 0.00M;
  18599. switch (dto.JJCCB)
  18600. {
  18601. case decimal x when (x >= 1000 && x <= 3000):
  18602. jjcXS = 2.6M;
  18603. break;
  18604. case decimal x when (x >= 3001 && x <= 8000):
  18605. jjcXS = 2.3M;
  18606. break;
  18607. case decimal x when (x >= 8001 && x <= 15000):
  18608. jjcXS = 2.1M;
  18609. break;
  18610. case decimal x when (x >= 15001 && x <= 30000):
  18611. jjcXS = 1.95M;
  18612. break;
  18613. case > 30000:
  18614. jjcXS = 1.8M;
  18615. break;
  18616. default:
  18617. break;
  18618. }
  18619. #endregion
  18620. #region 公务舱系数
  18621. var gwcXS = 0.00M;
  18622. switch (dto.GWCCB)
  18623. {
  18624. case decimal x when (x >= 1000 && x <= 3000):
  18625. gwcXS = 2.5M;
  18626. break;
  18627. case decimal x when (x >= 3001 && x <= 8000):
  18628. gwcXS = 2.2M;
  18629. break;
  18630. case decimal x when (x >= 8001 && x <= 15000):
  18631. gwcXS = 2.0M;
  18632. break;
  18633. case decimal x when (x >= 15001 && x <= 30000):
  18634. gwcXS = 1.85M;
  18635. break;
  18636. case > 30000:
  18637. gwcXS = 1.7M;
  18638. break;
  18639. default:
  18640. break;
  18641. }
  18642. #endregion
  18643. #region 头等舱系数
  18644. var tdcXS = 0.00M;
  18645. switch (dto.TDCCB)
  18646. {
  18647. case > 70000:
  18648. tdcXS = 1.5M;
  18649. break;
  18650. default:
  18651. tdcXS = 1.9M;
  18652. break;
  18653. }
  18654. #endregion
  18655. #endregion
  18656. #region 酒店系数
  18657. Dictionary<decimal, List<string>> dic = new Dictionary<decimal, List<string>>()
  18658. {
  18659. {1.6M, new List<string>(){"新西兰","澳大利亚" }},
  18660. {1.5M, new List<string>(){"越南社会主义共和国",
  18661. "老挝",
  18662. "柬埔寨",
  18663. "泰国",
  18664. "缅甸",
  18665. "马来西亚",
  18666. //"新加坡",
  18667. "文莱达鲁萨兰",
  18668. "印度尼西亚",
  18669. "东帝汶"}},
  18670. {1.2M, new List<string>(){ "日本","新加坡","法国","意大利","荷兰"}},
  18671. };
  18672. #region SGR
  18673. var sgrXS = 1.25M;
  18674. #endregion
  18675. #region TBR
  18676. var tbrXS = 1.25M;
  18677. #endregion
  18678. #region JSES
  18679. var jsesXS = 1.25M;
  18680. #endregion
  18681. #region SUITE
  18682. var suiteXS = 1.25M;
  18683. #endregion
  18684. var countryArr = di.VisitCountry.Split("|");
  18685. foreach (var item in dic)
  18686. {
  18687. var extsisCount = item.Value.Where(x => countryArr.Contains(x))
  18688. .Count();
  18689. if (extsisCount > 0)
  18690. {
  18691. jsesXS = item.Key;
  18692. sgrXS = item.Key;
  18693. tbrXS = item.Key;
  18694. suiteXS = item.Key;
  18695. }
  18696. }
  18697. #endregion
  18698. #region 地接系数
  18699. var djXS = 0.00M;
  18700. switch (dto.DJRS)
  18701. {
  18702. case 2 or 3:
  18703. djXS = 2.65M;
  18704. break;
  18705. case 4:
  18706. djXS = 2.6M;
  18707. break;
  18708. case 5 or 6:
  18709. djXS = 2.5M;
  18710. break;
  18711. case 7 or 8:
  18712. djXS = 2.4M;
  18713. break;
  18714. case 9 or 10:
  18715. djXS = 2.3M;
  18716. break;
  18717. case 11:
  18718. djXS = 2.2M;
  18719. break;
  18720. case 12:
  18721. djXS = 2.1M;
  18722. break;
  18723. case 13 or 14:
  18724. djXS = 2M;
  18725. break;
  18726. case 15:
  18727. djXS = 1.9M;
  18728. break;
  18729. case 16 or 17 or 18:
  18730. djXS = 1.8M;
  18731. break;
  18732. case 19 or 20:
  18733. djXS = 1.7M;
  18734. break;
  18735. }
  18736. #endregion
  18737. #region 零用金系数
  18738. var lyjXS = 0.00M;
  18739. switch (dto.LYJRS)
  18740. {
  18741. case 2:
  18742. lyjXS = 1.25M;
  18743. break;
  18744. case 3 or 4 or 5:
  18745. lyjXS = 1.2M;
  18746. break;
  18747. case int number when (number > 5 && number < 10):
  18748. lyjXS = 1.15M;
  18749. break;
  18750. case > 10:
  18751. lyjXS = 1.1M;
  18752. break;
  18753. default:
  18754. break;
  18755. }
  18756. #endregion
  18757. return Ok(JsonView(true, "查询成功", new ArrayList()
  18758. {
  18759. new { label = "火车票系数", value = hcpXS, key = "hcpXS" },
  18760. new { label = "经济舱系数", value = jjcXS, key = "jjcXS" },
  18761. new { label = "公务舱系数", value = gwcXS, key = "gwcXS" },
  18762. new { label = "头等舱系数", value = tdcXS, key = "tdcXS" },
  18763. new { label = "SGR系数", value = sgrXS, key = "sgrXS" },
  18764. new { label = "TBR系数", value = tbrXS, key = "tbrXS" },
  18765. new { label = "JSES系数", value = jsesXS, key = "jsesXS" },
  18766. new { label = "SUITE系数", value = suiteXS, key = "suiteXS" },
  18767. new { label = "地接系数", value = djXS, key = "djXS" },
  18768. new { label = "零用金系数", value = lyjXS, key = "lyjXS" },
  18769. new { label = "公务系数", value = 2M, key = "gwXS" }
  18770. }));
  18771. }
  18772. #endregion
  18773. #region 酒店预订 New 2023-12-28 17:45
  18774. /// <summary>
  18775. /// 酒店预订
  18776. /// 酒店费用列表 根据团组Id查询
  18777. /// </summary>
  18778. /// <param name="_dto"></param>
  18779. /// <returns></returns>
  18780. [HttpPost]
  18781. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18782. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  18783. {
  18784. #region 参数验证
  18785. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  18786. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  18787. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  18788. #region 团组操作权限验证 76 酒店预定模块
  18789. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18790. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  18791. #endregion
  18792. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18793. #region 页面操作权限验证
  18794. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18795. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  18796. #endregion
  18797. #endregion
  18798. return Ok(await _hotelPriceRep.ItemsByDiId(_dto.PortType, _dto.DiId));
  18799. }
  18800. /// <summary>
  18801. /// 酒店预订
  18802. /// 基础数据
  18803. /// </summary>
  18804. /// <param name="_dto"></param>
  18805. /// <returns></returns>
  18806. [HttpPost]
  18807. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18808. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  18809. {
  18810. #region 参数验证
  18811. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  18812. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  18813. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  18814. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18815. #region 页面操作权限验证
  18816. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18817. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  18818. #endregion
  18819. #region 团组操作权限验证 76 酒店预定模块
  18820. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18821. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  18822. #endregion
  18823. #endregion
  18824. return Ok(await _hotelPriceRep.BasicsDataInit(_dto.PortType, _dto.DiId));
  18825. }
  18826. /// <summary>
  18827. /// 酒店预订
  18828. /// 创建 入住卷号码
  18829. /// </summary>
  18830. /// <param name="_dto"></param>
  18831. /// <returns></returns>
  18832. [HttpPost]
  18833. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18834. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  18835. {
  18836. #region 参数验证
  18837. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  18838. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  18839. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  18840. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18841. #region 页面操作权限验证
  18842. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18843. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  18844. #endregion
  18845. #region 团组操作权限验证 76 酒店预定模块
  18846. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18847. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  18848. #endregion
  18849. #endregion
  18850. Result data = await _hotelPriceRep.CreateCheckVolumeNo(_dto.DiId);
  18851. if (data.Code != 0)
  18852. {
  18853. return Ok(JsonView(false, data.Msg));
  18854. }
  18855. return Ok(JsonView(true, data.Msg, data.Data));
  18856. }
  18857. /// <summary>
  18858. /// 酒店预订
  18859. /// 详情
  18860. /// </summary>
  18861. /// <param name="_dto"></param>
  18862. /// <returns></returns>
  18863. [HttpPost]
  18864. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18865. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  18866. {
  18867. #region 参数验证
  18868. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  18869. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  18870. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  18871. #region 团组操作权限验证 76 酒店预定模块
  18872. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18873. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  18874. #endregion
  18875. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18876. #region 页面操作权限验证
  18877. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18878. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  18879. #endregion
  18880. #endregion
  18881. return Ok(await _hotelPriceRep.Details(_dto.PortType, _dto.Id));
  18882. }
  18883. /// <summary>
  18884. /// 酒店预订
  18885. /// Add Or Edit
  18886. /// </summary>
  18887. /// <param name="_dto"></param>
  18888. /// <returns></returns>
  18889. [HttpPost]
  18890. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18891. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  18892. {
  18893. #region 参数验证
  18894. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  18895. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  18896. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  18897. #region 团组操作权限验证 76 酒店预定模块
  18898. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18899. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  18900. #endregion
  18901. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18902. #region 页面操作权限验证
  18903. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18904. if (_dto.Id == 0) // Add
  18905. {
  18906. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  18907. }
  18908. else if (_dto.Id > 1) // Edit
  18909. {
  18910. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  18911. }
  18912. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  18913. #endregion
  18914. #endregion
  18915. JsonView _view = await _hotelPriceRep.AddOrEdit(_dto);
  18916. if (_view.Code != 200)
  18917. {
  18918. return Ok(_view);
  18919. }
  18920. #region 成本无酒店价格数据进入超支
  18921. _sqlSugar.BeginTran();
  18922. var start_Bool = DateTime.TryParse(_dto.CheckInDate, out DateTime start_Time);
  18923. var end_Bool = DateTime.TryParse(_dto.CheckOutDate, out DateTime end_Time);
  18924. var groupCost = _sqlSugar.Queryable<Grp_GroupCost>().Where(x => x.Diid == _dto.DiId && x.IsDel == 0).ToList();
  18925. for (int i = 0; i < groupCost.Count; i++)
  18926. {
  18927. if (groupCost[i].Date.IsNullOrWhiteSpace() && i != 0)
  18928. {
  18929. groupCost[i].Date = groupCost[i - 1].Date;
  18930. }
  18931. }
  18932. var groupCost_Grp = groupCost.GroupBy(x => x.Date).ToList();
  18933. List<Fin_GroupExtraCostDto_OP> extraCostList = new
  18934. List<Fin_GroupExtraCostDto_OP>();
  18935. if (start_Bool && end_Bool)
  18936. {
  18937. while (start_Time < end_Time)
  18938. {
  18939. foreach (var item in groupCost_Grp)
  18940. {
  18941. if (DateTime.TryParse(item.Key, out DateTime cost_Time))
  18942. {
  18943. if (DateTime.Compare(start_Time, cost_Time) == 0 && item.Sum(x => x.SGR + x.Suite + x.TBR + x.JS_ES) == 0)
  18944. {
  18945. extraCostList.Add(new
  18946. Fin_GroupExtraCostDto_OP
  18947. {
  18948. Area = _dto.AreaId,
  18949. coefficient = 1.5M,
  18950. createUser = _dto.UserId,
  18951. currency = _dto.CardPriceCurrency,
  18952. diId = _dto.DiId,
  18953. ManagerConfirm = 0,
  18954. SupervisorConfirm = 0,
  18955. SYsupervisorConfirm = 0,
  18956. editType = 1,
  18957. PortType = 1,
  18958. price = _dto.CardPrice,
  18959. PriceCount = 1,
  18960. priceType = 1027,
  18961. priceDetailType = 1044,
  18962. PriceDt = start_Time.ToString("yyyy-MM-dd"),
  18963. priceName = $"酒店超支费用-酒店导入-({start_Time.ToString("yyyy/MM/dd")})",
  18964. });
  18965. }
  18966. }
  18967. }
  18968. start_Time = start_Time.AddDays(1);
  18969. }
  18970. }
  18971. if (extraCostList.Any())
  18972. {
  18973. await _carTouristGuideGroundRep.GroupExtraCost_OperatorList(extraCostList);
  18974. }
  18975. _sqlSugar.CommitTran();
  18976. #endregion
  18977. #region 应用推送
  18978. try
  18979. {
  18980. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  18981. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  18982. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  18983. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  18984. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  18985. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  18986. var diId = _dto.DiId;
  18987. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  18988. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  18989. #region 操作记录
  18990. var opInfo = new Crm_TableOperationRecord()
  18991. {
  18992. TableName = "Grp_HotelReservations",
  18993. PortType = _dto.PortType,
  18994. DataId = hotelId,
  18995. CreateUserId = _dto.UserId
  18996. };
  18997. //var opStatus = OperationEnum.NoOperation;
  18998. if (_dto.Id < 1) //添加操作
  18999. {
  19000. opInfo.OperationItem = OperationEnum.Add;
  19001. }
  19002. else if (_dto.Id > 0)
  19003. {
  19004. opInfo.OperationItem = OperationEnum.Edit;
  19005. }
  19006. string opRemark = string.Empty;
  19007. if (ccpInfo != null)
  19008. {
  19009. // USD 1211.86、 CNY 8761.75、汇率:7.2300
  19010. var currency = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.Id == ccpInfo.PaymentCurrency).First()?.Name;
  19011. var cnyPrice = ccpInfo.PayMoney * ccpInfo.DayRate;
  19012. opRemark = $"{currency} {ccpInfo.PayMoney.ToString("#0.00")}、CNY {cnyPrice.ToString("#0.00")}、汇率:{ccpInfo.DayRate.ToString("#0.0000")}";
  19013. }
  19014. opInfo.Remark = opRemark;
  19015. await _tableorRep.AddAsync(opInfo);
  19016. #endregion
  19017. _logger.LogInformation($"【iOS推送通知Exception】Begin");
  19018. //2024-10-21 新增LZ UID
  19019. var userIds = new List<int>() { 21 };
  19020. string title = $"费用审核";
  19021. string content = "";
  19022. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  19023. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  19024. try
  19025. {
  19026. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "76" };
  19027. await APNsTools.iOS_PushNotifications1("051", title, "", content, true, "ExpenseAuditWebView", h5);
  19028. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】Start");
  19029. //var iosRes = await APNsTools.iOS_PushNotifications("051", title, "", content);
  19030. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】End Response:[{JsonConvert.SerializeObject(iosRes)}]");
  19031. }
  19032. catch (Exception ex)
  19033. {
  19034. Logs($"【iOS推送通知-PostHotelReservationsAddOrEdit-Exception】[{ex.Message}]");
  19035. }
  19036. }
  19037. catch (Exception ex)
  19038. {
  19039. Logs($"【iOS推送通知Exception】【{ex.Message}】");
  19040. }
  19041. try
  19042. {
  19043. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  19044. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  19045. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  19046. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  19047. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  19048. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  19049. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  19050. //自动审核
  19051. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  19052. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  19053. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  19054. //2024-10-21 新增LZ UID
  19055. var userIds = new List<int>() { 21 };
  19056. string title = $"系统通知";
  19057. var diId = _dto.DiId;
  19058. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  19059. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  19060. string content = "";
  19061. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  19062. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  19063. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  19064. }
  19065. catch (Exception ex)
  19066. {
  19067. }
  19068. #endregion
  19069. return Ok(_view);
  19070. }
  19071. /// <summary>
  19072. /// 酒店自动审核测试
  19073. /// Add Or Edit
  19074. /// </summary>
  19075. /// <param name="diid"></param>
  19076. /// <param name="dataId"></param>
  19077. /// <returns></returns>
  19078. [HttpPost]
  19079. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19080. public async Task<IActionResult> PostHotelAutoAuditTest(int diid, int dataId)
  19081. {
  19082. #region 应用推送
  19083. try
  19084. {
  19085. //自动审核
  19086. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  19087. }
  19088. catch (Exception ex)
  19089. {
  19090. return Ok(JsonView(false, ex.Message));
  19091. }
  19092. #endregion
  19093. return Ok(JsonView(false, "操作成功"));
  19094. }
  19095. /// <summary>
  19096. /// 酒店预订
  19097. /// Del
  19098. /// </summary>
  19099. /// <param name="_dto"></param>
  19100. /// <returns></returns>
  19101. [HttpPost]
  19102. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19103. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  19104. {
  19105. #region 参数验证
  19106. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  19107. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  19108. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  19109. #region 团组操作权限验证 76 酒店预定模块
  19110. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  19111. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  19112. #endregion
  19113. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19114. #region 页面操作权限验证
  19115. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19116. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  19117. #endregion
  19118. #endregion
  19119. var data = await _hotelPriceRep.Del(_dto.Id, _dto.UserId);
  19120. #region 操作记录
  19121. await _tableorRep.AddAsync(new Crm_TableOperationRecord()
  19122. {
  19123. TableName = "Grp_HotelReservations",
  19124. PortType = _dto.PortType,
  19125. OperationItem = OperationEnum.Del,
  19126. DataId = _dto.Id,
  19127. CreateUserId = _dto.UserId
  19128. });
  19129. #endregion
  19130. return Ok(data);
  19131. }
  19132. /// <summary>
  19133. /// 酒店预订
  19134. /// 生成VOUCHER
  19135. /// 2024.05.06 之前版本
  19136. /// </summary>
  19137. /// <param name="_dto"></param>
  19138. /// <returns></returns>
  19139. [HttpPost]
  19140. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19141. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  19142. {
  19143. try
  19144. {
  19145. #region 参数验证
  19146. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  19147. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  19148. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  19149. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  19150. #region 团组操作权限验证 76 酒店预定模块
  19151. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  19152. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  19153. #endregion
  19154. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19155. #region 页面操作权限验证
  19156. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19157. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  19158. #endregion
  19159. #endregion
  19160. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  19161. //判断数据是否完整
  19162. if (hr != null)
  19163. {
  19164. if (!string.IsNullOrEmpty(hr.DetermineNo))
  19165. {
  19166. string strFileName = "HotelStatement/";
  19167. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  19168. if (dele != null)
  19169. strFileName += dele.TourCode;
  19170. //载入模板
  19171. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  19172. Document doc = new Document(sss);
  19173. DocumentBuilder builder = new DocumentBuilder(doc);
  19174. #region 替换Word模板书签内容
  19175. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  19176. //入住卷预定号码
  19177. if (doc.Range.Bookmarks["VNO"] != null)
  19178. {
  19179. Bookmark mark = doc.Range.Bookmarks["VNO"];
  19180. mark.Text = hr.CheckNumber;
  19181. }
  19182. //酒店时间
  19183. if (doc.Range.Bookmarks["Date"] != null)
  19184. {
  19185. Bookmark mark = doc.Range.Bookmarks["Date"];
  19186. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  19187. }
  19188. //团号
  19189. if (doc.Range.Bookmarks["TNo"] != null)
  19190. {
  19191. Bookmark mark = doc.Range.Bookmarks["TNo"];
  19192. mark.Text = dele.TourCode;
  19193. }
  19194. //预定号码
  19195. if (doc.Range.Bookmarks["BookingId"] != null)
  19196. {
  19197. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  19198. mark.Text = hr.ReservationsNo;
  19199. }
  19200. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  19201. {
  19202. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  19203. mark.Text = hr.DetermineNo;
  19204. }
  19205. //酒店城市
  19206. if (doc.Range.Bookmarks["City"] != null)
  19207. {
  19208. Bookmark mark = doc.Range.Bookmarks["City"];
  19209. mark.Text = hr.City;
  19210. }
  19211. //酒店名称
  19212. if (doc.Range.Bookmarks["HName"] != null)
  19213. {
  19214. Bookmark mark = doc.Range.Bookmarks["HName"];
  19215. mark.Text = hr.HotelName;
  19216. }
  19217. //酒店地址
  19218. if (doc.Range.Bookmarks["Address"] != null)
  19219. {
  19220. Bookmark mark = doc.Range.Bookmarks["Address"];
  19221. mark.Text = hr.HotelAddress;
  19222. }
  19223. //酒店电话
  19224. if (doc.Range.Bookmarks["Tel"] != null)
  19225. {
  19226. Bookmark mark = doc.Range.Bookmarks["Tel"];
  19227. mark.Text = hr.HotelTel;
  19228. }
  19229. //酒店传真
  19230. if (doc.Range.Bookmarks["Fax"] != null)
  19231. {
  19232. Bookmark mark = doc.Range.Bookmarks["Fax"];
  19233. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  19234. {
  19235. mark.Text = hr.HotelFax;
  19236. }
  19237. }
  19238. //入住时间
  19239. if (doc.Range.Bookmarks["CIn"] != null)
  19240. {
  19241. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  19242. Bookmark mark = doc.Range.Bookmarks["CIn"];
  19243. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  19244. }
  19245. //退房时间
  19246. if (doc.Range.Bookmarks["COut"] != null)
  19247. {
  19248. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  19249. Bookmark mark = doc.Range.Bookmarks["COut"];
  19250. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  19251. }
  19252. //客户名称
  19253. if (doc.Range.Bookmarks["GName"] != null)
  19254. {
  19255. string guestName = "";
  19256. string[] clients = Array.Empty<string>();
  19257. if (hr.GuestName.Contains(","))
  19258. {
  19259. clients = hr.GuestName.Split(",");
  19260. }
  19261. else
  19262. {
  19263. clients = new string[] { hr.GuestName };
  19264. }
  19265. List<int> clientIds_int = new List<int>();
  19266. if (clients.Length > 0)
  19267. {
  19268. foreach (var item in clients)
  19269. {
  19270. if (item.IsNumeric())
  19271. {
  19272. clientIds_int.Add(int.Parse(item));
  19273. }
  19274. }
  19275. }
  19276. if (clientIds_int.Count > 0)
  19277. {
  19278. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  19279. foreach (var client in _clientDatas)
  19280. {
  19281. //男
  19282. if (client.Sex == 0) guestName += $"Mr.";
  19283. //女
  19284. else if (client.Sex == 1) guestName += $"Ms.";
  19285. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  19286. {
  19287. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  19288. }
  19289. //guestName += $"{client.Pinyin},";
  19290. }
  19291. if (guestName.Length > 0)
  19292. {
  19293. guestName = guestName.Substring(0, guestName.Length - 1);
  19294. }
  19295. }
  19296. else
  19297. {
  19298. guestName = hr.GuestName;
  19299. }
  19300. Bookmark mark = doc.Range.Bookmarks["GName"];
  19301. mark.Text = guestName;
  19302. }
  19303. //房间介绍
  19304. if (doc.Range.Bookmarks["ROOM"] != null)
  19305. {
  19306. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  19307. mark.Text = hr.RoomExplanation;
  19308. }
  19309. //报价描述
  19310. if (doc.Range.Bookmarks["NOTE"] != null)
  19311. {
  19312. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  19313. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  19314. if (ss != null)
  19315. mark.Text = ss.Name;
  19316. }
  19317. //入住时间
  19318. if (doc.Range.Bookmarks["CheckIn"] != null)
  19319. {
  19320. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  19321. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  19322. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  19323. }
  19324. //退房时间
  19325. if (doc.Range.Bookmarks["CheckOut"] != null)
  19326. {
  19327. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  19328. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  19329. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  19330. }
  19331. //日期
  19332. if (doc.Range.Bookmarks["DT"] != null)
  19333. {
  19334. Bookmark mark = doc.Range.Bookmarks["DT"];
  19335. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  19336. }
  19337. //名称
  19338. if (doc.Range.Bookmarks["VName"] != null)
  19339. {
  19340. Bookmark mark = doc.Range.Bookmarks["VName"];
  19341. mark.Text = hr.HotelName;
  19342. }
  19343. //号码
  19344. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  19345. {
  19346. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  19347. mark.Text = hr.CheckNumber;
  19348. }
  19349. #endregion
  19350. strFileName += "VOUCHER.doc";
  19351. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  19352. doc.Save(fileDir);
  19353. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  19354. return Ok(JsonView(true, "操作成功!", Url));
  19355. }
  19356. else
  19357. {
  19358. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  19359. }
  19360. }
  19361. else
  19362. {
  19363. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  19364. }
  19365. }
  19366. catch (Exception ex)
  19367. {
  19368. return Ok(JsonView(false, ex.Message));
  19369. }
  19370. }
  19371. /// <summary>
  19372. /// 酒店预订
  19373. /// 生成VOUCHER
  19374. /// 2024.05.06 之后版本
  19375. /// </summary>
  19376. /// <param name="_dto"></param>
  19377. /// <returns></returns>
  19378. [HttpPost]
  19379. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19380. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  19381. {
  19382. #region 参数验证
  19383. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  19384. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  19385. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  19386. #region 团组操作权限验证 76 酒店预定模块
  19387. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  19388. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  19389. #endregion
  19390. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19391. #region 页面操作权限验证
  19392. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19393. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  19394. #endregion
  19395. #endregion
  19396. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  19397. //判断数据是否完整
  19398. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  19399. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  19400. string strFileName = "HotelStatement/";
  19401. string guestNames = ""; //格式Mr.xxx Ms.xxx
  19402. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  19403. #region 数据处理
  19404. List<int> guestIds = new List<int>();
  19405. //int index = 0;
  19406. foreach (var item in hrDtas)
  19407. {
  19408. if (item.GuestName.Contains(","))
  19409. {
  19410. string[] guestIdArr = item.GuestName.Split(',');
  19411. foreach (var guestIdStr in guestIdArr)
  19412. {
  19413. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  19414. if (guestBool)
  19415. {
  19416. guestIds.Add(guestId);
  19417. }
  19418. }
  19419. }
  19420. else guestNames += item.GuestName;
  19421. var voucherInfo = new HotelVoucherInfoView()
  19422. {
  19423. HotelName = item.HotelName,
  19424. CheckInDate = item.CheckInDate,
  19425. CheckOutDate = item.CheckOutDate,
  19426. ConfirmationNumber = item.DetermineNo.Trim(),
  19427. RoomType = item.RoomExplanation
  19428. };
  19429. vouchers.Add(voucherInfo);
  19430. }
  19431. if (guestIds.Count > 0)
  19432. {
  19433. guestIds = guestIds.Distinct().ToList();
  19434. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  19435. if (guestDatas.Count > 0)
  19436. {
  19437. guestNames = "";
  19438. foreach (var guest in guestDatas)
  19439. {
  19440. string guestName = "";
  19441. if (guest.Sex == 0) guestName += @"MR.";
  19442. else if (guest.Sex == 1) guestName += @"MS.";
  19443. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  19444. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  19445. guestNames += @$"{guestName.Trim()}、";
  19446. }
  19447. if (guestNames.Length > 0)
  19448. {
  19449. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  19450. }
  19451. }
  19452. }
  19453. #endregion
  19454. //载入模板
  19455. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  19456. Document doc = new Document(sss);
  19457. DocumentBuilder builder = new DocumentBuilder(doc);
  19458. if (doc.Range.Bookmarks["GuestName"] != null)
  19459. {
  19460. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  19461. mark.Text = guestNames;
  19462. }
  19463. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  19464. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  19465. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  19466. for (int i = 1; i <= vouchers.Count; i++)
  19467. {
  19468. HotelVoucherInfoView hviv = vouchers[i - 1];
  19469. builder.MoveToCell(0, i, 0, 0);
  19470. builder.Write(hviv.HotelName);
  19471. builder.MoveToCell(0, i, 1, 0);
  19472. builder.Write(hviv.CheckInDate);
  19473. builder.MoveToCell(0, i, 2, 0);
  19474. builder.Write(hviv.CheckOutDate);
  19475. builder.MoveToCell(0, i, 3, 0);
  19476. builder.Write(hviv.RoomType);
  19477. builder.MoveToCell(0, i, 4, 0);
  19478. builder.Write(hviv.ConfirmationNumber);
  19479. }
  19480. //删除多余行
  19481. int currRowIndex = vouchers.Count + 1;
  19482. int delRows = 21 - currRowIndex;
  19483. if (delRows > 0)
  19484. {
  19485. for (int i = 0; i < delRows; i++)
  19486. {
  19487. table.Rows.RemoveAt(currRowIndex);
  19488. //cultivateRowIndex++;
  19489. }
  19490. }
  19491. strFileName += "VOUCHER.docx";
  19492. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  19493. doc.Save(fileDir);
  19494. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  19495. return Ok(JsonView(true, "操作成功!", Url));
  19496. }
  19497. /// <summary>
  19498. /// 酒店预订
  19499. /// 生成VOUCHER 批量生成
  19500. /// New
  19501. /// </summary>
  19502. /// <param name="_dto"></param>
  19503. /// <returns></returns>
  19504. [HttpPost]
  19505. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19506. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  19507. {
  19508. #region 参数验证
  19509. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  19510. if (_dto.PageId < 1) _dto.PageId = 28;
  19511. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  19512. #region 团组操作权限验证 76 酒店预定模块
  19513. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  19514. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  19515. #endregion
  19516. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19517. #region 页面操作权限验证
  19518. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19519. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  19520. #endregion
  19521. #endregion
  19522. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  19523. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  19524. .OrderBy(x => x.CheckInDate)
  19525. .ToListAsync();
  19526. //判断数据是否完整
  19527. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  19528. string strFileName = "HotelStatement/";
  19529. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  19530. if (dele != null)
  19531. strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
  19532. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>()
  19533. .Select(x => new Crm_DeleClient { Id = x.Id, FirstName = x.FirstName, LastName = x.LastName, Pinyin = x.Pinyin })
  19534. .Where(it => it.IsDel == 0)
  19535. .ToListAsync();
  19536. foreach (var item in guestDatas) EncryptionProcessor.DecryptProperties(item);
  19537. for (int i = 0; i < hrDtas.Count; i++)
  19538. {
  19539. string guestNames = string.Empty;
  19540. List<int> guestIds = new List<int>();
  19541. var item = hrDtas[i];
  19542. //处理客户姓名
  19543. if (item.GuestName.Contains(","))
  19544. {
  19545. string[] guestIdArr = item.GuestName.Split(',');
  19546. foreach (var guestIdStr in guestIdArr)
  19547. if (int.TryParse(guestIdStr, out int guestId))
  19548. guestIds.Add(guestId);
  19549. }
  19550. else
  19551. {
  19552. bool guestIdBool = int.TryParse(item.GuestName, out int guestId);
  19553. if (guestIdBool)
  19554. {
  19555. guestIds.Add(guestId);
  19556. }
  19557. //NaN
  19558. if (item.GuestName.Contains("NaN"))
  19559. {
  19560. guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
  19561. }
  19562. }
  19563. if (guestIds.Count > 0)
  19564. {
  19565. guestIds = guestIds.Distinct().ToList();
  19566. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  19567. if (guestDatas1.Count > 0)
  19568. {
  19569. guestNames = "";
  19570. foreach (var guest in guestDatas1)
  19571. {
  19572. string guestName = "";
  19573. if (guest.Sex == 0) guestName += @"MR.";
  19574. else if (guest.Sex == 1) guestName += @"MS.";
  19575. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  19576. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  19577. guestNames += @$"{guestName.Trim()}、";
  19578. }
  19579. if (guestNames.Length > 0)
  19580. {
  19581. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  19582. }
  19583. }
  19584. }
  19585. //if (!string.IsNullOrEmpty(guestNames))
  19586. //{
  19587. hrDtas[i].GuestName = guestNames;
  19588. //}
  19589. }
  19590. strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  19591. Document doc = new Document();
  19592. DocumentBuilder builder = new DocumentBuilder(doc);
  19593. try
  19594. {
  19595. builder.MoveToDocumentStart();
  19596. foreach (var item in hrDtas)
  19597. {
  19598. //标题
  19599. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  19600. builder.ParagraphFormat.LineSpacing = 1;
  19601. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19602. builder.ParagraphFormat.Style.Font.Size = 9;
  19603. builder.ParagraphFormat.Style.Font.Bold = true;
  19604. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  19605. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  19606. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  19607. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  19608. builder.ParagraphFormat.LineSpacing = 1;
  19609. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19610. builder.ParagraphFormat.Style.Font.Size = 9;
  19611. builder.ParagraphFormat.Style.Font.Bold = true;
  19612. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  19613. builder.StartTable();
  19614. // 设置边框颜色
  19615. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  19616. //设置边框样式
  19617. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
  19618. //表格
  19619. #region 第一行
  19620. builder.InsertCell();
  19621. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19622. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19623. //builder.CellFormat.AllowAutoFit = false;
  19624. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19625. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19626. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19627. builder.CellFormat.WrapText = true; //自动换行
  19628. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  19629. builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
  19630. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19631. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19632. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19633. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19634. builder.Write("TOUR NO:");
  19635. builder.InsertCell();
  19636. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19637. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19638. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19639. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19640. builder.ParagraphFormat.Style.Font.Bold = false;
  19641. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19642. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  19643. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19644. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19645. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19646. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19647. builder.Write($"{dele?.TourCode ?? "-"}");
  19648. builder.InsertCell();
  19649. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19650. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19651. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19652. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19653. builder.ParagraphFormat.Style.Font.Bold = false;
  19654. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19655. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  19656. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19657. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19658. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19659. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19660. builder.Write($"CITY:");
  19661. builder.InsertCell();
  19662. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19663. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19664. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19665. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19666. builder.ParagraphFormat.Style.Font.Bold = false;
  19667. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19668. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  19669. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19670. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19671. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19672. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19673. builder.Write($"{item.City}");
  19674. builder.EndRow();
  19675. #endregion
  19676. #region 第二行
  19677. builder.InsertCell();
  19678. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19679. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19680. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19681. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19682. builder.ParagraphFormat.Style.Font.Bold = false;
  19683. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19684. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  19685. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19686. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19687. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19688. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19689. builder.Write("CONFIRMATION NO:");
  19690. builder.InsertCell();
  19691. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19692. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19693. builder.ParagraphFormat.Style.Font.Size = 8;
  19694. builder.ParagraphFormat.Style.Font.Bold = false;
  19695. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19696. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19697. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  19698. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19699. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19700. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19701. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19702. builder.CellFormat.HorizontalMerge = CellMerge.First;
  19703. builder.Write($"{item.DetermineNo}");
  19704. builder.InsertCell();
  19705. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19706. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  19707. builder.InsertCell();
  19708. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19709. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  19710. builder.EndRow();
  19711. #endregion
  19712. #region 第三行
  19713. builder.InsertCell();
  19714. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19715. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19716. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19717. builder.ParagraphFormat.Style.Font.Bold = false;
  19718. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19719. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19720. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  19721. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19722. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19723. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19724. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19725. builder.Write($"HOTEL NAME:");
  19726. builder.InsertCell();
  19727. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19728. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19729. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19730. builder.ParagraphFormat.Style.Font.Bold = false;
  19731. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19732. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19733. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  19734. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19735. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19736. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19737. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19738. builder.CellFormat.HorizontalMerge = CellMerge.First;
  19739. builder.Write($"{item.HotelName}");
  19740. builder.InsertCell();
  19741. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19742. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  19743. builder.InsertCell();
  19744. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19745. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  19746. builder.EndRow();
  19747. #endregion
  19748. #region 第四行
  19749. builder.InsertCell();
  19750. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19751. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19752. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19753. builder.ParagraphFormat.Style.Font.Bold = false;
  19754. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19755. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19756. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  19757. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19758. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19759. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19760. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19761. builder.Write($"HOTEL ADDRESS:");
  19762. builder.InsertCell();
  19763. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19764. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19765. builder.ParagraphFormat.Style.Font.Size = 8;
  19766. builder.ParagraphFormat.Style.Font.Bold = false;
  19767. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19768. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19769. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  19770. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19771. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19772. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19773. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19774. builder.CellFormat.HorizontalMerge = CellMerge.First;
  19775. builder.Write($"{item.HotelAddress}");
  19776. builder.InsertCell();
  19777. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19778. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  19779. builder.InsertCell();
  19780. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19781. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  19782. builder.EndRow();
  19783. #endregion
  19784. #region 第五行
  19785. builder.InsertCell();
  19786. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19787. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19788. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19789. builder.ParagraphFormat.Style.Font.Bold = false;
  19790. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19791. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19792. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  19793. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19794. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19795. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19796. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19797. builder.Write("TEL:");
  19798. builder.InsertCell();
  19799. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19800. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19801. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19802. builder.ParagraphFormat.Style.Font.Bold = false;
  19803. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19804. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19805. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  19806. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19807. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19808. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19809. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19810. builder.Write($"{item.HotelTel}");
  19811. builder.InsertCell();
  19812. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19813. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19814. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19815. builder.ParagraphFormat.Style.Font.Bold = false;
  19816. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19817. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19818. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  19819. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19820. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19821. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19822. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19823. builder.Write($"FAX:");
  19824. builder.InsertCell();
  19825. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19826. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19827. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19828. builder.ParagraphFormat.Style.Font.Bold = false;
  19829. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19830. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19831. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  19832. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19833. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19834. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19835. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19836. builder.Write($"{item.HotelFax}");
  19837. builder.EndRow();
  19838. #endregion
  19839. #region 第六行
  19840. builder.InsertCell();
  19841. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19842. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19843. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19844. builder.ParagraphFormat.Style.Font.Bold = false;
  19845. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19846. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19847. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  19848. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19849. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19850. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19851. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19852. builder.Write("CHECK IN:");
  19853. builder.InsertCell();
  19854. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19855. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19856. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19857. builder.ParagraphFormat.Style.Font.Bold = false;
  19858. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19859. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19860. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  19861. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19862. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19863. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19864. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19865. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  19866. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  19867. builder.Write($"{checkInStr}");
  19868. builder.InsertCell();
  19869. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19870. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19871. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19872. builder.ParagraphFormat.Style.Font.Bold = false;
  19873. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19874. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19875. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  19876. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19877. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19878. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19879. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19880. builder.Write($"CHECK OUT:");
  19881. builder.InsertCell();
  19882. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19883. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19884. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19885. builder.ParagraphFormat.Style.Font.Bold = false;
  19886. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19887. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19888. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  19889. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19890. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19891. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19892. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19893. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  19894. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  19895. builder.Write($"{checkOutStr}");
  19896. builder.EndRow();
  19897. #endregion
  19898. #region 第七行
  19899. builder.InsertCell();
  19900. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19901. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19902. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19903. builder.ParagraphFormat.Style.Font.Bold = false;
  19904. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19905. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19906. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  19907. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19908. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19909. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19910. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19911. builder.Write($"GUEST NAME:");
  19912. builder.InsertCell();
  19913. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19914. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19915. builder.ParagraphFormat.Style.Font.Size = 8;
  19916. builder.ParagraphFormat.Style.Font.Bold = false;
  19917. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19918. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19919. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  19920. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19921. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19922. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19923. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19924. builder.CellFormat.HorizontalMerge = CellMerge.First;
  19925. builder.Write($"{item.GuestName.Trim()}");
  19926. builder.InsertCell();
  19927. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19928. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  19929. builder.InsertCell();
  19930. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19931. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  19932. builder.EndRow();
  19933. #endregion
  19934. #region 第八行
  19935. builder.InsertCell();
  19936. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19937. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19938. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19939. builder.ParagraphFormat.Style.Font.Bold = false;
  19940. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19941. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19942. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  19943. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19944. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19945. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19946. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19947. builder.Write($"ROOM TYPE:");
  19948. builder.InsertCell();
  19949. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19950. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19951. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19952. builder.ParagraphFormat.Style.Font.Bold = false;
  19953. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19954. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19955. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  19956. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19957. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19958. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19959. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19960. builder.CellFormat.HorizontalMerge = CellMerge.First;
  19961. builder.Write($"{item.RoomExplanation}");
  19962. builder.InsertCell();
  19963. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19964. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  19965. builder.InsertCell();
  19966. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19967. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  19968. builder.EndRow();
  19969. #endregion
  19970. #region 第九行
  19971. builder.InsertCell();
  19972. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19973. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19974. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19975. builder.ParagraphFormat.Style.Font.Bold = false;
  19976. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19977. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19978. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  19979. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19980. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19981. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19982. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19983. builder.Write($"NOTE:");
  19984. builder.InsertCell();
  19985. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19986. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19987. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19988. builder.ParagraphFormat.Style.Font.Bold = false;
  19989. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19990. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19991. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  19992. builder.CellFormat.HorizontalMerge = CellMerge.First;
  19993. 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.");
  19994. builder.InsertCell();
  19995. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19996. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  19997. builder.InsertCell();
  19998. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19999. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  20000. builder.EndRow();
  20001. #endregion
  20002. builder.EndTable();
  20003. //换行
  20004. builder.Writeln("");
  20005. builder.Writeln("");
  20006. }
  20007. #region 获取文档中的所有表格 设置文字自适应
  20008. // 获取文档中的所有表格。
  20009. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  20010. {
  20011. // 遍历表格中的所有行。
  20012. foreach (Aspose.Words.Tables.Row row in table.Rows)
  20013. {
  20014. foreach (Cell cell in row.Cells)
  20015. {
  20016. Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
  20017. cellFormat.Width = 0;
  20018. }
  20019. }
  20020. }
  20021. #endregion
  20022. #region 设置页眉
  20023. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  20024. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  20025. if (System.IO.File.Exists(voucherHeaderPath))
  20026. {
  20027. byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
  20028. //Image image = Image.FromStream(imageBytes, ImageType.Png);
  20029. //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
  20030. Aspose.Words.Drawing.Shape shape = builder.InsertImage(imageBytes);
  20031. // 调整图片位置
  20032. shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
  20033. shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
  20034. shape.Top = 50; // 将图片距离页眉上边缘的距离
  20035. shape.Left = 0; // 将图片距离页面左边缘的距离
  20036. shape.Width = 81; // 设置图片宽度
  20037. shape.Height = 36; // 设置图片高度
  20038. }
  20039. //靠右
  20040. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  20041. //// 设置页脚上下边距
  20042. //builder.PageSetup.HeaderDistance = 42;
  20043. // 添加页眉线
  20044. Aspose.Words.Border borderHeader = null;
  20045. try
  20046. {
  20047. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  20048. }
  20049. catch (Exception e)
  20050. {
  20051. // TODO Auto-generated catch block
  20052. //e.printStackTrace();
  20053. }
  20054. borderHeader.Shadow = true;
  20055. borderHeader.DistanceFromText = 2;
  20056. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  20057. #endregion
  20058. }
  20059. catch (Exception ex)
  20060. {
  20061. }
  20062. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  20063. doc.Save(fileDir);
  20064. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  20065. return Ok(JsonView(true, "操作成功!", Url));
  20066. }
  20067. /// <summary>
  20068. /// 酒店预订
  20069. /// 生成 预定成本 Excel
  20070. /// </summary>
  20071. /// <param name="_dto"></param>
  20072. /// <returns></returns>
  20073. [HttpPost]
  20074. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20075. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  20076. {
  20077. #region 参数验证
  20078. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  20079. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  20080. if (!vadalitorRes.IsValid)
  20081. {
  20082. var errors = new StringBuilder();
  20083. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  20084. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  20085. }
  20086. #region 团组操作权限验证 76 酒店预定模块
  20087. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  20088. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  20089. #endregion
  20090. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20091. #region 页面操作权限验证
  20092. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20093. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  20094. #endregion
  20095. #endregion
  20096. decimal _rate = 1.00M;
  20097. string _currency = string.Empty;
  20098. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  20099. var hrDtas = _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  20100. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  20101. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  20102. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  20103. var _GroupCostParameter = _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).First();
  20104. //if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  20105. if (_GroupCostParameter == null)
  20106. {
  20107. //return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  20108. bool isIntType = int.TryParse(_currency, out int currId);
  20109. if (isIntType)
  20110. {
  20111. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  20112. }
  20113. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  20114. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  20115. if (currInfo == null)
  20116. {
  20117. //return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  20118. }
  20119. else _rate = currInfo.Rate;
  20120. if (!string.IsNullOrEmpty(_currency) && !_currency.ToUpper().Equals("CNY"))
  20121. {
  20122. _rate = _GroupCostParameter.Rate;
  20123. }
  20124. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  20125. //string strFileName = "HotelStatement/";
  20126. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  20127. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  20128. var rateDatas = new List<dynamic>();
  20129. #region 数据处理
  20130. foreach (var item in hrDtas)
  20131. {
  20132. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  20133. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  20134. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  20135. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  20136. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  20137. if (ccpInfo == null || roomInfo == null || breakfastInfo == null || governmentRentInfo == null || cityTaxInfo == null)
  20138. {
  20139. continue;
  20140. }
  20141. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  20142. if (string.IsNullOrEmpty(_currency)) _currency = $"CNY";
  20143. string singleRoomFeeStr = string.Empty,
  20144. doubleRoomFeeStr = string.Empty,
  20145. suiteRoomFeeStr = string.Empty,
  20146. otherRoomFeeStr = string.Empty,
  20147. payMoneyStr = string.Empty,
  20148. cardPriceStr = string.Empty;
  20149. if (roomCurr.Equals("CNY"))
  20150. {
  20151. rateDatas.Add(new { code = "CNY", rate = 1.0000 });
  20152. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  20153. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  20154. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  20155. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  20156. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? ""}";
  20157. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {currDatas.Find(it => it.Id == item.CardPriceCurrency)?.Name ?? ""}";
  20158. }
  20159. else
  20160. {
  20161. //singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  20162. //doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  20163. //suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  20164. //otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  20165. //payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  20166. //cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  20167. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  20168. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  20169. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  20170. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  20171. rateDatas.Add(new { code = roomCurr, rate = roomInfo.Rate });
  20172. var ccpPaymentCurrency = currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? "";
  20173. if (ccpPaymentCurrency.Equals("CNY"))
  20174. {
  20175. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} CNY";
  20176. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  20177. }
  20178. else
  20179. {
  20180. rateDatas.Add(new { code = ccpPaymentCurrency, rate = ccpInfo.DayRate });
  20181. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {ccpPaymentCurrency}\r\n{((ccpInfo.PayMoney * ccpInfo.DayRate) / _rate).ToString("#0.00")} CNY";
  20182. }
  20183. var hotelcardPriceCurrency = currDatas.Find(it => it.Id == item?.CardPriceCurrency)?.Name ?? "";
  20184. if (hotelcardPriceCurrency.Equals("CNY"))
  20185. {
  20186. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  20187. }
  20188. else
  20189. {
  20190. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {hotelcardPriceCurrency}\r\n{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} CNY";
  20191. }
  20192. }
  20193. string breakfastPriceStr = string.Empty,
  20194. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  20195. governmentRentStr = string.Empty,
  20196. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  20197. cityTaxStr = string.Empty,
  20198. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  20199. var breakfastCurrency1 = currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name;
  20200. if (!string.IsNullOrEmpty(breakfastCurrency1))
  20201. {
  20202. if (breakfastCurrency1.Equals("CNY"))
  20203. {
  20204. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  20205. }
  20206. else
  20207. {
  20208. rateDatas.Add(new { code = breakfastCurrency1, rate = breakfastInfo.Rate });
  20209. var breakfastPriceCny = breakfastInfo.Price * breakfastInfo.Rate;
  20210. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}\r\n{breakfastPriceCny.ToString("#0.00")} CNY";
  20211. }
  20212. }
  20213. else breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  20214. var governmentRentCurrency1 = currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name;
  20215. if (!string.IsNullOrEmpty(governmentRentCurrency1))
  20216. {
  20217. if (governmentRentCurrency.Equals("CNY"))
  20218. {
  20219. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  20220. }
  20221. else
  20222. {
  20223. rateDatas.Add(new { code = governmentRentCurrency1, rate = governmentRentInfo.Rate });
  20224. var governmentRentCny = governmentRentInfo.Price * governmentRentInfo.Rate;
  20225. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}\r\n{governmentRentCny.ToString("#0.00")} CNY";
  20226. }
  20227. }
  20228. else governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  20229. var cityTaxStrCurrency1 = currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name;
  20230. if (!string.IsNullOrEmpty(cityTaxStrCurrency1))
  20231. {
  20232. if (cityTaxStrCurrency1.Equals("CNY"))
  20233. {
  20234. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  20235. }
  20236. else
  20237. {
  20238. rateDatas.Add(new { code = cityTaxStrCurrency1, rate = cityTaxInfo.Rate });
  20239. var cityTaxCny = cityTaxInfo.Price * cityTaxInfo.Rate;
  20240. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}\r\n{cityTaxCny.ToString("#0.00")} CNY";
  20241. }
  20242. }
  20243. else cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  20244. int payDId = roomInfo?.PayDId ?? 0;
  20245. pcfds.Add(new HotelReservations_PCFD_View()
  20246. {
  20247. City = item.City,
  20248. HotelName = item.HotelName,
  20249. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  20250. // SingleRoomCount = item.SingleRoomCount,
  20251. SingleRoomPrice = singleRoomFeeStr,
  20252. // DoubleRoomCount = item.DoubleRoomCount,
  20253. DoubleRoomPrice = doubleRoomFeeStr,
  20254. //SuiteRoomCount = item.SuiteRoomCount,
  20255. SuiteRoomPrice = suiteRoomFeeStr,
  20256. OtherRoomPrice = otherRoomFeeStr,
  20257. //OtherRoomCount = item.OtherRoomCount,
  20258. BreakfastPrice = breakfastPriceStr,
  20259. GovernmentRent = governmentRentStr,
  20260. CityTax = cityTaxStr,
  20261. RoomExplanation = item.RoomExplanation,
  20262. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  20263. PayTime = roomInfo?.ConsumptionDate,
  20264. BankNo = roomInfo?.BankNo,
  20265. PayMoney = payMoneyStr,
  20266. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  20267. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  20268. CardPrice = cardPriceStr,
  20269. Remark = ccpInfo.Remark
  20270. });
  20271. }
  20272. #endregion
  20273. //载入模板
  20274. WorkbookDesigner designer = new WorkbookDesigner();
  20275. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  20276. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  20277. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  20278. designer.SetDataSource("TourNo", groupInfo.TourCode);
  20279. var rateDatas1 = rateDatas.Distinct();
  20280. var rateStr = string.Empty;
  20281. foreach (var item in rateDatas1)
  20282. {
  20283. rateStr += $"{item.code} {item.rate.ToString("#0.0000")} \t\t";
  20284. }
  20285. designer.SetDataSource("TeamName", $"酒店模块汇率:{rateStr}");
  20286. designer.SetDataSource("Opertor", userInfo.CnName);
  20287. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  20288. dt.TableName = "ViewMyHotelReservations";
  20289. designer.SetDataSource(dt);
  20290. designer.Process();
  20291. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  20292. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  20293. designer.Workbook.Save(serverPath);
  20294. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  20295. #region 删除指定行
  20296. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  20297. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  20298. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  20299. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  20300. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  20301. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  20302. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  20303. cssIndex = dt.Columns["CityTax"].Ordinal,
  20304. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  20305. remarkIndex = dt.Columns["Remark"].Ordinal;
  20306. //删除指定列
  20307. foreach (DataRow item in dt.Rows)
  20308. {
  20309. string singleStr = item["SingleRoomPrice"].ToString();
  20310. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  20311. if (containsDigitButNotZero1) singleDel = false;
  20312. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  20313. string doubleStr = item["DoubleRoomPrice"].ToString();
  20314. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  20315. if (containsDigitButNotZero2) doubleDel = false;
  20316. string suiteStr = item["SuiteRoomPrice"].ToString();
  20317. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  20318. if (containsDigitButNotZero3) suiteDel = false;
  20319. string otherStr = item["OtherRoomPrice"].ToString();
  20320. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  20321. if (containsDigitButNotZero4) otherDel = false;
  20322. string zcStr = item["BreakfastPrice"].ToString();
  20323. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  20324. if (containsDigitButNotZero5) zcDel = false;
  20325. string dsStr = item["GovernmentRent"].ToString();
  20326. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  20327. if (containsDigitButNotZero6) dsDel = false;
  20328. string cssStr = item["CityTax"].ToString();
  20329. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  20330. if (containsDigitButNotZero7) cssDel = false;
  20331. string cpStr = item["ConsumptionPatterns"].ToString();
  20332. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  20333. string remarkStr = item["Remark"].ToString();
  20334. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  20335. }
  20336. DeleteColumn(serverPath, remarkIndex, remarkDel);
  20337. DeleteColumn(serverPath, cpIndex, cpDel);
  20338. DeleteColumn(serverPath, dsIndex, dsDel);
  20339. DeleteColumn(serverPath, cssIndex, cssDel);
  20340. DeleteColumn(serverPath, zcIndex, zcDel);
  20341. DeleteColumn(serverPath, otherIndex, otherDel);
  20342. DeleteColumn(serverPath, suiteIndex, suiteDel);
  20343. DeleteColumn(serverPath, doubleIndex, doubleDel);
  20344. DeleteColumn(serverPath, singleIndex, singleDel);
  20345. #endregion
  20346. //只保留第一个表格
  20347. DeleteSheet(serverPath);
  20348. return Ok(JsonView(true, "操作成功", url = rst));
  20349. }
  20350. else
  20351. {
  20352. _currency = _GroupCostParameter.Currency;
  20353. bool isIntType = int.TryParse(_currency, out int currId);
  20354. if (isIntType)
  20355. {
  20356. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  20357. }
  20358. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  20359. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  20360. if (currInfo == null)
  20361. {
  20362. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  20363. }
  20364. if (!_currency.ToUpper().Equals("CNY"))
  20365. {
  20366. _rate = _GroupCostParameter.Rate;
  20367. }
  20368. _rate = currInfo.Rate;
  20369. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  20370. //string strFileName = "HotelStatement/";
  20371. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  20372. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  20373. #region 数据处理
  20374. foreach (var item in hrDtas)
  20375. {
  20376. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  20377. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  20378. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  20379. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  20380. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  20381. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  20382. string singleRoomFeeStr = string.Empty,
  20383. doubleRoomFeeStr = string.Empty,
  20384. suiteRoomFeeStr = string.Empty,
  20385. otherRoomFeeStr = string.Empty,
  20386. payMoneyStr = string.Empty,
  20387. cardPriceStr = string.Empty;
  20388. if (roomCurr.Equals(_currency))
  20389. {
  20390. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  20391. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  20392. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  20393. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  20394. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  20395. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  20396. }
  20397. else
  20398. {
  20399. singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  20400. doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  20401. suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  20402. otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  20403. payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  20404. cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  20405. }
  20406. string breakfastPriceStr = string.Empty,
  20407. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  20408. governmentRentStr = string.Empty,
  20409. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  20410. cityTaxStrStr = string.Empty,
  20411. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  20412. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  20413. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  20414. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  20415. int payDId = roomInfo?.PayDId ?? 0;
  20416. pcfds.Add(new HotelReservations_PCFD_View()
  20417. {
  20418. City = item.City,
  20419. HotelName = item.HotelName,
  20420. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  20421. // SingleRoomCount = item.SingleRoomCount,
  20422. SingleRoomPrice = singleRoomFeeStr,
  20423. // DoubleRoomCount = item.DoubleRoomCount,
  20424. DoubleRoomPrice = doubleRoomFeeStr,
  20425. //SuiteRoomCount = item.SuiteRoomCount,
  20426. SuiteRoomPrice = suiteRoomFeeStr,
  20427. OtherRoomPrice = otherRoomFeeStr,
  20428. //OtherRoomCount = item.OtherRoomCount,
  20429. BreakfastPrice = breakfastPriceStr,
  20430. GovernmentRent = governmentRentStr,
  20431. CityTax = cityTaxStrStr,
  20432. RoomExplanation = item.RoomExplanation,
  20433. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  20434. PayTime = roomInfo?.ConsumptionDate,
  20435. BankNo = roomInfo?.BankNo,
  20436. PayMoney = payMoneyStr,
  20437. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  20438. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  20439. CardPrice = cardPriceStr,
  20440. Remark = ccpInfo.Remark
  20441. });
  20442. }
  20443. #endregion
  20444. //载入模板
  20445. WorkbookDesigner designer = new WorkbookDesigner();
  20446. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  20447. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  20448. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  20449. designer.SetDataSource("TourNo", groupInfo.TourCode);
  20450. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  20451. designer.SetDataSource("Opertor", userInfo.CnName);
  20452. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  20453. dt.TableName = "ViewMyHotelReservations";
  20454. designer.SetDataSource(dt);
  20455. designer.Process();
  20456. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  20457. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  20458. designer.Workbook.Save(serverPath);
  20459. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  20460. #region 删除指定行
  20461. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  20462. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  20463. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  20464. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  20465. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  20466. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  20467. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  20468. cssIndex = dt.Columns["CityTax"].Ordinal,
  20469. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  20470. remarkIndex = dt.Columns["Remark"].Ordinal;
  20471. //删除指定列
  20472. foreach (DataRow item in dt.Rows)
  20473. {
  20474. string singleStr = item["SingleRoomPrice"].ToString();
  20475. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  20476. if (containsDigitButNotZero1) singleDel = false;
  20477. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  20478. string doubleStr = item["DoubleRoomPrice"].ToString();
  20479. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  20480. if (containsDigitButNotZero2) doubleDel = false;
  20481. string suiteStr = item["SuiteRoomPrice"].ToString();
  20482. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  20483. if (containsDigitButNotZero3) suiteDel = false;
  20484. string otherStr = item["OtherRoomPrice"].ToString();
  20485. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  20486. if (containsDigitButNotZero4) otherDel = false;
  20487. string zcStr = item["BreakfastPrice"].ToString();
  20488. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  20489. if (containsDigitButNotZero5) zcDel = false;
  20490. string dsStr = item["GovernmentRent"].ToString();
  20491. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  20492. if (containsDigitButNotZero6) dsDel = false;
  20493. string cssStr = item["CityTax"].ToString();
  20494. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  20495. if (containsDigitButNotZero7) cssDel = false;
  20496. string cpStr = item["ConsumptionPatterns"].ToString();
  20497. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  20498. string remarkStr = item["Remark"].ToString();
  20499. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  20500. }
  20501. DeleteColumn(serverPath, remarkIndex, remarkDel);
  20502. DeleteColumn(serverPath, cpIndex, cpDel);
  20503. DeleteColumn(serverPath, dsIndex, dsDel);
  20504. DeleteColumn(serverPath, cssIndex, cssDel);
  20505. DeleteColumn(serverPath, zcIndex, zcDel);
  20506. DeleteColumn(serverPath, otherIndex, otherDel);
  20507. DeleteColumn(serverPath, suiteIndex, suiteDel);
  20508. DeleteColumn(serverPath, doubleIndex, doubleDel);
  20509. DeleteColumn(serverPath, singleIndex, singleDel);
  20510. #endregion
  20511. //只保留第一个表格
  20512. DeleteSheet(serverPath);
  20513. return Ok(JsonView(true, "操作成功", url = rst));
  20514. }
  20515. //return Ok(JsonView(false));
  20516. }
  20517. /// <summary>
  20518. /// 删除指定列
  20519. /// </summary>
  20520. /// <param name="file"></param>
  20521. /// <param name="columnIndex"></param>
  20522. /// <param name="isDel"></param>
  20523. private void DeleteColumn(string file, int columnIndex, bool isDel)
  20524. {
  20525. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  20526. //wb.Save(file);
  20527. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  20528. if (sheet1 != null)
  20529. {
  20530. if (isDel)
  20531. {
  20532. Cells cells = sheet1.Cells;
  20533. cells.DeleteColumn(columnIndex);
  20534. }
  20535. }
  20536. wb.Save(file);
  20537. }
  20538. /// <summary>
  20539. /// 删除sheet
  20540. /// </summary>
  20541. /// <param name="file"></param>
  20542. private void DeleteSheet(string file)
  20543. {
  20544. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  20545. //wb.Save(file);
  20546. List<string> sheets = new List<string>();
  20547. foreach (var item in wb.Worksheets)
  20548. {
  20549. sheets.Add(item.Name);
  20550. }
  20551. if (sheets.Count > 0)
  20552. {
  20553. sheets.RemoveAt(0);//不删除第一个sheet
  20554. foreach (var item in sheets)
  20555. {
  20556. wb.Worksheets.RemoveAt(item);
  20557. }
  20558. }
  20559. wb.Save(file);
  20560. }
  20561. /// <summary>
  20562. /// 酒店预订
  20563. /// 确认单
  20564. /// </summary>
  20565. /// <param name="_dto"></param>
  20566. /// <returns></returns>
  20567. [HttpPost]
  20568. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20569. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  20570. {
  20571. try
  20572. {
  20573. #region 参数验证
  20574. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  20575. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  20576. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  20577. #region 团组操作权限验证 76 酒店预定模块
  20578. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  20579. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  20580. #endregion
  20581. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20582. #region 页面操作权限验证
  20583. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20584. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  20585. #endregion
  20586. #endregion
  20587. //团组信息
  20588. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  20589. //酒店数据
  20590. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  20591. if (listhoteldata.Count < 0)
  20592. {
  20593. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  20594. }
  20595. //利datatable存储
  20596. DataTable dt = new DataTable();
  20597. dt.Columns.Add("CheckInDate", typeof(string));
  20598. dt.Columns.Add("City", typeof(string));
  20599. dt.Columns.Add("Hotel", typeof(string));
  20600. dt.Columns.Add("Room", typeof(string));
  20601. for (int i = 0; i < listhoteldata.Count; i++)
  20602. {
  20603. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  20604. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  20605. while (dayStart < dayEnd)
  20606. {
  20607. string temp = "";
  20608. DataRow row = dt.NewRow();
  20609. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  20610. row["City"] = listhoteldata[i].City;
  20611. row["Hotel"] = listhoteldata[i].HotelName;
  20612. if (listhoteldata[i].SingleRoomCount > 0)
  20613. {
  20614. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  20615. }
  20616. if (listhoteldata[i].DoubleRoomCount > 0)
  20617. {
  20618. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  20619. }
  20620. if (listhoteldata[i].SuiteRoomCount > 0)
  20621. {
  20622. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  20623. }
  20624. if (listhoteldata[i].OtherRoomCount > 0)
  20625. {
  20626. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  20627. }
  20628. row["Room"] = temp;
  20629. dt.Rows.Add(row);
  20630. dayStart = dayStart.AddDays(1);
  20631. }
  20632. }
  20633. Dictionary<string, string> dic = new Dictionary<string, string>();
  20634. dic.Add("Dele", di.TeamName);
  20635. dic.Add("City", di.VisitCountry);
  20636. //模板路径
  20637. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  20638. //载入模板
  20639. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  20640. DocumentBuilder builder = new DocumentBuilder(doc);
  20641. foreach (var key in dic.Keys)
  20642. {
  20643. builder.MoveToBookmark(key);
  20644. builder.Write(dic[key]);
  20645. }
  20646. //获取word里所有表格
  20647. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  20648. //获取所填表格的序数
  20649. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  20650. var rowStart = tableOne.Rows[0]; //获取第1行
  20651. //循环赋值
  20652. for (int i = 0; i < dt.Rows.Count; i++)
  20653. {
  20654. builder.MoveToCell(0, i + 1, 0, 0);
  20655. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  20656. builder.MoveToCell(0, i + 1, 1, 0);
  20657. builder.Write(dt.Rows[i]["City"].ToString());
  20658. builder.MoveToCell(0, i + 1, 2, 0);
  20659. builder.Write(dt.Rows[i]["Hotel"].ToString());
  20660. builder.MoveToCell(0, i + 1, 3, 0);
  20661. builder.Write(dt.Rows[i]["Room"].ToString());
  20662. }
  20663. //删除多余行
  20664. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  20665. {
  20666. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  20667. }
  20668. string strFileName = di.TeamName + "酒店确认单.doc";
  20669. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  20670. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  20671. return Ok(JsonView(true, "成功", url));
  20672. }
  20673. catch (Exception ex)
  20674. {
  20675. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  20676. }
  20677. }
  20678. #endregion
  20679. #region 团组状态
  20680. /// <summary>
  20681. /// 团组状态列表 Page
  20682. /// </summary>
  20683. /// <param name="dto">团组列表请求dto</param>
  20684. /// <returns></returns>
  20685. [HttpPost]
  20686. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20687. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  20688. {
  20689. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  20690. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  20691. {
  20692. string sqlWhere = string.Empty;
  20693. if (dto.IsSure == 0) //未完成
  20694. {
  20695. sqlWhere += string.Format(@" And IsSure = 0");
  20696. }
  20697. else if (dto.IsSure == 1) //已完成
  20698. {
  20699. sqlWhere += string.Format(@" And IsSure = 1");
  20700. }
  20701. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  20702. {
  20703. string tj = dto.SearchCriteria;
  20704. 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}%')",
  20705. tj, tj, tj, tj, tj);
  20706. }
  20707. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  20708. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  20709. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  20710. From (
  20711. Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
  20712. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  20713. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  20714. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  20715. From Grp_DelegationInfo gdi
  20716. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  20717. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  20718. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  20719. Where gdi.IsDel = 0 {0}
  20720. ) temp ", sqlWhere);
  20721. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  20722. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  20723. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  20724. }
  20725. else
  20726. {
  20727. return Ok(JsonView(false, "查询失败"));
  20728. }
  20729. }
  20730. /// <summary>
  20731. /// 团组状态
  20732. /// 设置操作完成
  20733. /// </summary>
  20734. /// <param name="dto">团组列表请求dto</param>
  20735. /// <returns></returns>
  20736. [HttpPost]
  20737. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20738. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  20739. {
  20740. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  20741. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  20742. {
  20743. Id = dto.Id,
  20744. IsSure = 1
  20745. };
  20746. var result = await _sqlSugar.Updateable(_DelegationInfo)
  20747. .UpdateColumns(it => new { it.IsSure })
  20748. .WhereColumns(it => new { it.Id })
  20749. .ExecuteCommandAsync();
  20750. if (result > 0)
  20751. {
  20752. return Ok(JsonView(true, "操作完成!"));
  20753. }
  20754. return Ok(JsonView(false, "操作失败!"));
  20755. }
  20756. #endregion
  20757. #region 保险费用录入
  20758. /// <summary>
  20759. /// 根据团组Id查询保险费用列表
  20760. /// </summary>
  20761. /// <param name="dto"></param>
  20762. /// <returns></returns>
  20763. [HttpPost]
  20764. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20765. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  20766. {
  20767. Result groupData = await _customersRep.CustomersByDiId(dto);
  20768. if (groupData.Code != 0)
  20769. {
  20770. return Ok(JsonView(false, groupData.Msg));
  20771. }
  20772. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  20773. }
  20774. /// <summary>
  20775. /// 根据保险费用Id查询保险费用详细
  20776. /// </summary>
  20777. /// <param name="dto"></param>
  20778. /// <returns></returns>
  20779. [HttpPost]
  20780. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20781. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  20782. {
  20783. try
  20784. {
  20785. Result groupData = await _customersRep.CustomersById(dto);
  20786. if (groupData.Code != 0)
  20787. {
  20788. return Ok(JsonView(false, groupData.Msg));
  20789. }
  20790. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  20791. }
  20792. catch (Exception ex)
  20793. {
  20794. return Ok(JsonView(false, ex.Message));
  20795. }
  20796. }
  20797. /// <summary>
  20798. /// 保险费用录入页面初始化绑定
  20799. /// </summary>
  20800. /// <param name="dto"></param>
  20801. /// <returns></returns>
  20802. [HttpPost]
  20803. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20804. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  20805. {
  20806. try
  20807. {
  20808. Result groupData = await _customersRep.CustomersInitialize(dto);
  20809. if (groupData.Code != 0)
  20810. {
  20811. return Ok(JsonView(false, groupData.Msg));
  20812. }
  20813. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  20814. }
  20815. catch (Exception ex)
  20816. {
  20817. return Ok(JsonView(false, ex.Message));
  20818. }
  20819. }
  20820. /// <summary>
  20821. /// 保险费用操作(Status:1.新增,2.修改)
  20822. /// </summary>
  20823. /// <param name="dto"></param>
  20824. /// <returns></returns>
  20825. [HttpPost]
  20826. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20827. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  20828. {
  20829. Result groupData = await _customersRep.OpCustomers(dto);
  20830. if (groupData.Code != 0)
  20831. {
  20832. return Ok(JsonView(false, groupData.Msg));
  20833. }
  20834. #region 应用推送
  20835. try
  20836. {
  20837. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  20838. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  20839. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  20840. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  20841. //自动审核
  20842. await _feeAuditRep.FeeAutomaticAudit(4, dto.DiId, dataId);
  20843. //2024-10-21 新增LZ UID
  20844. var userIds = new List<int>() { 21 };
  20845. string title = $"系统通知";
  20846. var diId = dto.DiId;
  20847. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  20848. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  20849. string content = "";
  20850. if (dto.Status == 1) content = $"[新增-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  20851. else if (dto.Status == 2) content = $"[更新-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  20852. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  20853. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "82" };
  20854. await APNsTools.iOS_PushNotifications1("051", "保险费用审核", "", content, true, "ExpenseAuditWebView", h5);
  20855. }
  20856. catch (Exception ex)
  20857. {
  20858. }
  20859. #endregion
  20860. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  20861. }
  20862. /// <summary>
  20863. /// 保险文件上传
  20864. /// </summary>
  20865. /// <param name="file"></param>
  20866. /// <returns></returns>
  20867. [HttpPost]
  20868. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20869. public async Task<IActionResult> UploadCus(IFormFile file)
  20870. {
  20871. try
  20872. {
  20873. if (file != null)
  20874. {
  20875. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  20876. //文件名称
  20877. string projectFileName = file.FileName;
  20878. //上传的文件的路径
  20879. string filePath = "";
  20880. if (!Directory.Exists(fileDir))
  20881. {
  20882. Directory.CreateDirectory(fileDir);
  20883. }
  20884. //上传的文件的路径
  20885. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  20886. using (FileStream fs = System.IO.File.Create(filePath))
  20887. {
  20888. file.CopyTo(fs);
  20889. fs.Flush();
  20890. }
  20891. return Ok(JsonView(true, "上传成功!", projectFileName));
  20892. }
  20893. else
  20894. {
  20895. return Ok(JsonView(false, "上传失败!"));
  20896. }
  20897. }
  20898. catch (Exception ex)
  20899. {
  20900. return Ok(JsonView(false, ex.Message));
  20901. }
  20902. }
  20903. /// <summary>
  20904. /// 保险删除指定文件
  20905. /// </summary>
  20906. /// <param name="dto"></param>
  20907. /// <returns></returns>
  20908. [HttpPost]
  20909. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20910. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  20911. {
  20912. try
  20913. {
  20914. string filePath = "";
  20915. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  20916. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  20917. //int id = 0;
  20918. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  20919. // 删除该文件
  20920. try
  20921. {
  20922. System.IO.File.Delete(filePath);
  20923. 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()
  20924. {
  20925. Attachment = "",
  20926. }).ExecuteCommandAsync();
  20927. if (result != 0)
  20928. {
  20929. return Ok(JsonView(true, "成功!"));
  20930. }
  20931. else
  20932. {
  20933. return Ok(JsonView(false, "失败!"));
  20934. }
  20935. }
  20936. catch (Exception)
  20937. {
  20938. 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()
  20939. {
  20940. Attachment = "",
  20941. }).ExecuteCommandAsync();
  20942. if (result != 0)
  20943. {
  20944. return Ok(JsonView(true, "成功!"));
  20945. }
  20946. else
  20947. {
  20948. return Ok(JsonView(false, "失败!"));
  20949. }
  20950. }
  20951. }
  20952. catch (Exception ex)
  20953. {
  20954. return Ok(JsonView(false, "程序错误!"));
  20955. throw;
  20956. }
  20957. }
  20958. /// <summary>
  20959. /// 保险费用操作(删除)
  20960. /// </summary>
  20961. /// <param name="dto"></param>
  20962. /// <returns></returns>
  20963. [HttpPost]
  20964. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20965. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  20966. {
  20967. try
  20968. {
  20969. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  20970. if (!res)
  20971. {
  20972. return Ok(JsonView(false, "删除失败"));
  20973. }
  20974. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  20975. {
  20976. IsDel = 1,
  20977. DeleteUserId = dto.DeleteUserId,
  20978. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  20979. }).ExecuteCommandAsync();
  20980. return Ok(JsonView(true, "删除成功!"));
  20981. }
  20982. catch (Exception ex)
  20983. {
  20984. return Ok(JsonView(false, "程序错误!"));
  20985. throw;
  20986. }
  20987. }
  20988. #endregion
  20989. #region 接团客户名单 PageId 104
  20990. /// <summary>
  20991. /// 接团客户名单
  20992. /// 迁移数据(慎用!)
  20993. /// </summary>
  20994. /// <returns></returns>
  20995. [HttpPost]
  20996. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20997. public async Task<IActionResult> PostTourClientListChange()
  20998. {
  20999. try
  21000. {
  21001. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  21002. //var groupClinetData1
  21003. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  21004. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  21005. int updateCount = 0;
  21006. if (oldOAClientList.Count > 0)
  21007. {
  21008. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  21009. _sqlSugar.BeginTran();
  21010. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  21011. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  21012. foreach (var item in oldOAClientList)
  21013. {
  21014. int comId = 0;
  21015. string format = "yyyy-MM-dd HH:mm:ss";
  21016. string data11 = "1990-01-01 00:00";
  21017. var data1 = IsValidDate(item.OPdate, format);
  21018. if (data1) data11 = item.OPdate;
  21019. //客户公司验证
  21020. if (!string.IsNullOrEmpty(item.Company))
  21021. {
  21022. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  21023. if (clientComInfo == null) // add
  21024. {
  21025. var addInfo = new Crm_CustomerCompany()
  21026. {
  21027. CompanyAbbreviation = "",
  21028. CompanyFullName = item.Company,
  21029. Address = "",
  21030. PostCodes = "",
  21031. LastedOpUserId = item.OPer,
  21032. LastedOpDt = Convert.ToDateTime(data11),
  21033. CreateUserId = item.OPer,
  21034. CreateTime = Convert.ToDateTime(data11),
  21035. IsDel = 0
  21036. };
  21037. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  21038. if (comId1 > 0) comId = comId1;
  21039. }
  21040. else comId = clientComInfo.Id;
  21041. }
  21042. //客户人员验证
  21043. int clientId = 0;
  21044. string name = item.LastName + item.Name;
  21045. if (!string.IsNullOrEmpty(name))
  21046. {
  21047. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  21048. if (clientInfo == null)
  21049. {
  21050. DateTime? dateTime = null;
  21051. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  21052. if (isDt) dateTime = birthDayDt;
  21053. var addInfo1 = new Crm_DeleClient()
  21054. {
  21055. CrmCompanyId = comId,
  21056. DiId = -1,
  21057. LastName = item.LastName,
  21058. FirstName = item.Name,
  21059. OldName = "",
  21060. Pinyin = item.Pinyin,
  21061. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  21062. Marriage = 0,
  21063. Phone = item.Phone,
  21064. Job = item.Job,
  21065. BirthDay = dateTime
  21066. };
  21067. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  21068. if (clientId1 > 0) clientId = clientId1;
  21069. }
  21070. else clientId = clientInfo.Id;
  21071. }
  21072. if (clientId < 1)
  21073. {
  21074. continue;
  21075. }
  21076. int airType = 0;
  21077. if (item.AirType == "超经舱") airType = 459;
  21078. else if (item.AirType == "公务舱") airType = 458;
  21079. else if (item.AirType == "经济舱") airType = 460;
  21080. else if (item.AirType == "其他") airType = 565;
  21081. else if (item.AirType == "头等舱") airType = 457;
  21082. var _TourClientListEntity = new Grp_TourClientList()
  21083. {
  21084. DiId = item.Diid,
  21085. ClientId = clientId,
  21086. CreateUserId = item.OPer,
  21087. CreateTime = Convert.ToDateTime(data11),
  21088. Remark = item.Remark,
  21089. IsDel = item.Isdel,
  21090. ShippingSpaceTypeId = airType,
  21091. ShippingSpaceSpecialNeeds = item.AirRemark,
  21092. HotelSpecialNeeds = item.RoomType
  21093. };
  21094. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  21095. if (_TourClientList > 0)
  21096. {
  21097. updateCount++;
  21098. }
  21099. }
  21100. _sqlSugar.CommitTran();
  21101. }
  21102. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  21103. }
  21104. catch (Exception ex)
  21105. {
  21106. _sqlSugar.RollbackTran();
  21107. return Ok(JsonView(false, ex.Message));
  21108. }
  21109. //return Ok(JsonView(true));
  21110. }
  21111. private bool IsValidDate(string dateString, string format)
  21112. {
  21113. return DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime dateValue);
  21114. }
  21115. /// <summary>
  21116. /// 接团客户名单
  21117. /// 根据团组Id查询List
  21118. /// </summary>
  21119. /// <param name="_dto"></param>
  21120. /// <returns></returns>
  21121. [HttpPost]
  21122. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21123. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  21124. {
  21125. #region 参数验证
  21126. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  21127. if (_dto.PageId != 104) _dto.PageId = 104; //接团客户名单PageId
  21128. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  21129. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  21130. #region 页面操作权限验证
  21131. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  21132. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  21133. #endregion
  21134. #endregion
  21135. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  21136. if (viewData.Code != 0)
  21137. {
  21138. return Ok(JsonView(false, viewData.Msg));
  21139. }
  21140. return Ok(JsonView(viewData.Data));
  21141. }
  21142. /// <summary>
  21143. /// 接团客户名单
  21144. /// 基础数据 Init
  21145. /// </summary>
  21146. /// <param name="_dto"></param>
  21147. /// <returns></returns>
  21148. [HttpPost]
  21149. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21150. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  21151. {
  21152. #region 参数验证
  21153. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  21154. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  21155. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  21156. #region 页面操作权限验证
  21157. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  21158. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  21159. #endregion
  21160. #endregion
  21161. return Ok(await _tourClientListRep._BasicDataInit(_dto.PortType));
  21162. }
  21163. /// <summary>
  21164. /// 接团客户名单
  21165. /// 根据 Id查询 Details
  21166. /// </summary>
  21167. /// <param name="_dto"></param>
  21168. /// <returns></returns>
  21169. [HttpPost]
  21170. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21171. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  21172. {
  21173. #region 参数验证
  21174. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  21175. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  21176. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  21177. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  21178. #region 页面操作权限验证
  21179. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  21180. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  21181. #endregion
  21182. #endregion
  21183. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  21184. if (viewData.Code != 0)
  21185. {
  21186. return Ok(JsonView(false, viewData.Msg));
  21187. }
  21188. return Ok(JsonView(viewData.Data));
  21189. }
  21190. /// <summary>
  21191. /// 接团客户名单
  21192. /// Add Or Edit
  21193. /// </summary>
  21194. /// <param name="_dto"></param>
  21195. /// <returns></returns>
  21196. [HttpPost]
  21197. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21198. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  21199. {
  21200. #region 参数验证
  21201. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  21202. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  21203. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  21204. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  21205. #region 页面操作权限验证
  21206. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  21207. if (_dto.Id == 0) //添加
  21208. {
  21209. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  21210. }
  21211. else if (_dto.Id >= 0) //修改
  21212. {
  21213. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  21214. }
  21215. #endregion
  21216. #endregion
  21217. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  21218. if (viewData.Code != 0)
  21219. {
  21220. return Ok(JsonView(false, viewData.Msg));
  21221. }
  21222. return Ok(JsonView(true));
  21223. }
  21224. /// <summary>
  21225. /// 接团客户名单
  21226. /// json字符串 AddMultiple(添加多个)
  21227. /// </summary>
  21228. /// <param name="_dto"></param>
  21229. /// <returns></returns>
  21230. [HttpPost]
  21231. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21232. public async Task<IActionResult> PostTourClientListJsonFormatAddMultiple(PostTourClientListJsonFormatAddMultipleDto _dto)
  21233. {
  21234. #region 参数验证
  21235. string jsonLabel = _dto.JsonLabel;
  21236. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  21237. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  21238. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  21239. #region 页面操作权限验证
  21240. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  21241. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  21242. #endregion
  21243. #endregion
  21244. var request = new TourClientListAddMultipleDto();
  21245. request.DiId = _dto.DiId;
  21246. request.UserId = _dto.UserId;
  21247. if (!CommonFun.IsValidJson(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数不是合法的json格式!"));
  21248. if (string.IsNullOrEmpty(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数值不能为空"));
  21249. List<TourClientListInfoCN> datas = JsonConvert.DeserializeObject<List<TourClientListInfoCN>>(jsonLabel);
  21250. if (!datas.Any()) return Ok(JsonView(false, "JsonLabel参数值不能为空!"));
  21251. var infos = new List<TourClientListInfo>();
  21252. foreach (var data in datas)
  21253. {
  21254. (string lastName, string firstName) = CommonFun.GetLastNameAndFirstName(data.Name);
  21255. string lastNameEn = CommonFun.ConvertToPinyin(lastName),
  21256. firstNameEn = CommonFun.ConvertToPinyin(lastName);
  21257. if (string.IsNullOrEmpty(lastNameEn) || string.IsNullOrEmpty(firstNameEn))
  21258. {
  21259. continue;
  21260. }
  21261. infos.Add(new TourClientListInfo()
  21262. {
  21263. IsAccompany = 1,
  21264. LastName = lastName,
  21265. FirstName = firstName,
  21266. Pinyin = lastNameEn + @"/" + firstNameEn,
  21267. Sex = data.Sex.Equals("男") ? 0 : data.Sex.Equals("女") ? 1 : 2,
  21268. CompanyFullName = data.CompanyFullName,
  21269. Job = data.Job
  21270. });
  21271. }
  21272. if (infos.Any())
  21273. {
  21274. var viewData = await _tourClientListRep._AddMultiple(request);
  21275. if (viewData.Code != 0)
  21276. {
  21277. return Ok(JsonView(false, viewData.Msg));
  21278. }
  21279. return Ok(JsonView(true));
  21280. }
  21281. return Ok(JsonView(false));
  21282. }
  21283. /// <summary>
  21284. /// 接团客户名单
  21285. /// AddMultiple(添加多个)
  21286. /// </summary>
  21287. /// <param name="_dto"></param>
  21288. /// <returns></returns>
  21289. [HttpPost]
  21290. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21291. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  21292. {
  21293. #region 参数验证
  21294. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  21295. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  21296. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  21297. #region 页面操作权限验证
  21298. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  21299. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  21300. #endregion
  21301. #endregion
  21302. var viewData = await _tourClientListRep._AddMultiple(_dto);
  21303. if (viewData.Code != 0)
  21304. {
  21305. return Ok(JsonView(false, viewData.Msg));
  21306. }
  21307. return Ok(JsonView(true));
  21308. }
  21309. /// <summary>
  21310. /// 接团客户名单
  21311. /// Del
  21312. /// </summary>
  21313. /// <param name="_dto"></param>
  21314. /// <returns></returns>
  21315. [HttpPost]
  21316. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21317. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  21318. {
  21319. #region 参数验证
  21320. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  21321. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  21322. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  21323. #region 页面操作权限验证
  21324. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  21325. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  21326. #endregion
  21327. #endregion
  21328. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  21329. if (viewData.Code != 0)
  21330. {
  21331. return Ok(JsonView(false, viewData.Msg));
  21332. }
  21333. return Ok(JsonView(true));
  21334. }
  21335. /// <summary>
  21336. /// 接团客户名单
  21337. /// 文件下载 客户名单
  21338. /// </summary>
  21339. /// <param name="_dto"></param>
  21340. /// <returns></returns>
  21341. [HttpPost]
  21342. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21343. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  21344. {
  21345. #region 参数验证
  21346. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  21347. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  21348. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  21349. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  21350. #region 页面操作权限验证
  21351. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  21352. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  21353. #endregion
  21354. #endregion
  21355. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  21356. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  21357. From Grp_TourClientList tcl
  21358. Left Join
  21359. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  21360. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  21361. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  21362. From Crm_DeleClient dc
  21363. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  21364. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  21365. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  21366. Where dc.IsDel = 0) temp
  21367. On temp.DcId =tcl.ClientId
  21368. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  21369. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  21370. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  21371. //载入模板
  21372. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  21373. if (_dto.Language == 1)
  21374. {
  21375. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  21376. }
  21377. //载入模板
  21378. var doc = new Document(tempPath);
  21379. DocumentBuilder builder = new DocumentBuilder(doc);
  21380. //获取word里所有表格
  21381. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  21382. //获取所填表格的序数
  21383. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  21384. var rowStart = tableOne.Rows[0]; //获取第1行
  21385. if (_dto.Language == 0)
  21386. {
  21387. //循环赋值
  21388. for (int i = 0; i < DcList.Count; i++)
  21389. {
  21390. EncryptionProcessor.DecryptProperties(DcList[i]);
  21391. builder.MoveToCell(0, i + 1, 0, 0);
  21392. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  21393. builder.MoveToCell(0, i + 1, 1, 0);
  21394. int sex = DcList[i].Sex;
  21395. string sexStr = string.Empty;
  21396. if (sex == 0) sexStr = "男";
  21397. else if (sex == 1) sexStr = "女";
  21398. else sexStr = "未设置";
  21399. builder.Write(sexStr);
  21400. builder.MoveToCell(0, i + 1, 2, 0);
  21401. string birthDay = DcList[i].BirthDay;
  21402. string birthDayStr = string.Empty;
  21403. if (!string.IsNullOrEmpty(birthDay))
  21404. {
  21405. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  21406. }
  21407. builder.Write(birthDayStr);
  21408. builder.MoveToCell(0, i + 1, 3, 0);
  21409. string company = "";
  21410. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  21411. {
  21412. company = DcList[i].CompanyFullName.ToString();
  21413. }
  21414. builder.Write(company);
  21415. builder.MoveToCell(0, i + 1, 4, 0);
  21416. builder.Write(DcList[i].Job);
  21417. }
  21418. }
  21419. else if (_dto.Language == 1)
  21420. {
  21421. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  21422. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  21423. List<string> transArrayStr = new List<string>();
  21424. string transStrRes1 = "";
  21425. var clientEnglishs = new List<ClientEnglishView>();
  21426. for (int i = 0; i < DcList.Count; i++)
  21427. {
  21428. var dc = DcList[i];
  21429. EncryptionProcessor.DecryptProperties(dc);
  21430. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  21431. if (dc.Job.Equals("暂无")) dc.Job = "-";
  21432. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  21433. if (DcList.Count - 1 == i) transStrRes1 += str1;
  21434. else transStrRes1 += $"{str1}|";
  21435. clientEnglishs.Add(new()
  21436. {
  21437. Id = dc.Id,
  21438. LastName = dc.LastName,
  21439. FirstName = dc.FirstName,
  21440. Pinyin = dc.Pinyin,
  21441. Sex = dc.Sex,
  21442. CompanyFullName = dc.CompanyFullName,
  21443. Job = dc.Job,
  21444. IDCardNo = dc.IDCardNo,
  21445. BirthDay = dc.BirthDay,
  21446. });
  21447. }
  21448. #region AI转英文
  21449. string jsonValue = JsonConvert.SerializeObject(clientEnglishs);
  21450. string text = @"将此JSON的中文部分全部翻译为英文,然后只给出修改后的JSON数据,不要其他任何文字";
  21451. List<SeedMessages> messages = new List<SeedMessages>()
  21452. {
  21453. new SeedMessages
  21454. {
  21455. Role = KimiRole.user,
  21456. Content = jsonValue + text
  21457. }
  21458. };
  21459. KiMiApiClient client = new KiMiApiClient();
  21460. var kimiApiResult = await client.SeedMessage(messages);
  21461. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  21462. string clients = kimiApiResult_JObject["content"].ToString();
  21463. string startStr = "```json", endStr = "```";
  21464. // 判断并清除开头部分
  21465. if (clients.StartsWith(startStr))
  21466. {
  21467. clients = clients.Remove(0, startStr.Length);
  21468. }
  21469. // 判断并清除结尾部分
  21470. if (clients.EndsWith(endStr))
  21471. {
  21472. clients = clients.Remove(clients.Length - endStr.Length);
  21473. }
  21474. var en_Json = JsonConvert.DeserializeObject<List<ClientEnglishView>>(clients);
  21475. //循环赋值
  21476. for (int i = 0; i < en_Json.Count; i++)
  21477. {
  21478. var dc = en_Json[i];
  21479. var dc1 = DcList.Find(x => x.Id == dc.Id);
  21480. string PYName = dc.FirstName + " " + dc.LastName;
  21481. builder.MoveToCell(0, i + 1, 0, 0);
  21482. builder.Write(PYName);
  21483. string sex = dc.Sex == 0 ? "Male" : dc.Sex == 1 ? "Female" : "";
  21484. builder.MoveToCell(0, i + 1, 1, 0);
  21485. builder.Write(sex);
  21486. DateTime birthDt;
  21487. bool b_birth = DateTime.TryParse(dc.BirthDay, out birthDt);
  21488. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  21489. builder.MoveToCell(0, i + 1, 2, 0);
  21490. builder.Write(birthday);
  21491. string company = string.Empty, job = string.Empty;
  21492. company = dc.CompanyFullName;
  21493. job = dc.Job;
  21494. if (dc1 != null && !string.IsNullOrEmpty(dc1.CompanyFullName))
  21495. {
  21496. //查询对照表
  21497. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(dc1.CompanyFullName.ToString().Trim()));
  21498. if (tempCec != null)
  21499. {
  21500. company = tempCec.enName;
  21501. }
  21502. }
  21503. builder.MoveToCell(0, i + 1, 3, 0);
  21504. builder.Write(company);
  21505. if (dc1 != null && !string.IsNullOrEmpty(dc1.Job))
  21506. {
  21507. //查询对照表
  21508. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == dc1.Job.ToString().Trim());
  21509. if (tempPec != null)
  21510. {
  21511. job = tempPec.enName;
  21512. }
  21513. }
  21514. builder.MoveToCell(0, i + 1, 4, 0);
  21515. builder.Write(job);
  21516. }
  21517. #endregion
  21518. #region 旧翻译英文处理
  21519. ////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";
  21520. //string transStrRes = "";
  21521. //if (transStrRes1.Length > 0)
  21522. //{
  21523. // transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  21524. //}
  21525. ////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
  21526. ////await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  21527. ////List<string> transArray = new List<string> { };
  21528. //List<TranslateInfo> transArray = new List<TranslateInfo>();
  21529. //if (transStrRes.Contains("|"))
  21530. //{
  21531. // string[] transArray1 = transStrRes.Split('|');
  21532. // if (transArray1.Length > 0)
  21533. // {
  21534. // foreach (var item in transArray1)
  21535. // {
  21536. // if (item.Contains("&"))
  21537. // {
  21538. // string[] transArray2 = item.Split('&');
  21539. // int index = 0;
  21540. // string companyName = "", job = "";
  21541. // if (transArray2.Length > 0)
  21542. // {
  21543. // bool success = int.TryParse(transArray2[0].Trim(), out index);
  21544. // if (1 < transArray2.Length) companyName = transArray2[1];
  21545. // if (2 < transArray2.Length) job = transArray2[2];
  21546. // }
  21547. // transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  21548. // }
  21549. // }
  21550. // }
  21551. //}
  21552. ////循环赋值
  21553. //for (int i = 0; i < DcList.Count; i++)
  21554. //{
  21555. // string PYName = "";
  21556. // if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  21557. // {
  21558. // string PY_Last = DcList[i].Pinyin.Split('/')[0];
  21559. // string PY_First = DcList[i].Pinyin.Split('/')[1];
  21560. // PYName = PY_First + " " + PY_Last;
  21561. // }
  21562. // else
  21563. // {
  21564. // string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  21565. // string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  21566. // PYName = PY_First + " " + PY_Last;
  21567. // }
  21568. // builder.MoveToCell(0, i + 1, 0, 0);
  21569. // builder.Write(PYName);
  21570. // string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  21571. // builder.MoveToCell(0, i + 1, 1, 0);
  21572. // builder.Write(sex);
  21573. // DateTime birthDt;
  21574. // bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  21575. // string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  21576. // builder.MoveToCell(0, i + 1, 2, 0);
  21577. // builder.Write(birthday);
  21578. // string company = string.Empty, job = string.Empty;
  21579. // var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  21580. // if (dcTransInfo != null)
  21581. // {
  21582. // company = dcTransInfo.CompanyName;
  21583. // job = dcTransInfo.Job;
  21584. // }
  21585. // if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  21586. // {
  21587. // //查询对照表
  21588. // Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  21589. // if (tempCec != null)
  21590. // {
  21591. // company = tempCec.enName;
  21592. // }
  21593. // //翻译
  21594. // else
  21595. // {
  21596. // }
  21597. // }
  21598. // builder.MoveToCell(0, i + 1, 3, 0);
  21599. // builder.Write(company);
  21600. // if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  21601. // {
  21602. // //查询对照表
  21603. // Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  21604. // if (tempPec != null)
  21605. // {
  21606. // job = tempPec.enName;
  21607. // }
  21608. // //翻译
  21609. // else
  21610. // {
  21611. // }
  21612. // }
  21613. // builder.MoveToCell(0, i + 1, 4, 0);
  21614. // builder.Write(job);
  21615. //}
  21616. #endregion
  21617. }
  21618. //删除多余行
  21619. while (tableOne.Rows.Count > DcList.Count + 1)
  21620. {
  21621. tableOne.Rows.RemoveAt(DcList.Count + 1);
  21622. }
  21623. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  21624. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  21625. doc.Save(fileDir);
  21626. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  21627. return Ok(JsonView(true, "操作成功!", Url));
  21628. }
  21629. private class TranslateInfo
  21630. {
  21631. public int Index { get; set; }
  21632. public string CompanyName { get; set; }
  21633. public string Job { get; set; }
  21634. }
  21635. [HttpPost]
  21636. public async Task<IActionResult> FileReadClient(List<IFormFile> files)
  21637. {
  21638. if (files.Count == 0)
  21639. {
  21640. return Ok(JsonView(false, "文件为空"));
  21641. }
  21642. KiMiApiClient KiMiApi = new KiMiApiClient();
  21643. var seedConter = await KiMiApi.UploadFilesAsync(files);
  21644. if (seedConter.Count == 0)
  21645. {
  21646. return Ok(JsonView(false, "上传结果为空!"));
  21647. }
  21648. var messages = new List<SeedMessages>
  21649. {
  21650. new SeedMessages { Role = KimiRole.system, Content = "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长中文和英文的对话。你会为用户提供安全,有帮助,准确的回答。同时,你会拒绝一切涉及恐怖主义,种族歧视,黄色暴力等问题的回答。Moonshot AI 为专有名词,不可翻译成其他语言。" },
  21651. new SeedMessages { Role = KimiRole.user, Content = "根据文件内容 ,按照“姓、名、姓名拼音、性别、单位、职务、出生日期”的json格式来排列整理(性别和出生日期通过身份证来识别 , 当识别到性别为男时值给0女给1 未识别到性别的情况下值给-1,出生日期按照yyyy-MM-dd来整理(若出生日期没有值则为‘-’),文件存在拼音的情况读取对应的拼音不存在则设置拼音为中文名字全拼),只输出JSON数组数据 从'['开始 到']'结尾 ,不要除JSON数据外的任何文字以及符号" }
  21652. };
  21653. messages.InsertRange(1, seedConter);
  21654. var kimiApiResult = await KiMiApi.SeedMessage(messages);
  21655. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  21656. string clients = kimiApiResult_JObject["content"].ToString();
  21657. string startStr = "```json", endStr = "```";
  21658. // 判断并清除开头部分
  21659. if (clients.StartsWith(startStr))
  21660. {
  21661. clients = clients.Remove(0, startStr.Length);
  21662. }
  21663. // 判断并清除结尾部分
  21664. if (clients.EndsWith(endStr))
  21665. {
  21666. clients = clients.Remove(clients.Length - endStr.Length);
  21667. }
  21668. var clients_JObject = JsonConvert.DeserializeObject<List<JObject>>(clients);
  21669. Dictionary<string, string> clientFieldMap = new Dictionary<string, string>()
  21670. {
  21671. {"姓", "LastName" },
  21672. {"名", "FirstName" },
  21673. {"姓名拼音", "Pinyin" },
  21674. {"性别", "Sex" },
  21675. {"单位", "CompanyFullName" },
  21676. {"职务", "Job" },
  21677. {"出生日期", "Birthday" },
  21678. };
  21679. List<BaiduClientOCRView> crmClients = new List<BaiduClientOCRView>();
  21680. foreach (var item in clients_JObject)
  21681. {
  21682. BaiduClientOCRView cdc = new BaiduClientOCRView();
  21683. foreach (var field in clientFieldMap.Keys)
  21684. {
  21685. if (item.TryGetValue(field, out JToken value))
  21686. {
  21687. var getValue = value.ToString();
  21688. System.Type type = cdc.GetType();
  21689. PropertyInfo propertyInfo = type.GetProperty(clientFieldMap[field]);
  21690. var propertyValue = Convert.ChangeType(getValue, propertyInfo.PropertyType);
  21691. propertyInfo.SetValue(cdc, propertyValue);
  21692. }
  21693. }
  21694. crmClients.Add(cdc);
  21695. }
  21696. return Ok(JsonView(new
  21697. {
  21698. fileCount = files.Count,
  21699. UploadCount = seedConter.Count,
  21700. ApiResult = clients,
  21701. CrmClients = crmClients
  21702. }));
  21703. }
  21704. #endregion
  21705. #region 团组倒推表
  21706. /// <summary>
  21707. /// 倒推表基础数据
  21708. /// Init
  21709. /// </summary>
  21710. /// <returns></returns>
  21711. [HttpPost]
  21712. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21713. public async Task<IActionResult> PostInvertedListInit()
  21714. {
  21715. var viewData = await _invertedListRep._Init();
  21716. if (viewData.Code != 0)
  21717. {
  21718. return Ok(JsonView(false, viewData.Msg));
  21719. }
  21720. return Ok(JsonView(viewData.Data));
  21721. }
  21722. /// <summary>
  21723. /// 倒推表
  21724. /// Info
  21725. /// </summary>
  21726. /// <param name="dto"></param>
  21727. /// <returns></returns>
  21728. [HttpPost]
  21729. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21730. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  21731. {
  21732. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  21733. if (viewData.Code != 0)
  21734. {
  21735. return Ok(JsonView(false, viewData.Msg));
  21736. }
  21737. return Ok(JsonView(viewData.Data));
  21738. }
  21739. /// <summary>
  21740. /// 倒推表
  21741. /// Create
  21742. /// </summary>
  21743. /// <param name="dto"></param>
  21744. /// <returns></returns>
  21745. [HttpPost]
  21746. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21747. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  21748. {
  21749. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  21750. if (viewData.Code != 0)
  21751. {
  21752. return Ok(JsonView(false, viewData.Msg));
  21753. }
  21754. return Ok(JsonView(viewData.Data));
  21755. }
  21756. /// <summary>
  21757. /// 倒推表
  21758. /// Update
  21759. /// </summary>
  21760. /// <param name="dto"></param>
  21761. /// <returns></returns>
  21762. [HttpPost]
  21763. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21764. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  21765. {
  21766. var viewData = await _invertedListRep._Update(dto);
  21767. if (viewData.Code != 0)
  21768. {
  21769. return Ok(JsonView(false, viewData.Msg));
  21770. }
  21771. return Ok(JsonView(viewData.Data));
  21772. }
  21773. /// <summary>
  21774. /// 倒推表
  21775. /// File Download
  21776. /// </summary>
  21777. /// <param name="dto"></param>
  21778. /// <returns></returns>
  21779. [HttpPost]
  21780. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21781. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  21782. {
  21783. var info2 = await _invertedListRep._Info(1, dto.DiId);
  21784. if (info2.Code != 0)
  21785. {
  21786. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  21787. }
  21788. var info1 = info2.Data as InvertedListInfoView;
  21789. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  21790. string teamName = "";
  21791. if (info != null) teamName = info.TeamName;
  21792. var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20250121.doc";
  21793. var doc = new Document();
  21794. var builder = new DocumentBuilder(doc);
  21795. #region old insert
  21796. ////载入模板
  21797. //var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20200617.doc";
  21798. //Document doc = new Document(tempPath);
  21799. //DocumentBuilder builder = new DocumentBuilder(doc);
  21800. //利用键值对存放数据
  21801. //Dictionary<string, string> dic = new Dictionary<string, string>();
  21802. //dic.Add("TeamName", teamName);
  21803. //dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  21804. //dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  21805. //dic.Add("BPRemark", info1.ApprovalDataRemark);
  21806. //dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  21807. //dic.Add("SQRemark", info1.ApprovalRemark);
  21808. //dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  21809. //dic.Add("CPJRemark", info1.IssueApprovalRemark);
  21810. ////dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  21811. ////dic.Add("HZRemark", info1.ApplyPassportRemark);
  21812. //dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  21813. //dic.Add("QZRemark", info1.VisaInformationRemark);
  21814. //dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  21815. //dic.Add("SQQZRemark", info1.SendVisaRemark);
  21816. //dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  21817. //dic.Add("CQRemark", info1.IssueVisaRemark);
  21818. //dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  21819. //dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  21820. //dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  21821. //dic.Add("SJRemark", info1.AirportdDropOffRemark);
  21822. //#region 填充word模板书签内容
  21823. //foreach (var key in dic.Keys)
  21824. //{
  21825. // builder.MoveToBookmark(key);
  21826. // builder.Write(dic[key]);
  21827. //}
  21828. //#endregion
  21829. #endregion
  21830. #region New Insert
  21831. string titleFont = $"仿宋",
  21832. contentFont = $"仿宋";
  21833. var fontColor = Color.FromArgb(64, 64, 64);
  21834. //设置标题 团组名称
  21835. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  21836. builder.Font.Name = titleFont;
  21837. builder.Font.Color = fontColor;
  21838. builder.Font.Size = 12;
  21839. builder.Font.Bold = true;
  21840. builder.Writeln(teamName);
  21841. //设置副标题 团组出访时间
  21842. builder.Font.Size = 12;
  21843. builder.Writeln("出发时间:" + info1.AirportdDropOffDt.ConvertToDatetime());
  21844. builder.Writeln();
  21845. var backgroundColor = Color.FromArgb(199, 199, 199);
  21846. var table = builder.StartTable();
  21847. builder.InsertCell();
  21848. builder.CellFormat.Shading.BackgroundPatternColor = backgroundColor;
  21849. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Single;
  21850. builder.CellFormat.Borders.LineWidth = 1;
  21851. builder.CellFormat.Borders.Color = Color.FromArgb(183, 183, 183);
  21852. table.FirstRow.FirstCell.CellFormat.Width = 20; // 单位为百分比
  21853. builder.RowFormat.Height = 40;
  21854. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  21855. builder.Font.Name = contentFont;
  21856. builder.Font.Size = 12;
  21857. builder.Font.Bold = true;
  21858. builder.Font.Color = fontColor;
  21859. builder.Write("时间");
  21860. builder.InsertCell();
  21861. table.FirstRow.FirstCell.CellFormat.Width = 30; // 单位为百分比
  21862. builder.Write("流程");
  21863. builder.InsertCell();
  21864. table.FirstRow.FirstCell.CellFormat.Width = 50; // 单位为百分比
  21865. builder.Write("说明");
  21866. builder.EndRow();
  21867. //报批资料准备
  21868. if (info1.IsSelectedAirportd)
  21869. {
  21870. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDataDt.ConvertToDatetime(), "报批资料准备", info1.ApprovalDataRemark);
  21871. }
  21872. //报批/提供送签资料
  21873. if (info1.IsSelectedApprovalData)
  21874. {
  21875. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDt.ConvertToDatetime(), "报批/提供送签资料", info1.ApprovalRemark);
  21876. }
  21877. //出批件护照办理
  21878. if (info1.IsSelectedIssueApproval)
  21879. {
  21880. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueApprovalDt.ConvertToDatetime(), "出批件\r\n护照办理", info1.IssueApprovalRemark);
  21881. }
  21882. //签证资料准备
  21883. if (info1.IsSelectedVisaInfo)
  21884. {
  21885. InvertedListFileDownloadSetRow(builder, contentFont, info1.VisaInformationDt.ConvertToDatetime(), "签证资料准备", info1.VisaInformationRemark);
  21886. }
  21887. //送签
  21888. if (info1.IsSelectedSendVisa)
  21889. {
  21890. InvertedListFileDownloadSetRow(builder, contentFont, info1.SendVisaDt.ConvertToDatetime(), "送签", info1.SendVisaRemark);
  21891. }
  21892. //出签
  21893. if (info1.IsSelectedIssueVisa)
  21894. {
  21895. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueVisaDt.ConvertToDatetime(), "出签", info1.IssueVisaRemark);
  21896. }
  21897. //机票
  21898. if (info1.IsSelectedAirTicket)
  21899. {
  21900. if (string.IsNullOrEmpty(info1.AirTicketDt)) info1.AirTicketDt = info1.IssueVisaDt;
  21901. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirTicketDt.ConvertToDatetime(), "机票", info1.AirTicketRemark);
  21902. }
  21903. //酒店
  21904. if (info1.IsSelectedHotel)
  21905. {
  21906. if (string.IsNullOrEmpty(info1.HotelDt)) info1.HotelDt = info1.IssueVisaDt;
  21907. InvertedListFileDownloadSetRow(builder, contentFont, info1.HotelDt.ConvertToDatetime(), "酒店", info1.HotelRemark);
  21908. }
  21909. //开行前会
  21910. if (info1.IsSelectedPreTripMeeting)
  21911. {
  21912. InvertedListFileDownloadSetRow(builder, contentFont, info1.PreTripMeetingDt.ConvertToDatetime(), "开行前会", info1.PreTripMeetingRemark);
  21913. }
  21914. //送机
  21915. if (info1.IsSelectedAirportdDropOff)
  21916. {
  21917. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirportdDropOffDt.ConvertToDatetime(), "送机", info1.AirportdDropOffRemark);
  21918. }
  21919. builder.EndTable();
  21920. //table.PreferredWidth = PreferredWidth.FromPercent(100.00);
  21921. //table.AutoFit(AutoFitBehavior.FixedColumnWidths);
  21922. for (int i = 0; i < table.Rows.Count; i++)
  21923. {
  21924. var row = table.Rows[i];
  21925. //设置宽度
  21926. row.Cells[0].CellFormat.Width = 20.00;
  21927. row.Cells[1].CellFormat.Width = 30.00;
  21928. row.Cells[2].CellFormat.Width = 50.00;
  21929. if (i != 0)
  21930. {
  21931. //边框设置
  21932. InvertedListFileDownloadSetBorders(row.Cells, 0);
  21933. InvertedListFileDownloadSetBorders(row.Cells, 1);
  21934. InvertedListFileDownloadSetBorders(row.Cells, 2);
  21935. }
  21936. }
  21937. #region 页脚插入图片
  21938. // 创建页脚
  21939. Aspose.Words.HeaderFooter footer = new Aspose.Words.HeaderFooter(doc, HeaderFooterType.FooterPrimary);
  21940. doc.FirstSection.HeadersFooters.Add(footer);
  21941. Paragraph para = new Paragraph(doc);
  21942. para.ParagraphFormat.Alignment = ParagraphAlignment.Right;
  21943. footer.AppendChild(para);
  21944. builder.MoveTo(para);
  21945. string imagePath = "./Images/FMGJ_Log.png";
  21946. builder.InsertImage(imagePath);
  21947. #endregion
  21948. #endregion
  21949. var fileDir = AppSettingsHelper.Get("WordBasePath");
  21950. string fileName = $"{teamName}团出行准备流程表{CommonFun.GUID}.doc";
  21951. string filePath = fileDir + $@"InvertedList/{fileName}";
  21952. doc.Save(filePath);
  21953. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  21954. return Ok(JsonView(true, "操作成功!", Url));
  21955. }
  21956. private void InvertedListFileDownloadSetRow(DocumentBuilder builder, string fontName, string dateTime, string content, string reamrk)
  21957. {
  21958. var fontColor = Color.FromArgb(64, 64, 64);
  21959. builder.InsertCell();
  21960. builder.CellFormat.Shading.BackgroundPatternColor = Color.Empty;
  21961. builder.RowFormat.Height = 40;
  21962. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  21963. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  21964. builder.Font.Name = fontName;
  21965. builder.Font.Size = 8;
  21966. builder.Font.Bold = true;
  21967. builder.Font.Color = fontColor;
  21968. builder.Write(dateTime);
  21969. builder.InsertCell();
  21970. builder.Font.Size = 9;
  21971. builder.Font.Bold = true;
  21972. builder.Font.Color = fontColor;
  21973. builder.Write(content);
  21974. builder.InsertCell();
  21975. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  21976. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  21977. builder.Font.Size = 9;
  21978. builder.Font.Bold = false;
  21979. builder.Font.Color = fontColor;
  21980. builder.Write(reamrk);
  21981. builder.EndRow();
  21982. }
  21983. private void InvertedListFileDownloadSetBorders(CellCollection cell, int index)
  21984. {
  21985. cell[index].CellFormat.Borders.Top.LineStyle = Aspose.Words.LineStyle.None;
  21986. cell[index].CellFormat.Borders.Bottom.LineStyle = Aspose.Words.LineStyle.None;
  21987. cell[index].CellFormat.Borders.Left.LineStyle = Aspose.Words.LineStyle.None;
  21988. cell[index].CellFormat.Borders.Right.LineStyle = Aspose.Words.LineStyle.None;
  21989. //cell[index].CellFormat.Borders.Horizontal.LineStyle = Aspose.Words.LineStyle.None;
  21990. //cell[index].CellFormat.Borders.Vertical.LineStyle = Aspose.Words.LineStyle.None;
  21991. }
  21992. #endregion
  21993. #region 会务倒推表
  21994. /// <summary>
  21995. /// 会务倒推表
  21996. /// Init
  21997. /// </summary>
  21998. /// <returns></returns>
  21999. [HttpPost]
  22000. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22001. public async Task<IActionResult> InforRetrogressTableInit()
  22002. {
  22003. var groupData = await _groupRepository.PostShareGroupInfos(1);
  22004. if (groupData.Code == 0) return Ok(JsonView(groupData.Data));
  22005. return Ok(JsonView(false, groupData.Msg));
  22006. }
  22007. /// <summary>
  22008. /// 会务倒推表
  22009. /// ExcelDownload
  22010. /// </summary>
  22011. /// <param name="dto"></param>
  22012. /// <returns></returns>
  22013. [HttpPost]
  22014. [ApiLog("InforRetrogressTable", OperationEnum.Download)]
  22015. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22016. public async Task<IActionResult> InforRetrogressTableFileDownload(InforRetrogressTableFileDownloadDto dto)
  22017. {
  22018. var validator = new InforRetrogressTableFileDownloadDtoValidator();
  22019. var validatorRes = await validator.ValidateAsync(dto);
  22020. if (!validatorRes.IsValid)
  22021. {
  22022. StringBuilder sb = new StringBuilder();
  22023. foreach (var item in validatorRes.Errors)
  22024. {
  22025. sb.AppendLine(item.ErrorMessage);
  22026. }
  22027. return Ok(JsonView(false, sb.ToString()));
  22028. }
  22029. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.GroupId);
  22030. if (groupInfo == null) return Ok(JsonView(false, $"该团组信息未填写!"));
  22031. //时间根据团组出访日期-接团录入日期的天数来判断用哪个模板
  22032. var days = groupInfo.VisitDate.Subtract(groupInfo.CreateTime).Days;
  22033. #region Excel
  22034. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  22035. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  22036. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "InforRetrogressTable/";
  22037. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "InforRetrogressTable/";
  22038. var fileNamePrefix = string.Empty;
  22039. if (days >= 30)
  22040. {
  22041. tempPath += $"会务工作倒推进度表(30天).xlsx";
  22042. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(30天)";
  22043. }
  22044. else if (days < 30 && days > 7)
  22045. {
  22046. tempPath += $"会务工作倒推进度表(15天).xlsx";
  22047. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(15天)";
  22048. }
  22049. else if (days <= 7)
  22050. {
  22051. tempPath += $"会务工作倒推进度表(7天).xlsx";
  22052. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(7天)";
  22053. }
  22054. var fileName = $"{fileNamePrefix}{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  22055. fileName = CommonFun.ValidFileName(fileName);
  22056. //载入模板
  22057. WorkbookDesigner designer = new WorkbookDesigner();
  22058. designer.Workbook = new Workbook(tempPath);
  22059. designer.Process();
  22060. if (!Directory.Exists(savePath))
  22061. {
  22062. Directory.CreateDirectory(savePath);
  22063. }
  22064. string serverPath = $"{savePath}{fileName}";
  22065. designer.Workbook.Save(serverPath);
  22066. string rst = $"{servicePath}{ftpPath}{fileName}";
  22067. #endregion
  22068. return Ok(JsonView(new { url = rst }));
  22069. }
  22070. #endregion
  22071. #region 三公签证费用(签证费、代办费)
  22072. /// <summary>
  22073. /// 三公签证费用(签证费、代办费)
  22074. /// List
  22075. /// </summary>
  22076. /// <returns></returns>
  22077. [HttpPost]
  22078. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22079. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  22080. {
  22081. return Ok(await _visaFeeInfoRep.List(_dto.PortType, _dto.DiId));
  22082. }
  22083. /// <summary>
  22084. /// 三公签证费用(签证费、代办费)
  22085. /// Add Or Update
  22086. /// </summary>
  22087. /// <returns></returns>
  22088. [HttpPost]
  22089. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22090. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  22091. {
  22092. var _view = await _visaFeeInfoRep.Update(_dto);
  22093. if (_view.Code != 0)
  22094. {
  22095. return Ok(JsonView(false, _view.Msg));
  22096. }
  22097. return Ok(JsonView(true, _view.Msg));
  22098. }
  22099. #endregion
  22100. #region 酒店询价
  22101. /// <summary>
  22102. /// 酒店询价
  22103. /// Init
  22104. /// </summary>
  22105. /// <returns></returns>
  22106. [HttpPost]
  22107. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22108. public async Task<IActionResult> PostHotelInquiryInit()
  22109. {
  22110. var res = await _hotelInquiryRep._Init();
  22111. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  22112. return Ok(JsonView(true, res.Msg, res.Data));
  22113. }
  22114. /// <summary>
  22115. /// 酒店询价
  22116. /// page Item
  22117. /// </summary>
  22118. /// <param name="_dto"></param>
  22119. /// <returns></returns>
  22120. [HttpPost]
  22121. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22122. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  22123. {
  22124. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  22125. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  22126. var view = res.Data as PageDataViewBase;
  22127. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  22128. }
  22129. /// <summary>
  22130. /// 酒店询价
  22131. /// info
  22132. /// </summary>
  22133. /// <param name="_dto"></param>
  22134. /// <returns></returns>
  22135. [HttpPost]
  22136. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22137. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  22138. {
  22139. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  22140. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  22141. return Ok(JsonView(true, res.Msg, res.Data));
  22142. }
  22143. /// <summary>
  22144. /// 酒店询价
  22145. /// Add Or Edit
  22146. /// </summary>
  22147. /// <param name="_dto"></param>
  22148. /// <returns></returns>
  22149. [HttpPost]
  22150. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22151. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  22152. {
  22153. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  22154. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  22155. return Ok(JsonView(true, res.Msg, res.Data));
  22156. }
  22157. /// <summary>
  22158. /// 酒店询价
  22159. /// Del
  22160. /// </summary>
  22161. /// <param name="_dto"></param>
  22162. /// <returns></returns>
  22163. [HttpPost]
  22164. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22165. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  22166. {
  22167. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  22168. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  22169. return Ok(JsonView(true, res.Msg, res.Data));
  22170. }
  22171. #endregion
  22172. #region 下载匹配op行程单
  22173. /// <summary>
  22174. /// 匹配op行程单
  22175. /// Init
  22176. /// </summary>
  22177. /// <param name="dto">团组列表请求dto</param>
  22178. /// <returns></returns>
  22179. [HttpPost]
  22180. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22181. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  22182. {
  22183. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  22184. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  22185. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  22186. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  22187. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  22188. .Where(it => it.IsDel == 0)
  22189. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  22190. .OrderByDescending(it => it.VisitStartDate)
  22191. .ToList();
  22192. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  22193. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  22194. var diids = groupInfos.Select(it => it.Id).ToList();
  22195. List<string> countrys = new List<string>();
  22196. foreach (var item in country)
  22197. {
  22198. var data = _groupRepository.FormartTeamName(item);
  22199. var dataArray = _groupRepository.GroupSplitCountry(data);
  22200. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  22201. }
  22202. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  22203. List<string> areaArray = new List<string>(); //GetGroupCityLine
  22204. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  22205. foreach (var item in areaItem)
  22206. {
  22207. string areaStr = item.Value;
  22208. if (!string.IsNullOrEmpty(areaStr))
  22209. {
  22210. string[] str1 = areaStr.Split("-");
  22211. if (str1.Length > 0)
  22212. {
  22213. areaArray.AddRange(str1);
  22214. }
  22215. }
  22216. }
  22217. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  22218. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  22219. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  22220. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  22221. .ToList();
  22222. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  22223. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  22224. .Where(it => countriesIds.Contains(it.Id))
  22225. .Select(it => new { it.Id, Name = it.Name_CN })
  22226. .ToList();
  22227. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  22228. .Select(it => it.TeamName).ToList();
  22229. stopwatch.Stop();
  22230. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  22231. }
  22232. ///// <summary>
  22233. ///// 匹配op行程单
  22234. ///// Init 查询区域数据
  22235. ///// </summary>
  22236. ///// <param name="dto">团组列表请求dto</param>
  22237. ///// <returns></returns>
  22238. //[HttpPost]
  22239. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22240. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  22241. //{
  22242. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  22243. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  22244. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  22245. // if (string.IsNullOrEmpty(countriesDataStr))
  22246. // {
  22247. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  22248. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  22249. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  22250. // }
  22251. // else
  22252. // {
  22253. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  22254. // }
  22255. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  22256. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  22257. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  22258. // List<dynamic> childList = new List<dynamic>();
  22259. // int parentId = dto.CountriesId;
  22260. // if (provinceData.Count > 1)
  22261. // {
  22262. // foreach (var item1 in provinceData)
  22263. // {
  22264. // List<dynamic> childList1 = new List<dynamic>();
  22265. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  22266. // foreach (var item2 in citiesData1)
  22267. // {
  22268. // List<dynamic> childList2 = new List<dynamic>();
  22269. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  22270. // foreach (var item3 in countiesData1)
  22271. // {
  22272. // childList2.Add(new
  22273. // {
  22274. // id = item3.Id,
  22275. // parentId = item2.Id,
  22276. // level = "district",
  22277. // name = item3.Name_CN,
  22278. // });
  22279. // }
  22280. // childList1.Add(new
  22281. // {
  22282. // id = item2.Id,
  22283. // parentId = item1.Id,
  22284. // level = "city",
  22285. // name = item2.Name_CN,
  22286. // childList = childList2
  22287. // });
  22288. // }
  22289. // childList.Add(new
  22290. // {
  22291. // id = item1.Id,
  22292. // parentId = parentId,
  22293. // level = "province",
  22294. // name = item1.Name_CN,
  22295. // childList = childList1
  22296. // });
  22297. // }
  22298. // //城市
  22299. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  22300. // foreach (var item2 in citiesData2)
  22301. // {
  22302. // List<dynamic> childList22 = new List<dynamic>();
  22303. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  22304. // foreach (var item3 in countiesData1)
  22305. // {
  22306. // childList22.Add(new
  22307. // {
  22308. // id = item3.Id,
  22309. // parentId = item2.Id,
  22310. // level = "district",
  22311. // name = item3.Name_CN,
  22312. // });
  22313. // }
  22314. // childList.Add(new
  22315. // {
  22316. // id = item2.Id,
  22317. // parentId = parentId,
  22318. // level = "city",
  22319. // name = item2.Name_CN,
  22320. // childList = childList22
  22321. // });
  22322. // }
  22323. // }
  22324. // else
  22325. // {
  22326. // foreach (var item2 in citiesData)
  22327. // {
  22328. // string cname = item2.Name_CN;
  22329. // List<dynamic> childList1 = new List<dynamic>();
  22330. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  22331. // foreach (var item3 in countiesData1)
  22332. // {
  22333. // childList1.Add(new
  22334. // {
  22335. // Id = item3.Id,
  22336. // parentId = item2.Id,
  22337. // level = "district",
  22338. // name = item3.Name_CN
  22339. // });
  22340. // }
  22341. // childList.Add(new
  22342. // {
  22343. // id = item2.Id,
  22344. // parentId = parentId,
  22345. // level = "city",
  22346. // name = item2.Name_CN,
  22347. // childList = childList1
  22348. // });
  22349. // }
  22350. // }
  22351. // stopwatch.Stop();
  22352. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  22353. //}
  22354. /// <summary>
  22355. /// 匹配op行程单
  22356. /// 接团信息列表 Page
  22357. /// </summary>
  22358. /// <param name="dto">团组列表请求dto</param>
  22359. /// <returns></returns>
  22360. [HttpPost]
  22361. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22362. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  22363. {
  22364. var swatch = new Stopwatch();
  22365. swatch.Start();
  22366. #region 参数验证
  22367. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  22368. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  22369. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  22370. #region 页面操作权限验证
  22371. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  22372. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  22373. #endregion
  22374. #endregion
  22375. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  22376. {
  22377. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  22378. //string sqlWhere = "";
  22379. if (!string.IsNullOrEmpty(dto.Country))
  22380. {
  22381. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  22382. }
  22383. if (!string.IsNullOrEmpty(dto.Area))
  22384. {
  22385. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  22386. }
  22387. if (!string.IsNullOrEmpty(dto.TeamName))
  22388. {
  22389. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  22390. }
  22391. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  22392. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  22393. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  22394. swatch.Stop();
  22395. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  22396. }
  22397. else
  22398. {
  22399. return Ok(JsonView(false, "查询失败"));
  22400. }
  22401. }
  22402. /// <summary>
  22403. /// 匹配op行程单
  22404. /// 行程单下载
  22405. /// </summary>
  22406. /// <param name="dto">团组列表请求dto</param>
  22407. /// <returns></returns>
  22408. [HttpPost]
  22409. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22410. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  22411. {
  22412. #region 参数验证
  22413. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  22414. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  22415. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  22416. #region 页面操作权限验证
  22417. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  22418. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  22419. #endregion
  22420. #endregion
  22421. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  22422. {
  22423. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  22424. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  22425. }
  22426. else
  22427. {
  22428. return Ok(JsonView(false, "下载失败!"));
  22429. }
  22430. }
  22431. #endregion
  22432. #region 国家信息 数据 注释
  22433. //[HttpPost]
  22434. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  22435. //{
  22436. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  22437. // foreach (var item in dto)
  22438. // {
  22439. // infos.Add(new Grp_GroupsTaskAssignment()
  22440. // {
  22441. // DIId = item,
  22442. // CTId = 82,
  22443. // UId = 248,
  22444. // IsEnable = 1,
  22445. // CreateUserId = 233,
  22446. // CreateTime = DateTime.Now,
  22447. // IsDel = 0
  22448. // });
  22449. // infos.Add(new Grp_GroupsTaskAssignment()
  22450. // {
  22451. // DIId = item,
  22452. // CTId = 82,
  22453. // UId = 286,
  22454. // IsEnable = 1,
  22455. // CreateUserId = 233,
  22456. // CreateTime = DateTime.Now,
  22457. // IsDel = 0
  22458. // });
  22459. // }
  22460. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  22461. // return Ok("操作成功");
  22462. //}
  22463. //public class paramJsonDto
  22464. //{
  22465. // public List<CountriesInfo> str { get; set; }
  22466. //}
  22467. //[HttpPost]
  22468. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  22469. //{
  22470. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  22471. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  22472. // List<Sys_Cities> cities = new List<Sys_Cities>();
  22473. // List<Sys_Cities> districts = new List<Sys_Cities>();
  22474. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  22475. // _sqlSugar.BeginTran();
  22476. // int countitiesIndex = 0;
  22477. // foreach (var item in dto.str)
  22478. // {
  22479. // dynamic data = item.c;
  22480. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  22481. // if (data != null)
  22482. // {
  22483. // countitiesIndex++;
  22484. // foreach (var item1 in data)
  22485. // {
  22486. // string cnname = item1.cn;
  22487. // string enname = item1.en;
  22488. // Sys_Cities provinceInfo = new Sys_Cities()
  22489. // {
  22490. // CountriesId = countriesId,
  22491. // Name_CN = cnname,
  22492. // Name_EN = enname,
  22493. // ParentId = 0,
  22494. // IsCapital = 1,
  22495. // CreateUserId = 208,
  22496. // CreateTime = DateTime.Now,
  22497. // IsDel = 0
  22498. // };
  22499. // if (item1.lv == "province") //省份
  22500. // {
  22501. // provinceInfo.Level = 1;
  22502. // int provinceId = 0;
  22503. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  22504. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  22505. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  22506. // var data1 = item1.c;
  22507. // foreach (var item2 in data1)
  22508. // {
  22509. // if (item2.lv == "city")
  22510. // {
  22511. // string citycnname = item2.cn;
  22512. // string cityenname = item2.en;
  22513. // Sys_Cities cityInfo = new Sys_Cities()
  22514. // {
  22515. // CountriesId = countriesId,
  22516. // ParentId = provinceId,
  22517. // Level = 2,
  22518. // Name_CN = citycnname,
  22519. // Name_EN = cityenname,
  22520. // IsCapital = 1,
  22521. // CreateUserId = 208,
  22522. // CreateTime = DateTime.Now,
  22523. // IsDel = 0
  22524. // };
  22525. // if (item2.c != null)
  22526. // {
  22527. // int cityId = 0;
  22528. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  22529. // if (citiesInfo != null) cityId = citiesInfo.Id;
  22530. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  22531. // foreach (var item3 in item2.c)
  22532. // {
  22533. // if (item3.lv == "district")
  22534. // {
  22535. // var districtInfo = new Sys_Cities()
  22536. // {
  22537. // CountriesId = countriesId,
  22538. // Name_CN = item3.cn,
  22539. // Name_EN = item3.en,
  22540. // Level = 3,
  22541. // ParentId = cityId,
  22542. // IsCapital = 1,
  22543. // CreateUserId = 208,
  22544. // CreateTime = DateTime.Now,
  22545. // IsDel = 0
  22546. // };
  22547. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  22548. // //{
  22549. // districts.Add(districtInfo);
  22550. // //}
  22551. // }
  22552. // }
  22553. // }
  22554. // else
  22555. // {
  22556. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  22557. // //{
  22558. // cities.Add(cityInfo);
  22559. // //}
  22560. // }
  22561. // }
  22562. // }
  22563. // }
  22564. // else if (item1.lv == "city")//城市
  22565. // {
  22566. // provinceInfo.Level = 2;
  22567. // if (item1.c != null)
  22568. // {
  22569. // int cityId = 0;
  22570. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  22571. // if (citiesInfo != null) cityId = citiesInfo.Id;
  22572. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  22573. // foreach (var item3 in item1.c)
  22574. // {
  22575. // if (item3.lv == "district")
  22576. // {
  22577. // var districtInfo = new Sys_Cities()
  22578. // {
  22579. // CountriesId = countriesId,
  22580. // Name_CN = item3.cn,
  22581. // Name_EN = item3.en,
  22582. // Level = 3,
  22583. // ParentId = cityId,
  22584. // IsCapital = 1,
  22585. // CreateUserId = 208,
  22586. // CreateTime = DateTime.Now,
  22587. // IsDel = 0
  22588. // };
  22589. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  22590. // //{
  22591. // districts.Add(districtInfo);
  22592. // //}
  22593. // }
  22594. // }
  22595. // }
  22596. // else
  22597. // {
  22598. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  22599. // //{
  22600. // cities.Add(provinceInfo);
  22601. // //}
  22602. // }
  22603. // }
  22604. // }
  22605. // }
  22606. // }
  22607. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  22608. // cities = cities.Distinct().ToList();
  22609. // districts = districts.Distinct().ToList();
  22610. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  22611. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  22612. // cities.AddRange(districts);
  22613. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  22614. // //_sqlSugar.RollbackTran();
  22615. // _sqlSugar.CommitTran();
  22616. // return Ok(JsonView(false, "操作成功!"));
  22617. //}
  22618. //[HttpPost]
  22619. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  22620. //{
  22621. // List<CountitiesInfo> infos = dto.MyProperty;
  22622. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  22623. // _sqlSugar.BeginTran();
  22624. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  22625. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  22626. // foreach (var item in infos)
  22627. // {
  22628. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  22629. // if (countryInfo != null)
  22630. // {
  22631. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  22632. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  22633. // if (cityInfo1 != null)
  22634. // {
  22635. // cityInfo1.IsCapital = 0;
  22636. // cityInfos.Add(cityInfo1);
  22637. // }
  22638. // }
  22639. // }
  22640. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  22641. // .UpdateColumns(it => it.IsCapital)
  22642. // .WhereColumns(it => it.Id)
  22643. // .ExecuteCommand();
  22644. // //_sqlSugar.RollbackTran();
  22645. // _sqlSugar.CommitTran();
  22646. // return Ok(JsonView(false, "操作成功!"));
  22647. //}
  22648. //public class CounrtiesDto
  22649. //{
  22650. // public List<CountitiesInfo> MyProperty { get; set; }
  22651. //}
  22652. //public class CountitiesInfo
  22653. //{
  22654. // /// <summary>
  22655. // /// 圣约翰
  22656. // /// </summary>
  22657. // public string capital_name_chinese { get; set; }
  22658. // /// <summary>
  22659. // ///
  22660. // /// </summary>
  22661. // public string capital_name { get; set; }
  22662. // /// <summary>
  22663. // ///
  22664. // /// </summary>
  22665. // public string country_type { get; set; }
  22666. // /// <summary>
  22667. // /// 安提瓜和巴布达
  22668. // /// </summary>
  22669. // public string country_name_chinese { get; set; }
  22670. // /// <summary>
  22671. // /// 安提瓜和巴布达
  22672. // /// </summary>
  22673. // public string country_name_chinese_short { get; set; }
  22674. // /// <summary>
  22675. // /// 安提瓜和巴布达
  22676. // /// </summary>
  22677. // public string country_name_chinese_UN { get; set; }
  22678. // /// <summary>
  22679. // ///
  22680. // /// </summary>
  22681. // public string country_name_english_abbreviation { get; set; }
  22682. // /// <summary>
  22683. // ///
  22684. // /// </summary>
  22685. // public string country_name_english_formal { get; set; }
  22686. // /// <summary>
  22687. // ///
  22688. // /// </summary>
  22689. // public string country_name_english_UN { get; set; }
  22690. // /// <summary>
  22691. // ///
  22692. // /// </summary>
  22693. // public string continent_name { get; set; }
  22694. // /// <summary>
  22695. // ///
  22696. // /// </summary>
  22697. // public string subregion_name { get; set; }
  22698. // /// <summary>
  22699. // ///
  22700. // /// </summary>
  22701. // public string country_code2 { get; set; }
  22702. // /// <summary>
  22703. // ///
  22704. // /// </summary>
  22705. // public string country_code3 { get; set; }
  22706. // /// <summary>
  22707. // ///
  22708. // /// </summary>
  22709. // public string phone_code { get; set; }
  22710. //}
  22711. //public class CountriesInfo : BasicInfo
  22712. //{
  22713. // public List<CitiesInfo> c { get; set; }
  22714. //}
  22715. //public class CitiesInfo : BasicInfo
  22716. //{
  22717. // public List<AreaInfo> c { get; set; }
  22718. //}
  22719. //public class AreaInfo : BasicInfo
  22720. //{
  22721. // public List<AreaInfo> c { get; set; }
  22722. //}
  22723. //public class BasicInfo
  22724. //{
  22725. // public string code { get; set; }
  22726. // public string cn { get; set; }
  22727. // public string lv { get; set; }
  22728. // public string en { get; set; }
  22729. //}
  22730. #endregion
  22731. #region 查看邀请方
  22732. /// <summary>
  22733. /// 查看邀请方
  22734. /// 邀请方信息 Init
  22735. /// </summary>
  22736. /// <param name="dto"></param>
  22737. /// <returns></returns>
  22738. [HttpPost]
  22739. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22740. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  22741. {
  22742. string sqlWhere = string.Empty;
  22743. if (!string.IsNullOrEmpty(dto.Search))
  22744. {
  22745. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  22746. }
  22747. string sql = string.Format($@"Select
  22748. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  22749. Id,
  22750. UnitName
  22751. From Res_InvitationOfficialActivityData
  22752. Where IsDel = 0
  22753. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  22754. RefAsync<int> total = 0;
  22755. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  22756. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  22757. }
  22758. /// <summary>
  22759. /// 查看邀请方
  22760. /// 国家信息 Init
  22761. /// </summary>
  22762. /// <param name="dto"></param>
  22763. /// <returns></returns>
  22764. [HttpPost]
  22765. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22766. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  22767. {
  22768. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  22769. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  22770. var diids = groupInfos.Select(it => it.Id).ToList();
  22771. List<string> countrys = new List<string>();
  22772. foreach (var item in country)
  22773. {
  22774. var data = _groupRepository.FormartTeamName(item);
  22775. var dataArray = _groupRepository.GroupSplitCountry(data);
  22776. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  22777. }
  22778. countrys = countrys.Distinct().ToList();
  22779. for (int i = 0; i < countrys.Count; i++)
  22780. {
  22781. string item = countrys[i];
  22782. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  22783. {
  22784. countrys.Remove(item);
  22785. i--;
  22786. }
  22787. }
  22788. RefAsync<int> total = 0;
  22789. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  22790. .Where(it => countrys.Contains(it.Name_CN))
  22791. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  22792. .Select(it => new { id = it.Id, name = it.Name_CN })
  22793. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  22794. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  22795. }
  22796. /// <summary>
  22797. /// 查看邀请方
  22798. /// 城市信息 Init
  22799. /// </summary>
  22800. /// <param name="dto"></param>
  22801. /// <returns></returns>
  22802. [HttpPost]
  22803. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22804. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  22805. {
  22806. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  22807. RefAsync<int> total = 0;
  22808. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  22809. .Where(it => it.CountriesId == dto.CountiesId)
  22810. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  22811. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  22812. .Select(it => new { id = it.Id, name = it.Name_CN })
  22813. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  22814. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  22815. }
  22816. /// <summary>
  22817. /// 查看邀请方
  22818. /// 团组名称 Init
  22819. /// </summary>
  22820. /// <param name="dto"></param>
  22821. /// <returns></returns>
  22822. [HttpPost]
  22823. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22824. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  22825. {
  22826. var watch = new Stopwatch();
  22827. watch.Start();
  22828. RefAsync<int> total = 0;
  22829. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  22830. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  22831. .Where((oa, di) => oa.IsDel == 0)
  22832. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  22833. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  22834. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  22835. .Distinct()
  22836. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  22837. watch.Stop();
  22838. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  22839. }
  22840. /// <summary>
  22841. /// 查看邀请方
  22842. /// 团组 & 邀请方信息
  22843. /// </summary>
  22844. /// <param name="dto"></param>
  22845. /// <returns></returns>
  22846. [HttpPost]
  22847. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22848. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  22849. {
  22850. var watch = new Stopwatch();
  22851. watch.Start();
  22852. RefAsync<int> total = 0;
  22853. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  22854. .AS("Grp_DelegationInfo")
  22855. .Includes(x => x.InvitingInfos)
  22856. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  22857. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  22858. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  22859. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  22860. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  22861. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  22862. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  22863. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  22864. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  22865. infos.ForEach(x =>
  22866. {
  22867. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  22868. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  22869. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  22870. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  22871. });
  22872. watch.Stop();
  22873. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  22874. }
  22875. #endregion
  22876. #region 报批行程
  22877. /// <summary>
  22878. /// 报批行程初始化
  22879. /// </summary>
  22880. /// <param name="dto"></param>
  22881. /// <returns></returns>
  22882. [HttpPost]
  22883. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  22884. {
  22885. const int chiNumber = 5;
  22886. var jw = JsonView(false);
  22887. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  22888. var group = groupList.First();
  22889. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  22890. group = groupList.First(x => x.Id == diid);
  22891. var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  22892. .Where(x => x.DiId == diid && x.IsDel == 0)
  22893. .ToArray();
  22894. var count = 1;
  22895. foreach (var item in blackCodeList)
  22896. {
  22897. if (string.IsNullOrWhiteSpace(item.Title))
  22898. {
  22899. item.Title = "未设置名称数据" + count;
  22900. }
  22901. count++;
  22902. }
  22903. ;
  22904. if (group == null)
  22905. {
  22906. jw.Msg = "暂无团组!";
  22907. return Ok(jw);
  22908. }
  22909. var data = new
  22910. {
  22911. groupList = groupList.Select(x => new
  22912. {
  22913. x.TeamName,
  22914. x.Id
  22915. }),
  22916. content = new ArrayList(),
  22917. groupInfo = new
  22918. {
  22919. group.VisitDays,
  22920. group.TourCode,
  22921. group.VisitPNumber,
  22922. group.TeamName,
  22923. group.Id,
  22924. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  22925. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd"),
  22926. group.ClientUnit
  22927. },
  22928. blackCodeList = blackCodeList.Select(x => new
  22929. {
  22930. x.Title,
  22931. x.Id
  22932. }),
  22933. FileTempList = new ArrayList()
  22934. {
  22935. new { Index = 1,FileName = "旧模板" },
  22936. new { Index = 2,FileName = "省外办" },
  22937. new { Index = 3,FileName = "市外办" },
  22938. }
  22939. };
  22940. var resultArr = new ArrayList();
  22941. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  22942. #region 默认不生成行程
  22943. //if (content.Count == 0)
  22944. //{
  22945. // var stay = "-";
  22946. // var cityPath = "-";
  22947. // var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  22948. // .Where(x => x.DiId == diid && x.IsDel == 0)
  22949. // .ToList();
  22950. // //添加城市路径以及住宿地
  22951. // //黑屏代码数据
  22952. // DataTable dtBlack = GeneralMethod.GetTableByBlackCodeById(blackCodeList.FirstOrDefault());
  22953. // if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  22954. // {
  22955. // jw = JsonView(true, "黑屏代码有误!", data);
  22956. // return Ok(jw);
  22957. // }
  22958. // data = data with
  22959. // {
  22960. // blackCodeList = new ArrayList(blackCodeList.Select(x => new
  22961. // {
  22962. // x.Title,
  22963. // x.Id,
  22964. // }).ToArray())
  22965. // };
  22966. // foreach (DataRow row in dtBlack.Rows)
  22967. // {
  22968. // if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  22969. // {
  22970. // jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  22971. // return Ok(jw);
  22972. // }
  22973. // }
  22974. // //黑屏代码获取时间区间
  22975. // var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  22976. // string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  22977. // _sqlSugar.BeginTran();
  22978. // for (int i = 0; i < timeArr.Count; i++)
  22979. // {
  22980. // stay = "-";
  22981. // cityPath = "-";
  22982. // DateTime NewData = DateTime.Parse(timeArr[i]);
  22983. // string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  22984. // Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  22985. // var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  22986. // if (tbSelect.Length > 0)
  22987. // {
  22988. // List<string> threeCodeStr = new List<string>();
  22989. // foreach (var item in tbSelect)
  22990. // {
  22991. // var threeCode = item["Three"].ToString() ?? "";
  22992. // if (threeCode.Length == 6)
  22993. // {
  22994. // var start = threeCode.Substring(0, 3);
  22995. // var end = threeCode.Substring(3, 3);
  22996. // if (threeCodeStr.Count == 0)
  22997. // {
  22998. // threeCodeStr.Add(start);
  22999. // threeCodeStr.Add(end);
  23000. // }
  23001. // else
  23002. // {
  23003. // if (threeCodeStr[threeCodeStr.Count - 1] == start)
  23004. // {
  23005. // threeCodeStr.Add(end);
  23006. // }
  23007. // else
  23008. // {
  23009. // threeCodeStr.Add(start);
  23010. // threeCodeStr.Add(end);
  23011. // }
  23012. // }
  23013. // }
  23014. // }
  23015. // var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  23016. // var last = threeCodeStr.Last();
  23017. // foreach (var item in threeCodeStr)
  23018. // {
  23019. // cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  23020. // if (item.Equals(last))
  23021. // {
  23022. // stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  23023. // }
  23024. // }
  23025. // cityPath = cityPath.Trim('-');
  23026. // }
  23027. // appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  23028. // appro.Diid = diid ?? -1;
  23029. // var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  23030. // appro.Id = thisId;
  23031. // appro.CreateUserId = dto.UserId;
  23032. // appro.CreateTime = DateTime.Now;
  23033. // content.Add(appro);
  23034. // }
  23035. // _sqlSugar.CommitTran();
  23036. //}
  23037. #endregion
  23038. foreach (var x in content)
  23039. {
  23040. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  23041. if (chiList.Count < chiNumber)
  23042. {
  23043. for (int i = chiList.Count; i < chiNumber; i++)
  23044. {
  23045. chiList.Add(new Grp_ApprovalTravelDetails());
  23046. }
  23047. }
  23048. resultArr.Add(new
  23049. {
  23050. x.Id,
  23051. x.Date,
  23052. x.Diid,
  23053. chiList = chiList.Select(x1 => new
  23054. {
  23055. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  23056. x1.Details,
  23057. x1.ParentId,
  23058. x1.Id
  23059. })
  23060. });
  23061. }
  23062. data = data with
  23063. {
  23064. content = resultArr,
  23065. };
  23066. jw = JsonView(true, "获取成功!", data);
  23067. return Ok(jw);
  23068. }
  23069. /// <summary>
  23070. /// 报批行程删除
  23071. /// </summary>
  23072. /// <param name="dto"></param>
  23073. /// <returns></returns>
  23074. [HttpPost]
  23075. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  23076. {
  23077. var jw = JsonView(false);
  23078. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  23079. if (group == null)
  23080. {
  23081. jw.Msg = "团组参数有误!";
  23082. return Ok(jw);
  23083. }
  23084. try
  23085. {
  23086. _sqlSugar.BeginTran();
  23087. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  23088. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  23089. {
  23090. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  23091. DeleteUserId = dto.uesrId,
  23092. IsDel = 1
  23093. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  23094. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  23095. {
  23096. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  23097. DeleteUserId = dto.uesrId,
  23098. IsDel = 1
  23099. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  23100. _sqlSugar.CommitTran();
  23101. jw = JsonView(true, "删除成功");
  23102. }
  23103. catch (Exception ex)
  23104. {
  23105. jw = JsonView(false, ex.Message);
  23106. }
  23107. return Ok(jw);
  23108. }
  23109. /// <summary>
  23110. /// 报批行程保存
  23111. /// </summary>
  23112. /// <param name="dto"></param>
  23113. /// <returns></returns>
  23114. [HttpPost]
  23115. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  23116. {
  23117. var jw = JsonView(false);
  23118. var Find = dto.Arr.Find(x => x.id == 0);
  23119. if (Find != null)
  23120. {
  23121. jw.Msg = "生成的ID为0!";
  23122. return Ok(jw);
  23123. }
  23124. foreach (var item in dto.Arr)
  23125. {
  23126. foreach (var chi in item.chiList)
  23127. {
  23128. if (chi.parentId == 0)
  23129. {
  23130. chi.parentId = item.id;
  23131. }
  23132. }
  23133. }
  23134. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  23135. _sqlSugar.BeginTran();
  23136. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  23137. {
  23138. var parentIds = dto.Arr.Select(x => x.id).ToList();
  23139. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  23140. {
  23141. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  23142. DeleteUserId = dto.UserId,
  23143. IsDel = 1
  23144. }).ExecuteCommand();
  23145. }
  23146. try
  23147. {
  23148. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  23149. {
  23150. CreateTime = DateTime.Now,
  23151. CreateUserId = dto.UserId,
  23152. Details = x.details,
  23153. ParentId = x.parentId,
  23154. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  23155. Remark = "",
  23156. IsDel = 0
  23157. }).ToList()).ExecuteCommand();
  23158. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  23159. {
  23160. Id = x.id,
  23161. Details = x.details,
  23162. ParentId = x.parentId,
  23163. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  23164. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  23165. {
  23166. Details = x.Details,
  23167. ParentId = x.ParentId,
  23168. Time = x.Time
  23169. }).ExecuteCommand();
  23170. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  23171. {
  23172. Id = x.id,
  23173. Date = x.date,
  23174. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  23175. {
  23176. Date = x.Date
  23177. }).ExecuteCommand();
  23178. _sqlSugar.CommitTran();
  23179. jw = JsonView(true, "保存成功!");
  23180. }
  23181. catch (Exception ex)
  23182. {
  23183. _sqlSugar.RollbackTran();
  23184. jw = JsonView(false, "保存失败!" + ex.Message);
  23185. }
  23186. return Ok(jw);
  23187. }
  23188. /// <summary>
  23189. /// 报批行程生成
  23190. /// </summary>
  23191. /// <param name="dto"></param>
  23192. /// <returns></returns>
  23193. [HttpPost]
  23194. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  23195. {
  23196. var jw = JsonView(false);
  23197. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  23198. if (group == null)
  23199. {
  23200. jw.Msg = "暂无该团组!";
  23201. return Ok(jw);
  23202. }
  23203. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().First(x => x.Id == dto.BlackCodeId && x.IsDel == 0);
  23204. //黑屏代码数据
  23205. DataTable dtBlack = GeneralMethod.GetTableByBlackCodeBySingle(blackCode);
  23206. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  23207. {
  23208. jw.Msg = "黑屏代码有误!";
  23209. return Ok(jw);
  23210. }
  23211. foreach (DataRow row in dtBlack.Rows)
  23212. {
  23213. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  23214. {
  23215. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  23216. return Ok(jw);
  23217. }
  23218. }
  23219. //var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  23220. var resultArr = new ArrayList();
  23221. //if (officialActivitiesArr.Count == 0)
  23222. //{
  23223. // jw.Msg = "暂无公务出访信息!";
  23224. // return Ok(jw);
  23225. //}
  23226. try
  23227. {
  23228. _sqlSugar.BeginTran();
  23229. DeleteApprovalJourney(new
  23230. Domain.Dtos.Groups.DeleteApprovalJourney
  23231. {
  23232. Diid = dto.Diid,
  23233. uesrId = dto.Userid
  23234. });
  23235. var stay = "-";
  23236. var cityPath = "-";
  23237. var arriveCountry = string.Empty;
  23238. //添加城市路径以及住宿地
  23239. //黑屏代码获取时间区间
  23240. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  23241. var empty = "【未收入该三字码!请机票同事录入】";
  23242. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  23243. #region 配置公务活动时间
  23244. List<Tuple<int, string, string>> Times = new List<Tuple<int, string, string>>();
  23245. Times.Add(new Tuple<int, string, string>(9, "9:00", "10:30"));
  23246. Times.Add(new Tuple<int, string, string>(11, "11:00", "12:00"));
  23247. Times.Add(new Tuple<int, string, string>(14, "14:00", "15:30"));
  23248. Times.Add(new Tuple<int, string, string>(16, "16:00", "17:00"));
  23249. List<Tuple<DateTime, List<string>>> fallTimesCheckCountry = new List<Tuple<DateTime, List<string>>>()
  23250. {
  23251. 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" }),
  23252. 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"}),
  23253. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,11,30,0), new List<string>{"14:00-15:30","16:00-17:00"}),
  23254. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,13,30,0), new List<string>{"16:30-17:30"}),
  23255. };
  23256. List<Tuple<DateTime, List<string>>> fallTimesNotCheckCountry = new List<Tuple<DateTime, List<string>>>()
  23257. {
  23258. 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" }),
  23259. 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"}),
  23260. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,11,30,0), new List<string>{"14:00-15:30","16:00-17:00"}),
  23261. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,14,30,0), new List<string>{"16:30-17:30"}),
  23262. };
  23263. List<Tuple<DateTime, List<string>>> takeoffTimes = new List<Tuple<DateTime, List<string>>>()
  23264. {
  23265. 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" }),
  23266. 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"}),
  23267. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,14,00,0), new List<string>{"9:00-10:30", "11:00-12:00",}),
  23268. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,12,00,0), new List<string>{"09:00-10:00"}),
  23269. };
  23270. #endregion
  23271. var nextDayNum = 0;
  23272. for (int i = 0; i < timeArr.Count; i++)
  23273. {
  23274. stay = "-";
  23275. cityPath = "-";
  23276. var chiarr = new List<Grp_ApprovalTravelDetails>();
  23277. DateTime NewData = DateTime.Parse(timeArr[i]);
  23278. //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();
  23279. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  23280. if (nextDayNum > 0)
  23281. {
  23282. nextDayNum--;
  23283. }
  23284. if (tbSelect.Length > 0)
  23285. {
  23286. List<string> threeCodeStr = new List<string>();
  23287. bool isTrade = false;
  23288. string trip = string.Empty;
  23289. foreach (var item in tbSelect)
  23290. {
  23291. if (nextDayNum == 0)
  23292. {
  23293. nextDayNum = Convert.ToInt32(item["Sign"]);
  23294. }
  23295. var airStartTime = item["StartTime"].ToString() ?? "0000";
  23296. var airEndTime = item["EndTime"].ToString() ?? "0000";
  23297. var takeOffTime = DateTime.Parse(timeArr[i]);
  23298. var fallToTime = DateTime.Parse(timeArr[i]);
  23299. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  23300. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  23301. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  23302. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  23303. if (nextDayNum > 0)
  23304. {
  23305. fallToTime = fallToTime.AddDays(nextDayNum);
  23306. }
  23307. trip = string.Empty;
  23308. var start = string.Empty;
  23309. var end = string.Empty;
  23310. var threeCode = item["Three"].ToString() ?? "";
  23311. if (threeCode.Length == 6)
  23312. {
  23313. start = threeCode.Substring(0, 3);
  23314. end = threeCode.Substring(3, 3);
  23315. if (threeCodeStr.Count == 0)
  23316. {
  23317. threeCodeStr.Add(start);
  23318. threeCodeStr.Add(end);
  23319. }
  23320. else
  23321. {
  23322. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  23323. {
  23324. threeCodeStr.Add(end);
  23325. }
  23326. else
  23327. {
  23328. threeCodeStr.Add(start);
  23329. threeCodeStr.Add(end);
  23330. }
  23331. }
  23332. }
  23333. //处理机票信息
  23334. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  23335. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  23336. if (start_Object == null)
  23337. {
  23338. start_Object = new Res_ThreeCode()
  23339. {
  23340. AirPort = empty,
  23341. AirPort_En = empty,
  23342. City = empty,
  23343. Country = empty,
  23344. Four = empty,
  23345. Three = empty,
  23346. };
  23347. }
  23348. if (end_Object == null)
  23349. {
  23350. end_Object = new Res_ThreeCode()
  23351. {
  23352. AirPort = empty,
  23353. AirPort_En = empty,
  23354. City = empty,
  23355. Country = empty,
  23356. Four = empty,
  23357. Three = empty,
  23358. };
  23359. }
  23360. //机型判断
  23361. string airModel = item["AirModel"].ToString();
  23362. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  23363. string flightTime = item["FlightTime"].ToString();
  23364. flightTime = ParseBlackTime(flightTime);
  23365. //航班号
  23366. string flightcode = item["Fliagtcode"].ToString();
  23367. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  23368. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  23369. if (aircompany == null)
  23370. {
  23371. aircompany = new Res_AirCompany
  23372. {
  23373. CnName = hsEmpty,
  23374. EnName = hsEmpty,
  23375. ShortCode = hsEmpty,
  23376. };
  23377. }
  23378. //航班前公务安排
  23379. if (tbSelect.First().Equals(item) && i != 0)
  23380. {
  23381. foreach (var takeoff in takeoffTimes)
  23382. {
  23383. var takeoffItem1 = NewData.AddHours(takeoff.Item1.Hour).AddMinutes(takeoff.Item1.Minute);
  23384. if (DateTime.Compare(takeOffTime, takeoffItem1) > 0)
  23385. {
  23386. foreach (var addTime in takeoff.Item2)
  23387. {
  23388. chiarr.Add(new Grp_ApprovalTravelDetails
  23389. {
  23390. Time = addTime,
  23391. CreateTime = DateTime.Now,
  23392. CreateUserId = dto.Userid,
  23393. ParentId = 0,
  23394. Details = "公务活动"
  23395. });
  23396. }
  23397. break;
  23398. }
  23399. }
  23400. }
  23401. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  23402. //trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName}{flightcode}飞往{end_Object.City}。\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  23403. //乘坐四川航空3U3901次航班由成都飞往加德满都,3小时25分钟
  23404. trip += $"乘坐{aircompany.CnName}{flightcode}次航班由{start_Object.City}飞往{end_Object.City},{flightTime}";
  23405. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  23406. if (isTrade)
  23407. {
  23408. //trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  23409. trip += "(转机不出机场)。";
  23410. }
  23411. //else
  23412. //{
  23413. // trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  23414. //}
  23415. chiarr.Add(new Grp_ApprovalTravelDetails
  23416. {
  23417. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  23418. CreateTime = DateTime.Now,
  23419. CreateUserId = dto.Userid,
  23420. ParentId = 0,
  23421. Details = trip
  23422. });
  23423. //最后一条到达的时间安排公务
  23424. if (tbSelect.Last().Equals(item) && i != timeArr.Count - 1)
  23425. {
  23426. bool isCheckCountry = false;
  23427. if (end_Object.Country != arriveCountry)
  23428. {
  23429. arriveCountry = end_Object.Country;
  23430. isCheckCountry = true;
  23431. }
  23432. if (nextDayNum == 0)
  23433. {
  23434. //需要入境的情况
  23435. if (isCheckCountry)
  23436. {
  23437. foreach (var fallTime in fallTimesCheckCountry)
  23438. {
  23439. var fallTimeItem1 = NewData.AddHours(fallTime.Item1.Hour).AddMinutes(fallTime.Item1.Minute);
  23440. if (DateTime.Compare(fallToTime, fallTimeItem1) < 0)
  23441. {
  23442. foreach (var addTime in fallTime.Item2)
  23443. {
  23444. chiarr.Add(new Grp_ApprovalTravelDetails
  23445. {
  23446. Time = addTime,
  23447. CreateTime = DateTime.Now,
  23448. CreateUserId = dto.Userid,
  23449. ParentId = 0,
  23450. Details = "公务活动"
  23451. });
  23452. }
  23453. break;
  23454. }
  23455. }
  23456. }
  23457. else
  23458. {
  23459. foreach (var fallTime in fallTimesNotCheckCountry)
  23460. {
  23461. var fallTimeItem1 = NewData.AddHours(fallTime.Item1.Hour).AddMinutes(fallTime.Item1.Minute);
  23462. if (DateTime.Compare(fallToTime, fallTimeItem1) < 0)
  23463. {
  23464. foreach (var addTime in fallTime.Item2)
  23465. {
  23466. chiarr.Add(new Grp_ApprovalTravelDetails
  23467. {
  23468. Time = addTime,
  23469. CreateTime = DateTime.Now,
  23470. CreateUserId = dto.Userid,
  23471. ParentId = 0,
  23472. Details = "公务活动"
  23473. });
  23474. }
  23475. break;
  23476. }
  23477. }
  23478. }
  23479. }
  23480. }
  23481. }
  23482. //添加乘车语句
  23483. //chiarr.Add(new Grp_ApprovalTravelDetails
  23484. //{
  23485. // Time = (fallToTime.AddHours(2.5).ToString("HH:mm") + "-" + fallToTime.AddHours(3).ToString("HH:mm")),
  23486. // CreateTime = DateTime.Now,
  23487. // CreateUserId = dto.Userid,
  23488. // ParentId = 0,
  23489. // Details = "乘车前往市区(约xx公里,大约需要xx分钟)"
  23490. //});
  23491. //if (i != timeArr.Count - 1)
  23492. //{
  23493. // fallToTime = fallToTime.AddHours(2.5);
  23494. // foreach (var item in Times)
  23495. // {
  23496. // //排列公务时间
  23497. // if (fallToTime.Hour < item.Item1)
  23498. // {
  23499. // chiarr.Add(new Grp_ApprovalTravelDetails
  23500. // {
  23501. // Time = $"{item.Item2} - {item.Item3}",
  23502. // CreateTime = DateTime.Now,
  23503. // CreateUserId = dto.Userid,
  23504. // ParentId = 0,
  23505. // Details = "公务活动"
  23506. // });
  23507. // }
  23508. // }
  23509. //}
  23510. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  23511. var last = threeCodeStr.Last();
  23512. foreach (var item in threeCodeStr)
  23513. {
  23514. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  23515. if (item.Equals(last))
  23516. {
  23517. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  23518. }
  23519. }
  23520. cityPath = cityPath.Trim('-');
  23521. }
  23522. else
  23523. {
  23524. foreach (var item in Times)
  23525. {
  23526. chiarr.Add(new Grp_ApprovalTravelDetails
  23527. {
  23528. Time = $"{item.Item2} - {item.Item3}",
  23529. CreateTime = DateTime.Now,
  23530. CreateUserId = dto.Userid,
  23531. ParentId = 0,
  23532. Details = "公务活动"
  23533. });
  23534. }
  23535. }
  23536. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  23537. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  23538. appro.Date = NewData.Month + "月" + NewData.Day + "日(" + week + ")" + "第" + intToString(i + 1) + "天 ";
  23539. appro.Diid = dto.Diid;
  23540. appro.CreateUserId = dto.Userid;
  23541. appro.CreateTime = DateTime.Now;
  23542. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  23543. appro.Id = thisId;
  23544. //foreach (var item in gwinfo)
  23545. //{
  23546. // Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  23547. // chi.Details = "拜访" + item.Client;
  23548. // if (!string.IsNullOrWhiteSpace(item.ReqSample))
  23549. // {
  23550. // chi.Details += "," + item.ReqSample;
  23551. // }
  23552. // chi.ParentId = thisId;
  23553. // chi.Time = item.Time;
  23554. // chiarr.Add(chi);
  23555. //}
  23556. if (chiarr.Count < 6)
  23557. {
  23558. for (int j = chiarr.Count; j < 6; j++)
  23559. {
  23560. chiarr.Add(new
  23561. Grp_ApprovalTravelDetails());
  23562. }
  23563. }
  23564. resultArr.Add(new
  23565. {
  23566. appro.Id,
  23567. appro.Date,
  23568. appro.Diid,
  23569. chiList = chiarr.Select(x1 => new
  23570. {
  23571. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  23572. x1.Details,
  23573. x1.ParentId,
  23574. x1.Id
  23575. })
  23576. });
  23577. }
  23578. _sqlSugar.CommitTran();
  23579. jw = JsonView(true, "生成成功!", resultArr);
  23580. }
  23581. catch (Exception ex)
  23582. {
  23583. jw.Code = 400;
  23584. jw.Msg = "生成失败!" + ex.Message;
  23585. }
  23586. return Ok(jw);
  23587. }
  23588. /// <summary>
  23589. /// 报批行程word导出
  23590. /// </summary>
  23591. /// <param name="dto"></param>
  23592. /// <returns></returns>
  23593. [HttpPost]
  23594. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  23595. {
  23596. var jw = JsonView(false);
  23597. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  23598. if (group == null)
  23599. {
  23600. jw.Msg = "暂无该团组!";
  23601. return Ok(jw);
  23602. }
  23603. //模板路径
  23604. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/";
  23605. var fileName = string.Empty;
  23606. string titleFont = string.Empty, timeFont = string.Empty, contentFont = string.Empty;
  23607. bool bold = false;
  23608. if (dto.FileIndex == 1)
  23609. {
  23610. fileName = "公务行程导出模板.docx"; //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  23611. }
  23612. else if (dto.FileIndex == 2)
  23613. {
  23614. fileName = "省外办-报批.docx";
  23615. bold = false;
  23616. titleFont = "方正黑体简体";
  23617. timeFont = "Times New Roman";
  23618. contentFont = "方正仿宋_GBK";
  23619. }
  23620. else if (dto.FileIndex == 3)
  23621. {
  23622. fileName = "市外办-报批.docx";
  23623. titleFont = "方正黑体简体";
  23624. timeFont = "Times New Roman";
  23625. contentFont = "方正仿宋简体";
  23626. }
  23627. tempPath = tempPath + fileName;
  23628. //载入模板
  23629. Document doc = new Document(tempPath);
  23630. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  23631. //获取所填表格的序数
  23632. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  23633. Aspose.Words.Tables.Row titleRowClone = null;
  23634. Aspose.Words.Tables.Row CenterRowClone = null;
  23635. int index = 0;
  23636. int indexChi = 0;
  23637. int SetIndex = 0;
  23638. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  23639. //获取数据,放到datatable
  23640. foreach (var item in ApprovalTravelArr)
  23641. {
  23642. if (index > 0)
  23643. {
  23644. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  23645. tableOne.AppendChild(titleRowClone);
  23646. }
  23647. var textTime = item.Date;
  23648. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  23649. SetCells(tableOne, doc, SetIndex, 0, textTime, titleFont, bold);
  23650. SetIndex++;
  23651. if (ChiRep.Count > 0)
  23652. {
  23653. foreach (var itemChi in ChiRep)
  23654. {
  23655. var txtTime = itemChi.Time;
  23656. var txtDetail = itemChi.Details;
  23657. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  23658. {
  23659. //SetCells(tableOne, doc, SetIndex, 0, "", timeFont, bold);
  23660. //SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  23661. //indexChi++;
  23662. //SetIndex++;
  23663. break;
  23664. }
  23665. if (indexChi > 0)
  23666. {
  23667. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  23668. tableOne.AppendChild(CenterRowClone);
  23669. }
  23670. SetCells(tableOne, doc, SetIndex, 0, txtTime, timeFont, bold);
  23671. SetCells(tableOne, doc, SetIndex, 1, txtDetail, contentFont, bold);
  23672. indexChi++;
  23673. SetIndex++;
  23674. }
  23675. }
  23676. //else
  23677. //{
  23678. // if (indexChi > 0)
  23679. // {
  23680. // CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  23681. // tableOne.AppendChild(CenterRowClone);
  23682. // }
  23683. // SetCells(tableOne, doc, SetIndex, 0, "",timeFont, bold);
  23684. // SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  23685. // indexChi++;
  23686. // SetIndex++;
  23687. //}
  23688. index++;
  23689. }
  23690. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + fileName;
  23691. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName, Aspose.Words.SaveFormat.Docx); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  23692. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  23693. jw.Code = 200;
  23694. jw.Msg = "";
  23695. return Ok(jw);
  23696. }
  23697. private string ParseBlackTime(string time)
  23698. {
  23699. // 匹配可能只有分钟的情况
  23700. string pattern = @"(?:(\d+)H)?(?:(\d+)M)?";
  23701. System.Text.RegularExpressions.Match match = Regex.Match(time, pattern);
  23702. if (match.Success)
  23703. {
  23704. string hours = match.Groups[1].Value;
  23705. string minutes = match.Groups[2].Value;
  23706. // 如果小时部分为空,则只显示分钟
  23707. if (string.IsNullOrEmpty(hours))
  23708. {
  23709. return $"{minutes}分钟";
  23710. }
  23711. // 如果分钟部分为空,则只显示小时
  23712. else if (string.IsNullOrEmpty(minutes))
  23713. {
  23714. return $"{hours}小时";
  23715. }
  23716. // 否则显示完整格式
  23717. else
  23718. {
  23719. return $"{hours}小时{minutes}分钟";
  23720. }
  23721. }
  23722. else
  23723. {
  23724. return "未知时长";
  23725. }
  23726. }
  23727. private string intToString(int numberVal)
  23728. {
  23729. string numberval = numberVal.ToString();
  23730. Dictionary<char, string> Number = new Dictionary<char, string>();
  23731. Number.Add('1', "一");
  23732. Number.Add('2', "二");
  23733. Number.Add('3', "三");
  23734. Number.Add('4', "四");
  23735. Number.Add('5', "五");
  23736. Number.Add('6', "六");
  23737. Number.Add('7', "七");
  23738. Number.Add('8', "八");
  23739. Number.Add('9', "九");
  23740. string stringNumberVal = string.Empty;
  23741. for (int i = 0; i < numberval.Length; i++)
  23742. {
  23743. if (i == 0)
  23744. {
  23745. stringNumberVal += Number[numberval[i]];
  23746. }
  23747. else if (i >= 1)
  23748. {
  23749. if (numberval[i] == '0')
  23750. {
  23751. stringNumberVal = "十";
  23752. }
  23753. else
  23754. {
  23755. stringNumberVal += "十" + Number[numberval[i]];
  23756. }
  23757. }
  23758. }
  23759. return stringNumberVal;
  23760. }
  23761. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val, string font, bool bold)
  23762. {
  23763. //获取table中的某个单元格,从0开始
  23764. Cell lshCell = table.Rows[rows].Cells[cells];
  23765. //将单元格中段落移除
  23766. foreach (Paragraph item in lshCell.Paragraphs)
  23767. {
  23768. lshCell.Paragraphs.Remove(item);
  23769. }
  23770. if (val.Contains("\r\n"))
  23771. {
  23772. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  23773. foreach (var item in spArr)
  23774. {
  23775. //新建一个段落
  23776. Paragraph p = new Paragraph(doc);
  23777. var r = new Run(doc, item);
  23778. //设置字体
  23779. if (!string.IsNullOrEmpty(font))
  23780. {
  23781. r.Font.Name = font;
  23782. }
  23783. r.Font.Bold = bold;
  23784. //把设置的值赋给之前新建的段落
  23785. p.AppendChild(r);
  23786. //将此段落加到单元格内
  23787. lshCell.AppendChild(p);
  23788. }
  23789. }
  23790. else
  23791. {
  23792. //新建一个段落
  23793. Paragraph p = new Paragraph(doc);
  23794. var r = new Run(doc, val);
  23795. //设置字体
  23796. if (!string.IsNullOrEmpty(font))
  23797. {
  23798. r.Font.Name = font;
  23799. }
  23800. r.Font.Bold = bold;
  23801. //把设置的值赋给之前新建的段落
  23802. p.AppendChild(r);
  23803. //将此段落加到单元格内
  23804. lshCell.AppendChild(p);
  23805. }
  23806. }
  23807. /// <summary>
  23808. /// 报批行程AI续写
  23809. /// </summary>
  23810. /// <returns></returns>
  23811. [HttpPost]
  23812. public async Task<IActionResult> ApprovalJourneyAiWrite(ApprovalJourneyAiWriteDto dto)
  23813. {
  23814. var jw = JsonView(false);
  23815. if (dto.ClientPurpose.IsNullOrWhiteSpace() || dto.ClientName.IsNullOrWhiteSpace())
  23816. {
  23817. jw.Msg = "参数有误!";
  23818. return Ok(jw);
  23819. }
  23820. KiMiApiClient kiMi = new KiMiApiClient();
  23821. List<SeedMessages> messages = new List<SeedMessages>() {
  23822. new SeedMessages
  23823. {
  23824. Role = KimiRole.system,
  23825. Content = "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长中文和英文的对话。你会为用户提供安全,有帮助,准确的回答。"
  23826. },
  23827. new SeedMessages
  23828. {
  23829. Role = KimiRole.user,
  23830. Content = $@"参考这个模板格式来编写一份{dto.ClientName}拜访{dto.ClientPurpose},结合{dto.ClientName}的业务,描述拜访目的,字数在200字内(直接给出拜访目的,不输出其他内容)"
  23831. }
  23832. };
  23833. var kimi_result = await kiMi.SeedMessageByFullConterObject(messages);
  23834. string data = kimi_result.Choices[0]?.Message.Content;
  23835. if (string.IsNullOrWhiteSpace(data))
  23836. {
  23837. jw.Data = "Ai续写失败!";
  23838. }
  23839. else
  23840. {
  23841. jw = JsonView(true, "success!", data);
  23842. }
  23843. return Ok(jw);
  23844. }
  23845. #endregion
  23846. #region 团组接待意见调查
  23847. /// <summary>
  23848. /// 团组接待意见调查 - 信息管理
  23849. /// 基础数据(团组)
  23850. /// </summary>
  23851. /// <returns></returns>
  23852. [HttpGet]
  23853. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23854. public async Task<IActionResult> OpinionaireInit()
  23855. {
  23856. var groupData = await _groupRepository.Query(x => x.IsDel == 0)
  23857. .Select(x => new
  23858. {
  23859. x.Id,
  23860. GroupName = $"[{x.VisitDate.ToString("yyyy-MM-dd")}]{x.TeamName}"
  23861. })
  23862. .OrderByDescending(x => x.Id)
  23863. .ToListAsync();
  23864. return Ok(JsonView(groupData, groupData.Count));
  23865. }
  23866. /// <summary>
  23867. /// 团组接待意见调查 - 信息管理
  23868. /// 列表
  23869. /// </summary>
  23870. /// <param name="groupId"></param>
  23871. /// <returns></returns>
  23872. [HttpGet("{groupId}")]
  23873. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23874. public async Task<IActionResult> OpinionaireManageList(int groupId)
  23875. {
  23876. if (groupId < 1) Ok(JsonView(false, "请传入有效的diId"));
  23877. var data = await _opinionaireRep.Query(x => x.DiId == groupId)
  23878. .Select(x => new
  23879. {
  23880. x.Id,
  23881. x.TourGuideName,
  23882. x.CityName,
  23883. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x.CreateUserId == x1.Id).Select(x1 => x1.CnName),
  23884. x.CreateTime
  23885. })
  23886. .OrderBy(x => x.Id)
  23887. .ToListAsync();
  23888. return Ok(JsonView(data));
  23889. }
  23890. /// <summary>
  23891. /// 团组接待意见调查 - 信息管理
  23892. /// 保存
  23893. /// </summary>
  23894. /// <param name="dto"></param>
  23895. /// <returns></returns>
  23896. [HttpPost]
  23897. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23898. public async Task<IActionResult> OpinionaireManageSave(OpinionaireManageSaveDto dto)
  23899. {
  23900. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  23901. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  23902. if (dto.DiId < 1) Ok(JsonView(false, "请传入有效的diId"));
  23903. if (dto.Items.Length < 1) Ok(JsonView(false, "请传入需要保存的信息"));
  23904. var addData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id == 0).ToList());
  23905. var updData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id > 0).ToList());
  23906. _opinionaireRep.BeginTran();
  23907. if (addData != null && addData.Count > 0)
  23908. {
  23909. foreach (var item in addData)
  23910. {
  23911. item.CreateUserId = currUserInfo.UserId;
  23912. item.DiId = dto.DiId;
  23913. }
  23914. var add = await _opinionaireRep._sqlSugar.Insertable(addData).ExecuteCommandAsync();
  23915. }
  23916. if (updData != null && updData.Count > 0)
  23917. {
  23918. var upd = await _opinionaireRep._sqlSugar
  23919. .Updateable(updData)
  23920. .UpdateColumns(x => new { x.CityName, x.TourGuideName })
  23921. .WhereColumns(x => new { x.Id })
  23922. .ExecuteCommandAsync();
  23923. }
  23924. _opinionaireRep.CommitTran();
  23925. return Ok(JsonView("操作成功!"));
  23926. }
  23927. /// <summary>
  23928. /// 团组接待意见调查 - 信息管理
  23929. /// 删除
  23930. /// </summary>
  23931. /// <param name="id"></param>
  23932. /// <returns></returns>
  23933. [HttpDelete("{id}")]
  23934. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23935. public async Task<IActionResult> OpinionaireManageDel(int id)
  23936. {
  23937. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  23938. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  23939. if (id < 1) Ok(JsonView(false, "请传入有效的id"));
  23940. var del = await _opinionaireRep.SoftDeleteAsync(x => x.Id == id, currUserInfo.UserId);
  23941. if (!del) return Ok(JsonView("操作失败!"));
  23942. return Ok(JsonView("操作成功!"));
  23943. }
  23944. /// <summary>
  23945. /// 团组接待意见调查 - 用户
  23946. /// 列表
  23947. /// </summary>
  23948. /// <param name="diId"></param>
  23949. /// <returns></returns>
  23950. [HttpGet("{diId}")]
  23951. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23952. public async Task<IActionResult> OpinionaireUserList(int diId)
  23953. {
  23954. if (diId < 1) Ok(JsonView(false, "请传入有效的diId"));
  23955. var sql = string.Format(@"
  23956. SELECT
  23957. o.Id,
  23958. o.DiId,
  23959. di.TeamName AS 'GroupName',
  23960. di.VisitPNumber AS 'PeopleNumber',
  23961. di.ClientName AS 'LeadGroup',
  23962. di.VisitCountry AS 'Travel',
  23963. di.VisitDays AS 'Days',
  23964. o.CityName,
  23965. o.TourGuideName,
  23966. o.Catering,
  23967. o.CateringReason,
  23968. o.Stay,
  23969. o.StayReason,
  23970. o.[Route],
  23971. o.RouteReason,
  23972. o.OfficialActivity,
  23973. o.OfficialActivityReason,
  23974. o.TourGuide,
  23975. o.TourGuideReason,
  23976. o.[Translate],
  23977. o.TranslateReason,
  23978. o.Trip,
  23979. o.TripReason,
  23980. o.ESFileName,
  23981. o.SignatureDate,
  23982. o.Remark
  23983. FROM
  23984. Grp_Opinionaire o
  23985. LEFT JOIN Grp_DelegationInfo di ON o.DiId = di.Id
  23986. WHERE
  23987. o.IsDel = 0
  23988. AND o.DiId = {0}
  23989. ORDER BY
  23990. o.Id ASC", diId);
  23991. var data = await _sqlSugar.SqlQueryable<OpinionaireUserListView>(sql).ToListAsync();
  23992. if (data.Count < 1) return Ok(JsonView(false, "暂无数据"));
  23993. return Ok(JsonView(data));
  23994. }
  23995. /// <summary>
  23996. /// 团组接待意见调查 - 用户
  23997. /// 保存
  23998. /// </summary>
  23999. /// <param name="dto"></param>
  24000. /// <returns></returns>
  24001. [HttpPost]
  24002. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  24003. public async Task<IActionResult> OpinionaireUserSave([FromForm] OpinionaireUserSaveInfo[] dto)
  24004. {
  24005. if (dto.Length < 1) Ok(JsonView(false, "请传入有效的参数"));
  24006. foreach (var item in dto)
  24007. {
  24008. if (string.IsNullOrEmpty(item.Catering)) Ok(JsonView(false, "请选择餐饮评分!"));
  24009. if (string.IsNullOrEmpty(item.Stay)) Ok(JsonView(false, "请选择住宿评分!"));
  24010. if (string.IsNullOrEmpty(item.Route)) Ok(JsonView(false, "请选择行程评分!"));
  24011. if (string.IsNullOrEmpty(item.OfficialActivity)) Ok(JsonView(false, "请选择公务活动评分!"));
  24012. if (string.IsNullOrEmpty(item.Translate)) Ok(JsonView(false, "请选择翻译评分!"));
  24013. if (string.IsNullOrEmpty(item.Trip)) Ok(JsonView(false, "请选择行程评分!"));
  24014. if (string.IsNullOrEmpty(item.SignatureDate)) Ok(JsonView(false, "请填写签名日期!"));
  24015. if (item.File.Length < 1) Ok(JsonView(false, "请上传签名图片!"));
  24016. }
  24017. var filePathBase = $"{AppSettingsHelper.Get("GrpFileBasePath")}OpinionaireElectronicSignature";
  24018. if (!Directory.Exists(filePathBase))
  24019. {
  24020. Directory.CreateDirectory(filePathBase);
  24021. }
  24022. #region 上传文件
  24023. var filePaths = new List<string>();
  24024. foreach (var item in dto)
  24025. {
  24026. var file = item.File;
  24027. // 将文件保存到指定位置
  24028. var filePath = Path.Combine(filePathBase, file.FileName);
  24029. using (var stream = new FileStream(filePath, FileMode.Create))
  24030. {
  24031. await file.CopyToAsync(stream);
  24032. }
  24033. //验证文件是否上传成功
  24034. if (!System.IO.File.Exists(filePath))
  24035. {
  24036. foreach (var filePathStr in filePaths)
  24037. {
  24038. System.IO.File.Delete(filePathStr);
  24039. }
  24040. return Ok(JsonView(false, "文件上传失败!"));
  24041. }
  24042. item.ESFileName = file.FileName;
  24043. }
  24044. #endregion
  24045. var infos = _mapper.Map<List<Grp_Opinionaire>>(dto);
  24046. var upd = await _sqlSugar.Updateable<Grp_Opinionaire>(infos)
  24047. .UpdateColumns(x => new
  24048. {
  24049. x.Catering,
  24050. x.CateringReason,
  24051. x.Stay,
  24052. x.StayReason,
  24053. x.Route,
  24054. x.RouteReason,
  24055. x.OfficialActivity,
  24056. x.OfficialActivityReason,
  24057. x.TourGuide,
  24058. x.TourGuideReason,
  24059. x.Translate,
  24060. x.TranslateReason,
  24061. x.Trip,
  24062. x.TripReason,
  24063. x.ESFileName,
  24064. x.SignatureDate,
  24065. x.Remark
  24066. })
  24067. .WhereColumns(x => new { x.Id })
  24068. .ExecuteCommandAsync();
  24069. if (upd < 1)
  24070. {
  24071. foreach (var filePathStr in filePaths)
  24072. {
  24073. System.IO.File.Delete(filePathStr);
  24074. }
  24075. return Ok(JsonView(false));
  24076. }
  24077. return Ok(JsonView(true));
  24078. }
  24079. #endregion
  24080. #region 团组餐厅相关信息
  24081. /// <summary>
  24082. /// 团组相关餐厅信息
  24083. /// 基础数据(团组)
  24084. /// </summary>
  24085. /// <returns></returns>
  24086. [HttpGet]
  24087. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  24088. public async Task<IActionResult> RestaurantInit()
  24089. {
  24090. return Ok(await _restaurantRep.InitAsync());
  24091. }
  24092. /// <summary>
  24093. /// 团组相关餐厅信息
  24094. /// Item
  24095. /// </summary>
  24096. /// <param name="dto"></param>
  24097. /// <returns></returns>
  24098. [HttpPost]
  24099. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  24100. public async Task<IActionResult> RestaurantItem(RestaurantItemDto dto)
  24101. {
  24102. int portType = dto.PortType,
  24103. groupId = dto.GroupId;
  24104. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  24105. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  24106. return Ok(await _restaurantRep.ItemAsync(portType, groupId));
  24107. }
  24108. /// <summary>
  24109. /// 团组相关餐厅信息
  24110. /// List
  24111. /// </summary>
  24112. /// <param name="dto"></param>
  24113. /// <returns></returns>
  24114. [HttpPost]
  24115. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  24116. public async Task<IActionResult> RestaurantList(RestaurantItemDto dto)
  24117. {
  24118. int portType = dto.PortType,
  24119. groupId = dto.GroupId;
  24120. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  24121. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  24122. var sql = string.Format(@" SELECT
  24123. ri.Id,
  24124. ri.GroupId,
  24125. ri.Date,
  24126. ri.StartTime,
  24127. ri.EndTime,
  24128. CASE WHEN ri.Type = 1 THEN '早餐'
  24129. WHEN ri.Type = 2 THEN '午餐'
  24130. WHEN ri.Type = 3 THEN '晚餐'
  24131. ELSE '其他'
  24132. END AS 'Type',
  24133. ri.Name,
  24134. ri.Address,
  24135. ri.Tel,
  24136. ri.Remark,
  24137. ri.CreateTime,
  24138. u.CnName AS CreateUserName
  24139. FROM
  24140. Grp_RestaurantInfo ri
  24141. LEFT JOIN Sys_Users u ON ri.CreateUserId = u.Id
  24142. WHERE
  24143. ri.IsDel = 0
  24144. AND ri.GroupId = {0}
  24145. ORDER BY
  24146. ri.Date ASC
  24147. ", groupId);
  24148. var infos = await _sqlSugar.SqlQueryable<RestaurantItemView>(sql).ToListAsync();
  24149. if (!infos.Any()) Ok(JsonView(false, "数据未填写!"));
  24150. return Ok(JsonView(infos));
  24151. }
  24152. /// <summary>
  24153. /// 团组相关餐厅信息
  24154. /// Info
  24155. /// </summary>
  24156. /// <param name="dto"></param>
  24157. /// <returns></returns>
  24158. [HttpPost]
  24159. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  24160. public async Task<IActionResult> RestaurantInfo(RestaurantInfoDto dto)
  24161. {
  24162. int portType = dto.PortType,
  24163. id = dto.Id;
  24164. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  24165. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  24166. return Ok(await _restaurantRep.InfoAsync(portType, id));
  24167. }
  24168. /// <summary>
  24169. /// 团组相关餐厅信息
  24170. /// Op
  24171. /// </summary>
  24172. /// <param name="dto"></param>
  24173. /// <returns></returns>
  24174. [HttpPost]
  24175. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  24176. public async Task<IActionResult> RestaurantOp(RestaurantOpDto dto)
  24177. {
  24178. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  24179. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  24180. if (string.IsNullOrEmpty(dto.Name)) return Ok(JsonView(false, "餐厅名称为空!"));
  24181. return Ok(await _restaurantRep.OpAsync(dto));
  24182. }
  24183. /// <summary>
  24184. /// 团组相关餐厅信息
  24185. /// Del
  24186. /// </summary>
  24187. /// <param name="dto"></param>
  24188. /// <returns></returns>
  24189. [HttpPost]
  24190. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  24191. public async Task<IActionResult> RestaurantDel(RestaurantDelDto dto)
  24192. {
  24193. int userId = dto.DeleteUserId;
  24194. var id = dto.Id;
  24195. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  24196. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  24197. return Ok(await _restaurantRep.DelAsync(dto));
  24198. }
  24199. #endregion
  24200. #region 团组会务成本
  24201. /// <summary>
  24202. /// 团组会务成本数据初始化
  24203. /// </summary>
  24204. /// <returns></returns>
  24205. [HttpPost]
  24206. public async Task<IActionResult> ConferenceAffairsInIt(ConferenceAffairsInItDto Dto)
  24207. {
  24208. var expr = _sqlSugar.Queryable<Grp_DelegationInfo>()
  24209. .OrderByDescending(x => x.CreateTime)
  24210. .Where(x => x.IsDel == 0)
  24211. .Select<DelegationEasyView>();
  24212. DelegationEasyView di = Dto.GroupId == 0 ?
  24213. expr.First() :
  24214. expr.First(x => x.Id == Dto.GroupId);
  24215. if (di == null)
  24216. {
  24217. return Ok(JsonView(false, "团组信息不存在!"));
  24218. }
  24219. var typeData = await _sqlSugar.Queryable<Sys_SetData>()
  24220. .Where(x => x.IsDel == 0 && x.STid == 21)
  24221. .Select(x => new { x.Id, Text = x.Name })
  24222. .ToListAsync();
  24223. var hwids = _sqlSugar.Queryable<Sys_SetData>()
  24224. .Where(x => x.IsDel == 0 && x.STid == 10 && x.Name.Contains("会务活动"))
  24225. .Select(x => x.Id)
  24226. .ToList();
  24227. //仅检索会务团组
  24228. var groupList = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  24229. .Where(x => x.IsDel == 0 && hwids.Contains(x.TeamDid))
  24230. .OrderByDescending(x => x.VisitDate)
  24231. .Select(x => new { x.Id, x.TeamName })
  24232. .ToListAsync();
  24233. var currenyList = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(1, di.Id, 98);
  24234. var userList = await _sqlSugar.Queryable<Sys_Users>()
  24235. .Where(x => x.IsDel == 0)
  24236. .Select(x => new { x.Id, x.CnName })
  24237. .ToListAsync();
  24238. var units = await _sqlSugar.Queryable<Sys_SetData>()
  24239. .Where(x => x.IsDel == 0 && x.STid == 119)
  24240. .Select(x => new { x.Id, Text = x.Name })
  24241. .ToListAsync();
  24242. var FileType = new[]
  24243. {
  24244. new { Id = 0 , Name = "成本下载" },
  24245. new { Id = 1 , Name = "报价下载" },
  24246. new { Id = 2 , Name = "总表下载" },
  24247. };
  24248. var GM = new List<int>();
  24249. var permissionControlDB = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1448)?.Remark;
  24250. try
  24251. {
  24252. GM = JsonConvert.DeserializeObject<List<int>>(permissionControlDB);
  24253. }
  24254. catch (Exception ex)
  24255. {
  24256. GM = new List<int>() { 21 };
  24257. }
  24258. var isReview = Dto.UserId == 21;
  24259. var isGM = GM.Contains(Dto.UserId);
  24260. var ConferenceAffairsCost = _sqlSugar.Queryable<Grp_ConferenceAffairsCost>()
  24261. .Where(x => x.IsDel == 0)
  24262. .Select<ConferenceAffairsCostView>()
  24263. .First(x => x.Diid == di.Id);
  24264. if (ConferenceAffairsCost == null)
  24265. {
  24266. ConferenceAffairsCost = new ConferenceAffairsCostView();
  24267. ConferenceAffairsCost.Diid = di.Id;
  24268. }
  24269. #region 权限校验
  24270. var ids = _sqlSugar.Queryable<Grp_ConferenceAffairsCostControl>()
  24271. .Where(x => x.Diid == di.Id && x.IsDel == 0)
  24272. .Select(x => x.UserId)
  24273. .Distinct()
  24274. .ToList();
  24275. if (!ids.Contains(Dto.UserId) && !isGM)
  24276. {
  24277. return Ok(JsonView(201, "暂无权限!", new
  24278. {
  24279. typeData,
  24280. groupList,
  24281. currenyList,
  24282. isGM,
  24283. userList,
  24284. units,
  24285. isReview,
  24286. operatorUser = ids,
  24287. di,
  24288. FileType
  24289. }));
  24290. }
  24291. #endregion
  24292. var ConferenceAffairsCostChi = _sqlSugar.Queryable<Grp_ConferenceAffairsCostChild>()
  24293. .Where(x => x.IsDel == 0 && x.Diid == di.Id)
  24294. .Select<ConferenceAffairsCostChildView>()
  24295. .OrderBy(x => x.Index)
  24296. .ToList();
  24297. for (int i = 1; i <= ConferenceAffairsCostChi.Count; i++)
  24298. {
  24299. ConferenceAffairsCostChi[i - 1].Index = i;
  24300. }
  24301. var backData = new
  24302. {
  24303. ConferenceAffairsCost,
  24304. ConferenceAffairsCostChi,
  24305. typeData,
  24306. groupList,
  24307. currenyList,
  24308. isGM,
  24309. userList,
  24310. units,
  24311. isReview,
  24312. operatorUser = ids,
  24313. di,
  24314. FileType
  24315. };
  24316. return Ok(JsonView(true, "SUCCESS", backData));
  24317. }
  24318. /// <summary>
  24319. /// 会务成本保存
  24320. /// </summary>
  24321. /// <returns></returns>
  24322. [HttpPost]
  24323. public async Task<IActionResult> ConferenceAffairsSave(ConferenceAffairsSaveDto Dto)
  24324. {
  24325. _sqlSugar.BeginTran();
  24326. var data = _mapper.Map<Grp_ConferenceAffairsCost>(Dto.ConferenceAffairsCost);
  24327. var childResult = new
  24328. {
  24329. success = 0,
  24330. error = 0
  24331. };
  24332. try
  24333. {
  24334. if (data.Id == 0)
  24335. {
  24336. _sqlSugar.Updateable<Grp_ConferenceAffairsCost>()
  24337. .Where(x => x.Diid == Dto.GroupId)
  24338. .SetColumns(x => new Grp_ConferenceAffairsCost
  24339. {
  24340. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  24341. DeleteUserId = Dto.UserId
  24342. })
  24343. .ExecuteCommand();
  24344. data.Diid = Dto.GroupId;
  24345. data.CreateTime = DateTime.Now;
  24346. data.CreateUserId = Dto.UserId;
  24347. data.Id = _sqlSugar.Insertable<Grp_ConferenceAffairsCost>(data)
  24348. .ExecuteReturnIdentity();
  24349. }
  24350. else
  24351. {
  24352. _sqlSugar.Updateable<Grp_ConferenceAffairsCost>(data)
  24353. .ExecuteCommand();
  24354. data.Id = data.Id;
  24355. }
  24356. if (Dto.ConferenceAffairsCostChild.Any())
  24357. {
  24358. var datas = _mapper.Map<List<Grp_ConferenceAffairsCostChild>>(Dto.ConferenceAffairsCostChild);
  24359. var insertArr = datas.Where(x => x.Id == 0).ToList();
  24360. var updateArr = datas.Where(x => x.Id != 0 && x.ReviewStatus != 1).ToList();
  24361. var notUpdateArr = datas.Where(x => x.Id != 0 && x.ReviewStatus == 1).ToList();
  24362. insertArr.ForEach(x => { x.Diid = Dto.GroupId; x.ConferenceAffairsCostId = data.Id; });
  24363. var inrsetCount = insertArr.Any() ? _sqlSugar.Insertable<Grp_ConferenceAffairsCostChild>(insertArr).ExecuteCommand() : 0;
  24364. var updateCount = updateArr.Any() ? _sqlSugar.Updateable<Grp_ConferenceAffairsCostChild>(updateArr)
  24365. .IgnoreColumns(x => new { x.ConferenceAffairsCostId })
  24366. .ExecuteCommand() : 0;
  24367. childResult = childResult with
  24368. {
  24369. error = notUpdateArr.Count(),
  24370. success = inrsetCount + updateCount
  24371. };
  24372. }
  24373. _sqlSugar.CommitTran();
  24374. }
  24375. catch (Exception ex)
  24376. {
  24377. _sqlSugar.RollbackTran();
  24378. return Ok(JsonView(false, "失败!" + ex.Message));
  24379. }
  24380. return Ok(JsonView(true, "操作成功!", childResult));
  24381. }
  24382. [HttpPost]
  24383. public async Task<IActionResult> ConferenceAffairsAudit(ConferenceAffairsAuditDto Dto)
  24384. {
  24385. var count = 0;
  24386. if (Dto.ConferenceAffairsCostChildids.Any())
  24387. {
  24388. count = _sqlSugar.Updateable<Grp_ConferenceAffairsCostChild>().
  24389. Where(x => Dto.ConferenceAffairsCostChildids.Contains(x.Id)).
  24390. SetColumns(x => new Grp_ConferenceAffairsCostChild
  24391. {
  24392. ReviewStatus = Dto.ReviewStatus
  24393. }).
  24394. ExecuteCommand();
  24395. }
  24396. return Ok(JsonView(true, "操作成功!", count));
  24397. }
  24398. /// <summary>
  24399. /// 会务成本所有数据清除
  24400. /// </summary>
  24401. /// <param name="Dto"></param>
  24402. /// <returns></returns>
  24403. [HttpPost]
  24404. public async Task<IActionResult> ConferenceAffairsDelete(ConferenceAffairsDeleteDto Dto)
  24405. {
  24406. if (Dto.GroupId < 1) return Ok(JsonView(false, "请传入有效的Id"));
  24407. if (Dto.UserId < 1) return Ok(JsonView(false, "请传入有效的用户Id"));
  24408. _sqlSugar.BeginTran();
  24409. try
  24410. {
  24411. var delCount = _sqlSugar.Updateable<Grp_ConferenceAffairsCost>()
  24412. .Where(x => x.Diid == Dto.GroupId)
  24413. .SetColumns(x => new Grp_ConferenceAffairsCost
  24414. {
  24415. IsDel = 1,
  24416. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  24417. DeleteUserId = Dto.UserId
  24418. })
  24419. .ExecuteCommand();
  24420. if (delCount > 0)
  24421. {
  24422. _sqlSugar.Updateable<Grp_ConferenceAffairsCostChild>()
  24423. .Where(x => x.Diid == Dto.GroupId)
  24424. .SetColumns(x => new Grp_ConferenceAffairsCostChild
  24425. {
  24426. IsDel = 1,
  24427. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  24428. DeleteUserId = Dto.UserId
  24429. })
  24430. .ExecuteCommand();
  24431. _sqlSugar.Updateable<Grp_ConferenceAffairsCostControl>()
  24432. .Where(x => x.Diid == Dto.GroupId && x.IsDel == 0)
  24433. .SetColumns(x => new Grp_ConferenceAffairsCostControl
  24434. {
  24435. IsDel = 1,
  24436. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  24437. DeleteUserId = Dto.UserId
  24438. })
  24439. .ExecuteCommand();
  24440. }
  24441. _sqlSugar.CommitTran();
  24442. }
  24443. catch (Exception ex)
  24444. {
  24445. _sqlSugar.RollbackTran();
  24446. return Ok(JsonView(false, "操作失败!" + ex.Message));
  24447. }
  24448. return Ok(JsonView(true, "操作成功!"));
  24449. }
  24450. /// <summary>
  24451. /// 子项数据删除
  24452. /// </summary>
  24453. /// <param name="Dto"></param>
  24454. /// <returns></returns>
  24455. [HttpPost]
  24456. public async Task<IActionResult> ConferenceAffairSinglesDelete(ConferenceAffairsDeleteSingleDto Dto)
  24457. {
  24458. var isAudit = _sqlSugar.Queryable<Grp_ConferenceAffairsCostChild>().Where(x => x.IsDel == 0 && Dto.ids.Contains(x.Id))
  24459. .Any(x => x.ReviewStatus == 1);
  24460. if (isAudit) return Ok(JsonView(false, "包含已审核数据无法删除!"));
  24461. var count = _sqlSugar.Updateable<Grp_ConferenceAffairsCostChild>()
  24462. .Where(x => Dto.ids.Contains(x.Id) && x.IsDel == 0)
  24463. .SetColumns(x => new Grp_ConferenceAffairsCostChild
  24464. {
  24465. IsDel = 1,
  24466. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  24467. DeleteUserId = Dto.UserId
  24468. })
  24469. .ExecuteCommand();
  24470. return Ok(JsonView(true, "SUCCESS!", count));
  24471. }
  24472. /// <summary>
  24473. /// 会务成本权限分配
  24474. /// </summary>
  24475. /// <param name="Dto"></param>
  24476. /// <returns></returns>
  24477. [HttpPost]
  24478. public async Task<IActionResult> PermissionSetting(PermissionSettingDto Dto)
  24479. {
  24480. _sqlSugar.BeginTran();
  24481. var count = 0;
  24482. try
  24483. {
  24484. _sqlSugar.Updateable<Grp_ConferenceAffairsCostControl>()
  24485. .Where(x => x.Diid == Dto.GroupId && x.IsDel == 0)
  24486. .SetColumns(x => new Grp_ConferenceAffairsCostControl
  24487. {
  24488. IsDel = 1,
  24489. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  24490. DeleteUserId = Dto.CreateUserId
  24491. })
  24492. .ExecuteCommand();
  24493. count = _sqlSugar.Insertable<Grp_ConferenceAffairsCostControl>(Dto.UserIds.Select(x => new Grp_ConferenceAffairsCostControl
  24494. {
  24495. CreateTime = DateTime.Now,
  24496. CreateUserId = Dto.CreateUserId,
  24497. UserId = x,
  24498. Diid = Dto.GroupId,
  24499. }).ToList()).ExecuteCommand();
  24500. _sqlSugar.CommitTran();
  24501. }
  24502. catch (Exception ex)
  24503. {
  24504. _sqlSugar.RollbackTran();
  24505. return Ok(JsonView(false, "操作失败!" + ex.Message));
  24506. }
  24507. return Ok(JsonView(true, "操作成功!", count));
  24508. }
  24509. /// <summary>
  24510. /// 团组会务成本文件下载
  24511. /// </summary>
  24512. /// <returns></returns>
  24513. [HttpPost]
  24514. public async Task<IActionResult> ConferenceAffairsFileDown(ConferenceAffairsFileDownDto Dto)
  24515. {
  24516. var FileType = new[]
  24517. {
  24518. new { Id = 0 , Name = "成本下载" },
  24519. new { Id = 1 , Name = "报价下载" },
  24520. new { Id = 2 , Name = "总表下载" },
  24521. };
  24522. if (Dto.GroupId < 1) return Ok(JsonView(false, "请传入有效的Id"));
  24523. if (Dto.FileTypeId < 0 || Dto.FileTypeId > 2) return Ok(JsonView(false, "请传入有效的文件类型"));
  24524. var di = _sqlSugar.Queryable<Grp_DelegationInfo>()
  24525. .Where(x => x.IsDel == 0 && x.Id == Dto.GroupId)
  24526. .Select<DelegationEasyView>()
  24527. .First();
  24528. var main = _sqlSugar.Queryable<Grp_ConferenceAffairsCost>()
  24529. .First(x => x.Diid == Dto.GroupId && x.IsDel == 0);
  24530. if (main == null)
  24531. {
  24532. return Ok(JsonView(false, "团组会务成本信息不存在!"));
  24533. }
  24534. JsonView jw = JsonView(false);
  24535. //总表下载
  24536. var loadPath = $"{AppSettingsHelper.Get("ExcelBasePath")}ConferenceAffairs/template/";
  24537. var outputPath = $"{AppSettingsHelper.Get("ExcelBasePath")}ConferenceAffairs/output/total/";
  24538. var networkPath = outputPath.Replace(AppSettingsHelper.Get("ExcelBasePath"), AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath"));
  24539. var field = string.Empty;
  24540. var fileTypeName = string.Empty;
  24541. field = @$"
  24542. a.[Index],a.PriceName,a.CostPrice,a.Count,a.Coefficient,a.BaoJiaPrice,a.AddedValue,a.Details,a.Remark,a.Rate,
  24543. b.Name as PriceTypeStr ,
  24544. c.Name as CurrencyStr ,
  24545. d.Name as UnitStr ,
  24546. case a.ReviewStatus
  24547. WHEN 1 THEN '已通过'
  24548. WHEN 0 THEN '未审核'
  24549. WHEN -1 THEN '未通过'
  24550. ELSE '未审核'
  24551. END AS ReviewStatusStr
  24552. ";
  24553. if (Dto.FileTypeId == 0)
  24554. {
  24555. fileTypeName = "会务成本成本表";
  24556. loadPath += $"{fileTypeName}.xlsx";
  24557. outputPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  24558. networkPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  24559. }
  24560. else if (Dto.FileTypeId == 1)
  24561. {
  24562. fileTypeName = "会务成本报价表";
  24563. loadPath += $"{fileTypeName}.xlsx";
  24564. outputPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  24565. networkPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  24566. }
  24567. else if (Dto.FileTypeId == 2)
  24568. {
  24569. fileTypeName = "会务成本总表";
  24570. loadPath += $"{fileTypeName}.xlsx";
  24571. outputPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  24572. networkPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  24573. }
  24574. var chiExcelContent = _sqlSugar.SqlQueryable<ConferenceAffairsExcelContent>(@$"
  24575. SELECT
  24576. {field}
  24577. FROM Grp_ConferenceAffairsCostChild a
  24578. LEFT JOIN Sys_SetData b on b.IsDel = 0 AND b.Id = a.PriceType
  24579. LEFT JOIN Sys_SetData c on c.IsDel = 0 AND c.Id = a.Currency
  24580. LEFT JOIN Sys_SetData d on d.IsDel = 0 AND d.Id = a.Unit
  24581. WHERE a.isdel = 0
  24582. AND a.Diid = {main.Diid}
  24583. AND a.ConferenceAffairsCostId = {main.Id}
  24584. ").ToList();
  24585. var currLists = chiExcelContent.Select(x => new CurrList
  24586. {
  24587. CurrName = x.CurrencyStr,
  24588. CurrRate = x.Rate
  24589. })
  24590. .Distinct()
  24591. .ToList();
  24592. var designer = new WorkbookDesigner
  24593. {
  24594. Workbook = new Workbook(loadPath)
  24595. };
  24596. var MostCurr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.IsDel == 0 && x.Id == main.MostCurr);
  24597. MostCurr ??= new Sys_SetData { Name = "暂无!" };
  24598. designer.SetDataSource("TeamName", di.TeamName);
  24599. designer.SetDataSource("City", main.City);
  24600. designer.SetDataSource("AllCost", main.CostAll);
  24601. designer.SetDataSource("AllBaoJia", main.BaoJiaAll);
  24602. designer.SetDataSource("Curr", MostCurr.Name);
  24603. designer.SetDataSource("Curr1", MostCurr.Name);
  24604. DataTable dt = CommonFun.GetDataTableFromIList<ConferenceAffairsExcelContent>(chiExcelContent);
  24605. dt.TableName = "TB";
  24606. designer.SetDataSource(dt);
  24607. DataTable dt1 = CommonFun.GetDataTableFromIList<CurrList>(currLists);
  24608. dt1.TableName = "currTb";
  24609. designer.SetDataSource(dt1);
  24610. designer.Process();
  24611. designer.Workbook.Save(outputPath);
  24612. jw = JsonView(true, "操作成功!", new
  24613. {
  24614. FileName = $"{di.TeamName}_{fileTypeName}.xlsx",
  24615. FilePath = networkPath
  24616. });
  24617. return Ok(jw);
  24618. }
  24619. [HttpPost]
  24620. public async Task<IActionResult> QueryConferenceAffairsChild(QueryConferenceAffairsChildDto Dto)
  24621. {
  24622. return Ok(JsonView(true, "SUCCESS", _sqlSugar.Queryable<Grp_ConferenceAffairsCostChild>().Where(x => x.IsDel == 0 && x.Diid == Dto.GroupId)
  24623. .Select(x => x.PriceName).ToList()));
  24624. }
  24625. #endregion
  24626. #region 会务流程
  24627. /// <summary>
  24628. /// 会务流程 - 团组列表
  24629. /// </summary>
  24630. /// <returns>团组基本信息、团组列表和会务基本信息列表</returns>
  24631. [HttpGet]
  24632. public async Task<IActionResult> ConferenceProceduresGroupNames()
  24633. {
  24634. var conferenceTypeIds = new List<int>() {
  24635. 302, // 成都-会务活动
  24636. 691 // 四川-会务活动
  24637. };
  24638. var groupList = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  24639. .Where(x => x.IsDel == 0)
  24640. .Where(x => conferenceTypeIds.Contains(x.TeamDid))
  24641. .OrderByDescending(x => x.VisitDate)
  24642. .Select(x => new
  24643. {
  24644. x.Id,
  24645. x.TeamName,
  24646. HasChildData = SqlFunc.Subqueryable<Grp_ConferenceProcedures>()
  24647. .Where(child => child.DiId == x.Id) // 替换关联条件
  24648. .Any() // 判断子表是否存在数据
  24649. })
  24650. .ToListAsync();
  24651. return Ok(JsonView(true, "SUCCESS", groupList));
  24652. }
  24653. /// <summary>
  24654. /// 会务流程 - 数据初始化
  24655. /// </summary>
  24656. /// <param name="dto"></param>
  24657. /// <returns>团组基本信息、团组列表和会务基本信息列表</returns>
  24658. [HttpPost]
  24659. public async Task<IActionResult> ConferenceProceduresInit(ConferenceProceduresInitDto dto)
  24660. {
  24661. try
  24662. {
  24663. var conferenceTypeIds = new List<int>() {
  24664. 302, // 成都-会务活动
  24665. 691 // 四川-会务活动
  24666. };
  24667. Grp_DelegationInfo targetGroup = null;
  24668. targetGroup = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  24669. .Where(x => x.Id == dto.GroupId && x.IsDel == 0)
  24670. .FirstAsync();
  24671. if (targetGroup == null)
  24672. {
  24673. targetGroup = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  24674. .Where(x => x.IsDel == 0)
  24675. .Where(x => conferenceTypeIds.Contains(x.TeamDid))
  24676. .OrderByDescending(x => x.VisitDate)
  24677. .FirstAsync();
  24678. }
  24679. if (targetGroup == null)
  24680. {
  24681. return Ok(JsonView(false, "未找到任何团组信息"));
  24682. }
  24683. var groupList = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  24684. .Where(x => x.IsDel == 0)
  24685. .Where(x => conferenceTypeIds.Contains(x.TeamDid))
  24686. .OrderByDescending(x => x.VisitDate)
  24687. .Select(x => new
  24688. {
  24689. x.Id,
  24690. x.TeamName,
  24691. HasChildData = SqlFunc.Subqueryable<Grp_ConferenceProcedures>()
  24692. .Where(child => child.DiId == x.Id)
  24693. .Any() // 判断子表是否存在数据
  24694. })
  24695. .ToListAsync();
  24696. var conferenceProceduresList = await _sqlSugar.Queryable<Grp_ConferenceProcedures>()
  24697. .Where(x => x.DiId == targetGroup.Id && x.IsDel == 0)
  24698. .Select(x => new { x.Id, x.Title, x.DataDetails, x.Details, x.Remark })
  24699. .ToListAsync();
  24700. if (!conferenceProceduresList.Any())
  24701. {
  24702. conferenceProceduresList = await _sqlSugar.Queryable<Grp_ConferenceProcedures>()
  24703. .Where(x => x.DiId == -1 && x.IsDel == 0)
  24704. .Select(x => new { x.Id, x.Title, x.DataDetails, x.Details, x.Remark })
  24705. .ToListAsync();
  24706. }
  24707. var conferenceProceduresGroupByTitle = conferenceProceduresList
  24708. .GroupBy(x => x.Title)
  24709. .Select(x => new
  24710. {
  24711. title = x.Key,
  24712. itmes = x.Select(y => new
  24713. {
  24714. y.Id,
  24715. y.DataDetails,
  24716. y.Details,
  24717. y.Remark
  24718. }).ToList()
  24719. })
  24720. .ToList();
  24721. var response = new
  24722. {
  24723. GroupInfo = new
  24724. {
  24725. targetGroup.Id,
  24726. targetGroup.TeamName,
  24727. targetGroup.VisitDate,
  24728. targetGroup.VisitDays,
  24729. targetGroup.VisitPNumber,
  24730. targetGroup.VisitCountry,
  24731. targetGroup.VisitStartDate,
  24732. targetGroup.VisitEndDate,
  24733. targetGroup.ClientName,
  24734. targetGroup.ClientUnit
  24735. },
  24736. GroupList = groupList,
  24737. ConferenceProceduresList = conferenceProceduresList,
  24738. conferenceProceduresGroupByTitle = conferenceProceduresGroupByTitle
  24739. };
  24740. return Ok(JsonView(true, "SUCCESS", response));
  24741. }
  24742. catch (Exception ex)
  24743. {
  24744. _logger.LogError(ex, "数据初始化失败");
  24745. return Ok(JsonView(false, $"ERROR:{ex.Message}"));
  24746. }
  24747. }
  24748. /// <summary>
  24749. /// 会务流程 - 保存
  24750. /// </summary>
  24751. /// <param name="dto"></param>
  24752. /// <returns></returns>
  24753. [HttpPost]
  24754. public async Task<IActionResult> ConferenceProceduresSave(ConferenceProceduresSaveDto dto)
  24755. {
  24756. _sqlSugar.BeginTran();
  24757. try
  24758. {
  24759. //删除旧数据
  24760. _sqlSugar.Updateable<Grp_ConferenceProcedures>()
  24761. .Where(x => x.DiId == dto.GroupId && x.IsDel == 0)
  24762. .SetColumns(x => new Grp_ConferenceProcedures
  24763. {
  24764. IsDel = 1,
  24765. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  24766. DeleteUserId = dto.UserId
  24767. })
  24768. .ExecuteCommand();
  24769. //添加新数据
  24770. var newData = new List<Grp_ConferenceProcedures>();
  24771. foreach (var item in dto.ConferenceProceduresSaveItem)
  24772. {
  24773. foreach (var item2 in item.itmes)
  24774. {
  24775. newData.Add(new Grp_ConferenceProcedures
  24776. {
  24777. DiId = dto.GroupId,
  24778. Title = item.title,
  24779. DataDetails = item2.DataDetails,
  24780. Details = item2.details,
  24781. Remark = item2.Remark,
  24782. CreateTime = DateTime.Now,
  24783. CreateUserId = dto.UserId
  24784. });
  24785. }
  24786. }
  24787. _sqlSugar.Insertable(newData).ExecuteCommand();
  24788. _sqlSugar.CommitTran();
  24789. }
  24790. catch (Exception ex)
  24791. {
  24792. _sqlSugar.RollbackTran();
  24793. return Ok(JsonView(false, $"ERROR:{ex.Message}"));
  24794. }
  24795. return Ok(JsonView(true, "SUCCESS"));
  24796. }
  24797. [HttpPost]
  24798. public async Task<IActionResult> ConferenceProceduresFileDown(ConferenceProceduresFileDownDto dto)
  24799. {
  24800. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  24801. .Where(x => x.Id == dto.GroupId && x.IsDel == 0)
  24802. .FirstAsync();
  24803. if (groupInfo == null)
  24804. {
  24805. return Ok(JsonView(false, "团组信息不存在"));
  24806. }
  24807. var conferenceProceduresList = await _sqlSugar.Queryable<Grp_ConferenceProcedures>()
  24808. .Where(x => x.DiId == dto.GroupId && x.IsDel == 0)
  24809. .ToListAsync();
  24810. if (!conferenceProceduresList.Any())
  24811. {
  24812. return Ok(JsonView(false, "会务流程信息不存在"));
  24813. }
  24814. var filePath = $"{AppSettingsHelper.Get("ExcelBasePath")}Template/会务流程.xlsx";
  24815. if (!System.IO.File.Exists(filePath))
  24816. {
  24817. return Ok(JsonView(false, "模板文件不存在"));
  24818. }
  24819. var designer = new WorkbookDesigner();
  24820. designer.Workbook = new Workbook(filePath);
  24821. designer.SetDataSource("TB", conferenceProceduresList);
  24822. designer.Process();
  24823. var sheet = designer.Workbook.Worksheets[0];
  24824. var cells = sheet.Cells;
  24825. int col = 0; // 第一列
  24826. int startRow = 2; // 若第0行为表头,则从第1行开始;无表头请改为0
  24827. int endRow = cells.MaxDataRow;
  24828. if (endRow >= startRow)
  24829. {
  24830. int mergeStart = startRow;
  24831. string prev = cells[mergeStart, col].StringValue?.Trim() ?? string.Empty;
  24832. for (int r = startRow + 1; r <= endRow; r++)
  24833. {
  24834. string cur = cells[r, col].StringValue?.Trim() ?? string.Empty;
  24835. if (!string.Equals(cur, prev, StringComparison.Ordinal))
  24836. {
  24837. int count = r - mergeStart;
  24838. if (count > 1)
  24839. cells.Merge(mergeStart, col, count, 1);
  24840. mergeStart = r;
  24841. prev = cur;
  24842. }
  24843. }
  24844. int tailCount = endRow - mergeStart + 1;
  24845. if (tailCount > 1)
  24846. cells.Merge(mergeStart, col, tailCount, 1);
  24847. }
  24848. // byte[] bytes = null;
  24849. // using (MemoryStream stream = new MemoryStream())
  24850. // {
  24851. // designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  24852. // bytes = stream.ToArray();
  24853. // }
  24854. // return File(bytes, "application/excel", $"{groupInfo.TeamName}_会务流程.xlsx");
  24855. string savePath = $"{AppSettingsHelper.Get("ExcelBasePath")}ConferenceProcedures";
  24856. if (!System.IO.Directory.Exists(savePath))
  24857. {
  24858. System.IO.Directory.CreateDirectory(savePath);
  24859. }
  24860. designer.Workbook.Save($"{savePath}/{groupInfo.TeamName}_会务流程.xlsx");
  24861. string rst = savePath.replace(AppSettingsHelper.Get("ExcelBasePath"),
  24862. AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath"));
  24863. return Ok(JsonView(true, "SUCCESS", $"{rst}/{groupInfo.TeamName}_会务流程.xlsx"));
  24864. }
  24865. #endregion
  24866. #region 团组签证流程
  24867. /// <summary>
  24868. /// 团组签证流程 - 团组列表(分页)
  24869. /// </summary>
  24870. /// <returns></returns>
  24871. [HttpPost]
  24872. public async Task<IActionResult> VisaProcessGroupNames(VisaProcessGroupNamesDto dto)
  24873. {
  24874. int currUserId = dto.CurrUserId <= 0 ? 1 : dto.CurrUserId;
  24875. string groupName = dto.GroupName.Trim();
  24876. int pageIndex = dto.PageIndex <= 0 ? 1 : dto.PageIndex;
  24877. int pageSize = dto.PageSize <= 0 ? 10 : dto.PageSize;
  24878. int portType = dto.PortType;
  24879. RefAsync<int> total = 0;
  24880. var query = _sqlSugar.Queryable<Grp_GroupsTaskAssignment>()
  24881. .InnerJoin<Grp_DelegationInfo>((x, y) => x.DIId == y.Id)
  24882. .InnerJoin<Grp_VisaProcessSteps>((x, y, z) => x.DIId == z.GroupId)
  24883. .Where((x, y, z) => x.IsDel == 0 && x.CTId == 80 && x.UId == currUserId && z.IsDel == 0);
  24884. //构建单字模糊查询
  24885. if (!string.IsNullOrEmpty(groupName))
  24886. {
  24887. var characters = groupName.ToCharArray();
  24888. foreach (var character in characters)
  24889. {
  24890. var charString = character.ToString();
  24891. query = query.Where((x, y) =>
  24892. SqlFunc.Contains(y.TeamName, charString));
  24893. }
  24894. }
  24895. var groups = await query
  24896. .OrderByDescending((x, y) => y.VisitDate)
  24897. .Select((x, y) => new
  24898. {
  24899. y.Id,
  24900. GroupName = y.TeamName,
  24901. y.VisitDate,
  24902. // 加入子查询统计子表条数
  24903. CompletedCount = SqlFunc.Subqueryable<Grp_VisaProcessSteps>()
  24904. .Where(sub => sub.GroupId == y.Id && sub.IsCompleted && sub.IsDel == 0)
  24905. .Count()
  24906. })
  24907. .Distinct()
  24908. .ToPageListAsync(pageIndex, pageSize, total);
  24909. var msg = "SUCCESS";
  24910. if (total <= 0) msg = "暂无可操作的团组,请联系经理分配团组!";
  24911. var groups1 = groups.Select(x => new
  24912. {
  24913. x.Id,
  24914. x.GroupName,
  24915. x.CompletedCount
  24916. }).ToList();
  24917. return Ok(JsonView(true, msg, groups1, total));
  24918. }
  24919. /// <summary>
  24920. /// 团组签证流程 - 详情
  24921. /// </summary>
  24922. /// <returns></returns>
  24923. [HttpPost]
  24924. public async Task<IActionResult> VisaProcessInfoByGroupId(VisaProcessInfoByGroupIdDto dto)
  24925. {
  24926. var res = await _visaProcessRep.Info(dto);
  24927. if (res.Code != 200) return Ok(JsonView(false, res.Msg));
  24928. return Ok(JsonView(true, res.Msg, res.Data));
  24929. }
  24930. /// <summary>
  24931. /// 团组签证流程 - 流程创建测试
  24932. /// </summary>
  24933. /// <returns></returns>
  24934. [HttpPost]
  24935. public async Task<IActionResult> VisaProcessAdd(int groupId, int currUserId)
  24936. {
  24937. return Ok(await _visaProcessRep.Create(currUserId, groupId));
  24938. }
  24939. /// <summary>
  24940. /// 团组签证流程 - 流程Top4Init 测试
  24941. /// </summary>
  24942. /// <returns></returns>
  24943. [HttpPost]
  24944. public async Task<IActionResult> VisaProcessTop4StepInit(int groupId, int currUserId)
  24945. {
  24946. return Ok(await _visaProcessRep.UpdateBatchTop4Step(groupId, currUserId));
  24947. }
  24948. /// <summary>
  24949. /// 团组签证流程 - 设置状态 完成/未完成
  24950. /// </summary>
  24951. /// <returns></returns>
  24952. [HttpPost]
  24953. public async Task<IActionResult> VisaProcessSetCompleted(VisaProcessSetCompletedDto dto)
  24954. {
  24955. //参数验证
  24956. var stepValid = await _sqlSugar.Queryable<Grp_VisaProcessSteps>().Where(x => x.Id == dto.StepId && x.IsDel == 0).AnyAsync();
  24957. if (!stepValid) return Ok(JsonView(false, "签证流程ID无效。"));
  24958. var userValid = await _sqlSugar.Queryable<Sys_Users>().Where(x => x.Id == dto.CurrUserId && x.IsDel == 0).AnyAsync();
  24959. if (!userValid) return Ok(JsonView(false, "用户ID无效。"));
  24960. var res = await _visaProcessRep.SetCompleted(dto.StepId, dto.CurrUserId, dto.IsCompleted);
  24961. if (res.Code != 200) return Ok(JsonView(false, res.Msg));
  24962. return Ok(JsonView(true, res.Msg));
  24963. }
  24964. /// <summary>
  24965. /// 团组签证流程 - 修改各步骤内容
  24966. /// </summary>
  24967. /// <returns></returns>
  24968. [HttpPost]
  24969. public async Task<IActionResult> VisaProcessSetContent(VisaProcessSetContent dto)
  24970. {
  24971. //参数验证
  24972. var stepValid = await _sqlSugar.Queryable<Grp_VisaProcessSteps>().Where(x => x.Id == dto.StepId && x.IsDel == 0).FirstAsync();
  24973. if (stepValid == null) return Ok(JsonView(false, "签证流程ID无效。"));
  24974. var userValid = await _sqlSugar.Queryable<Sys_Users>().Where(x => x.Id == dto.CurrUserId && x.IsDel == 0).AnyAsync();
  24975. if (!userValid) return Ok(JsonView(false, "用户ID无效。"));
  24976. if (dto.StepContents == null && dto.StepContents.Count < 1)
  24977. {
  24978. return Ok(JsonView(false, "步骤内容无效。"));
  24979. }
  24980. //各步骤值处理
  24981. object stepVal;
  24982. if (stepValid.Step == 7) stepVal = dto.StepContents;
  24983. else stepVal = dto.StepContents[0].ToString();
  24984. var stepInfo = new Grp_VisaProcessSteps
  24985. {
  24986. Id = dto.StepId,
  24987. DataType = stepValid.DataType,
  24988. TypedValue = stepVal,
  24989. LastUpdateUserId = dto.CurrUserId
  24990. };
  24991. var res = await _visaProcessRep.Update(stepInfo);
  24992. if (res.Code != 200) return Ok(JsonView(false, res.Msg));
  24993. return Ok(JsonView(true, res.Msg));
  24994. }
  24995. /// <summary>
  24996. /// 团组签证流程 - 上传文件
  24997. /// </summary>
  24998. /// <returns></returns>
  24999. [HttpPost]
  25000. public async Task<IActionResult> VisaProcessUploadFiles([FromForm] VisaProcessUploadFilesDto dto)
  25001. {
  25002. //参数验证
  25003. var stepValid = await _sqlSugar.Queryable<Grp_VisaProcessSteps>().Where(x => x.Id == dto.StepId && x.IsDel == 0).FirstAsync();
  25004. if (stepValid == null) return Ok(JsonView(false, "签证流程ID无效。"));
  25005. var before = stepValid;
  25006. var userValid = await _sqlSugar.Queryable<Sys_Users>().Where(x => x.Id == dto.CurrUserId && x.IsDel == 0).AnyAsync();
  25007. if (!userValid) return Ok(JsonView(false, "用户ID无效。"));
  25008. //验证文件是否存在
  25009. if (dto.Files == null || dto.Files.Count < 1) return Ok(JsonView(false, "请选择文件。"));
  25010. //验证该步骤是否可以上传文件
  25011. var uploadSteps = new List<int>() {
  25012. 5, //实际出签时间
  25013. 6, //是否需要开出境证明
  25014. 7, //是否需要办理电子入境卡手续
  25015. };
  25016. if (!uploadSteps.Contains(stepValid.Step))
  25017. {
  25018. return Ok(JsonView(false, $"该步骤不可上传附件。可上传附件步骤({string.Join("、", uploadSteps)})"));
  25019. }
  25020. //验证根目录
  25021. string rootRrl = AppSettingsHelper.Get("OfficeBaseUrl");
  25022. string rootPath = AppSettingsHelper.Get("OfficeTempBasePath");
  25023. if (!System.IO.Directory.Exists(rootPath))
  25024. {
  25025. System.IO.Directory.CreateDirectory(rootPath);
  25026. }
  25027. //验证签证流程上传文件夹 //按照团组名称存储文件夹 GrpFile/VisaProcessFiles/
  25028. var groupName = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  25029. .Where(x => x.IsDel == 0 && x.Id == stepValid.GroupId)
  25030. .Select(x => $"{x.TeamName}({x.Id})")
  25031. .FirstAsync();
  25032. //创建团组文件夹
  25033. var groupPath = rootPath + "GrpFile/VisaProcessFiles/" + groupName;
  25034. if (!System.IO.Directory.Exists(groupPath))
  25035. {
  25036. System.IO.Directory.CreateDirectory(groupPath);
  25037. }
  25038. List<string> filePaths = new List<string>();
  25039. //保存文件
  25040. foreach (var file in dto.Files)
  25041. {
  25042. // 生成存储文件名
  25043. var fileName = CommonFun.GenerateStoredFileName($"Step{stepValid.Step}.{file.FileName.Split(".")[1]}");
  25044. var filePath = Path.Combine(groupPath, fileName);
  25045. // 保存文件到磁盘
  25046. using (var stream = new FileStream(filePath, FileMode.Create))
  25047. {
  25048. await file.CopyToAsync(stream);
  25049. }
  25050. filePaths.Add($"GrpFile/VisaProcessFiles/{groupName}/{fileName}");
  25051. }
  25052. //数据库存储
  25053. stepValid.TypedFileNameValue = filePaths;
  25054. stepValid.LastUpdateUserId = dto.CurrUserId;
  25055. stepValid.LastUpdateTime = DateTime.Now;
  25056. var res = await _sqlSugar.Updateable(stepValid)
  25057. .UpdateColumns(it => new { it.TypedFileNameValue, it.LastUpdateUserId, it.LastUpdateTime })
  25058. .Where(s => s.Id == dto.StepId && s.IsDel == 0)
  25059. .ExecuteCommandAsync();
  25060. if (res < 1) Ok(JsonView(false, "文件上传失败。"));
  25061. //记录上传文件
  25062. await _visaProcessRep.LogOperationAsync(before, stepValid, "Upload", dto.CurrUserId);
  25063. return Ok(JsonView(true));
  25064. }
  25065. /// <summary>
  25066. /// 团组签证流程 - step 7 资料下载
  25067. /// </summary>
  25068. /// <returns></returns>
  25069. [HttpGet]
  25070. public async Task<IActionResult> VisaProcessDownload(int groupId, int currUserId)
  25071. {
  25072. var userValid = await _sqlSugar.Queryable<Sys_Users>().Where(x => x.Id == currUserId && x.IsDel == 0).AnyAsync();
  25073. if (!userValid) return Ok(JsonView(false, "用户ID无效。"));
  25074. //验证根目录
  25075. string rootRrl = AppSettingsHelper.Get("OfficeBaseUrl");
  25076. string rootPath = AppSettingsHelper.Get("OfficeTempBasePath");
  25077. if (!System.IO.Directory.Exists(rootPath))
  25078. {
  25079. System.IO.Directory.CreateDirectory(rootPath);
  25080. }
  25081. //验证签证流程上传文件夹 //按照团组名称存储文件夹 GrpFile/VisaProcessFiles/
  25082. var groupName = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  25083. .Where(x => x.IsDel == 0 && x.Id == groupId)
  25084. .Select(x => $"{x.TeamName}({x.Id})")
  25085. .FirstAsync();
  25086. //创建团组文件夹
  25087. var timestamp = DateTime.Now.ToString("yyyyMMddHHmmss");
  25088. var randomStr = Guid.NewGuid().ToString("N").Substring(0, 8);
  25089. var dirName = $"{groupName}_相关资料_{timestamp}";
  25090. var sourceDirectoryPath = $"{rootPath}/GrpFile/VisaProcessFiles/{groupName}";
  25091. var path = $"{rootPath}/GrpFile/VisaProcessFiles/{groupName}/{dirName}";
  25092. if (!System.IO.Directory.Exists(path))
  25093. {
  25094. System.IO.Directory.CreateDirectory(path);
  25095. }
  25096. //验证接团客户名单
  25097. string sql = string.Format(@"
  25098. SELECT
  25099. tcl.Id,
  25100. tcl.DiId,
  25101. tcl.IsAccompany,
  25102. temp.*,
  25103. u.CnName AS Operator,
  25104. tcl.CreateTime AS OperatingTime,
  25105. ssd.name AS ShippingSpaceType
  25106. FROM
  25107. Grp_TourClientList tcl
  25108. LEFT JOIN (
  25109. SELECT
  25110. dc.Id AS DcId,
  25111. dc.LastName,
  25112. dc.FirstName,
  25113. ccom.CompanyFullName,
  25114. dc.Job,
  25115. cc.CertNo AS IDCardNo,
  25116. dc.Sex,
  25117. dc.BirthDay
  25118. FROM
  25119. Crm_DeleClient dc
  25120. LEFT JOIN Crm_CustomerCompany ccom ON dc.CrmCompanyId = ccom.Id
  25121. AND ccom.IsDel = 0
  25122. LEFT JOIN Crm_CustomerCert cc ON dc.Id = cc.DcId
  25123. AND cc.SdId = 773
  25124. AND cc.IsDel = 0
  25125. WHERE
  25126. dc.IsDel = 0
  25127. ) temp ON temp.DcId = tcl.ClientId
  25128. LEFT JOIN Sys_Users u ON tcl.CreateUserId = u.Id
  25129. LEFT JOIN sys_setdata ssd ON ssd.isdel = 0 AND ssd.id = tcl.ShippingSpaceTypeid
  25130. WHERE
  25131. tcl.IsDel = 0
  25132. AND tcl.DiId = {0}", groupId);
  25133. var groupClientList = await _sqlSugar.SqlQueryable<TourClientInfosView>(sql).ToListAsync();
  25134. //解密
  25135. foreach (var item in groupClientList)
  25136. {
  25137. EncryptionProcessor.DecryptProperties(item);
  25138. }
  25139. if (groupClientList == null || groupClientList.Count < 1)
  25140. {
  25141. return Ok(JsonView(false, $"团组客户名单未录入客户信息,不可生成相关资料。"));
  25142. }
  25143. #region 生成文件
  25144. //酒店信息
  25145. var hotelInfos = await _sqlSugar.Queryable<Grp_HotelReservations>()
  25146. .Where(x => x.IsDel == 0 && x.DiId == groupId)
  25147. .OrderBy(x => x.CheckInDate)
  25148. .ToListAsync();
  25149. //航班信息
  25150. var airInfos = await _sqlSugar.Queryable<Grp_AirTicketReservations>()
  25151. .Where(x => x.IsDel == 0 && x.DIId == groupId)
  25152. .OrderBy(x => x.FlightsDate)
  25153. .ToListAsync();
  25154. foreach (var clientInfo in groupClientList)
  25155. {
  25156. var clientId = clientInfo.DcId;
  25157. var guestName = $"{clientInfo.LastName}{clientInfo.FirstName}";
  25158. #region 个人信息资料
  25159. #endregion
  25160. #region 机票航班信息
  25161. var clientAirInfos = airInfos.Where(x => x.ClientName.Contains(clientId.ToString())).ToList();
  25162. if (clientAirInfos != null && clientAirInfos.Count > 0)
  25163. {
  25164. //创建表格
  25165. Document airDoc = new Document();
  25166. DocumentBuilder airBuilder = new DocumentBuilder(airDoc);
  25167. GeneralMethod.SetupDocumentStyles(airBuilder);
  25168. GeneralMethod.AddTitle(airBuilder, $"{guestName} - 机票信息");
  25169. GeneralMethod.AddAirInfoSections(airBuilder, clientAirInfos, "机票航班信息");
  25170. var airRandomStr = Guid.NewGuid().ToString("N").Substring(0, 8);
  25171. var airFileName = $"{guestName}_机票信息_{airRandomStr}.docx";
  25172. airDoc.Save($"{path}/{airFileName}");
  25173. }
  25174. #endregion
  25175. #region 酒店信息
  25176. var clientHotelInfos = hotelInfos.Where(x => x.GuestName.Contains(clientId.ToString())).ToList();
  25177. if (clientHotelInfos != null && clientHotelInfos.Count > 0)
  25178. {
  25179. //创建表格
  25180. Document hotelDoc = new Document();
  25181. DocumentBuilder HotelBuilder = new DocumentBuilder(hotelDoc);
  25182. GeneralMethod.SetupDocumentStyles(HotelBuilder);
  25183. GeneralMethod.AddTitle(HotelBuilder, $"{guestName} - 酒店信息");
  25184. GeneralMethod.AddHotelInfoSections(HotelBuilder, clientHotelInfos, "酒店信息");
  25185. var hotelRandomStr = Guid.NewGuid().ToString("N").Substring(0, 8);
  25186. var hotelFileName = $"{guestName}_酒店信息_{hotelRandomStr}.docx";
  25187. hotelDoc.Save($"{path}/{hotelFileName}");
  25188. }
  25189. #endregion
  25190. }
  25191. #endregion
  25192. //打包文件夹
  25193. var sourceDirectory = $"{sourceDirectoryPath}/{dirName}";
  25194. var zipFilePath = $"{sourceDirectoryPath}/{dirName}.zip";
  25195. if (System.IO.File.Exists(zipFilePath))
  25196. {
  25197. System.IO.File.Delete(zipFilePath);
  25198. }
  25199. ZipFile.CreateFromDirectory(sourceDirectory, zipFilePath, CompressionLevel.Fastest, false);
  25200. // 等待并验证
  25201. await Task.Delay(100); // 给系统时间完成文件操作
  25202. if (System.IO.File.Exists(zipFilePath))
  25203. {
  25204. var fileInfo = new FileInfo(zipFilePath);
  25205. var url = $"{rootRrl}Office/GrpFile/VisaProcessFiles/{groupName}/{dirName}.zip";
  25206. //记录下载日志
  25207. await _visaProcessRep.LogOperationAsync(null, null, "Download", currUserId);
  25208. return Ok(JsonView(StatusCodes.Status200OK, "操作成功!", url));
  25209. }
  25210. return Ok(JsonView(false));
  25211. }
  25212. /// <summary>
  25213. /// 团组签证流程 - 根据步骤记录ID获取该步骤的所有操作日志
  25214. /// </summary>
  25215. /// <returns></returns>
  25216. [HttpGet]
  25217. public async Task<IActionResult> VisaProcessLogByStepId(int stepId)
  25218. {
  25219. //参数验证
  25220. var stepValid = await _sqlSugar.Queryable<Grp_VisaProcessSteps>().Where(x => x.Id == stepId && x.IsDel == 0).FirstAsync();
  25221. if (stepValid == null) return Ok(JsonView(false, "签证流程ID无效。"));
  25222. var logs = await _visaProcessRep.GetStepLogsAsync(stepId);
  25223. return Ok(JsonView(logs));
  25224. }
  25225. /// <summary>
  25226. /// 团组签证流程 - 根据团组ID获取该团组下所有步骤的操作日志
  25227. /// </summary>
  25228. /// <returns></returns>
  25229. [HttpGet]
  25230. public async Task<IActionResult> VisaProcessLogByGroupId(int groupId)
  25231. {
  25232. //参数验证
  25233. var stepValid = await _sqlSugar.Queryable<Grp_VisaProcessSteps>().Where(x => x.GroupId == groupId && x.IsDel == 0).FirstAsync();
  25234. if (stepValid == null) return Ok(JsonView(false, "团组ID无效。"));
  25235. var logs = await _visaProcessRep.GetGroupStepLogsAsync(groupId);
  25236. return Ok(JsonView(logs));
  25237. }
  25238. #endregion
  25239. #region 团组总览进程
  25240. /// <summary>
  25241. /// 团组总览进程 - 流程创建测试
  25242. /// </summary>
  25243. /// <returns></returns>
  25244. [HttpGet]
  25245. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  25246. public async Task<IActionResult> GroupProcessInitTest(int groupId, int currUserId)
  25247. {
  25248. return Ok(await _processOverviewRep.ProcessInitAsync(groupId, currUserId));
  25249. }
  25250. /// <summary>
  25251. /// 团组总览进程 - 团组名称集合
  25252. /// </summary>
  25253. /// <returns></returns>
  25254. [HttpGet]
  25255. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  25256. public async Task<IActionResult> GroupProcessGroupNames()
  25257. {
  25258. var groupNames = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  25259. .Where(x => x.IsDel == 0)
  25260. .OrderByDescending(x => x.VisitDate)
  25261. .Select(x => new
  25262. {
  25263. x.Id,
  25264. GroupName = x.TeamName,
  25265. HasProcess = SqlFunc.Subqueryable<Grp_ProcessOverview>()
  25266. .Where(po => po.GroupId == x.Id && po.IsDel == 0)
  25267. .Any()
  25268. })
  25269. .ToListAsync();
  25270. return Ok(JsonView(groupNames));
  25271. }
  25272. /// <summary>
  25273. /// 团组总览进程 - 流程详情
  25274. /// </summary>
  25275. /// <returns></returns>
  25276. [HttpGet]
  25277. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  25278. public async Task<IActionResult> GroupProcessDetails(int groupId)
  25279. {
  25280. var res = await _processOverviewRep.ProcessesDetailsAsync(groupId);
  25281. if (res.Code == StatusCodes.Status200OK)
  25282. {
  25283. return Ok(JsonView(res.Data));
  25284. }
  25285. return Ok(JsonView(false, res.Msg));
  25286. }
  25287. /// <summary>
  25288. /// 团组总览进程 - 更新节点状态
  25289. /// </summary>
  25290. /// <returns></returns>
  25291. [HttpPost]
  25292. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  25293. public async Task<IActionResult> GroupProcessUpdateNodeStatus(GroupProcessUpdateNodeStatusDto dto)
  25294. {
  25295. var res = await _processOverviewRep.UpdateNodeStatusAsync(dto.NodeId, dto.CurrUserId);
  25296. if (res.Code == StatusCodes.Status200OK)
  25297. {
  25298. return Ok(JsonView(res.Data));
  25299. }
  25300. return Ok(JsonView(false, res.Msg));
  25301. }
  25302. /// <summary>
  25303. /// 团组总览进程 - 更新签证节点信息
  25304. /// </summary>
  25305. /// <returns></returns>
  25306. [HttpPost]
  25307. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  25308. public async Task<IActionResult> GroupProcessUpdateVisaNodeDetails(GroupProcessUpdateVisaNodeDetailsDto dto)
  25309. {
  25310. //验证签证信息
  25311. if (dto.VisaSubNodes.Count < 1) return Ok(JsonView(false, "请传入有效的签证节点信息。"));
  25312. var res = await _processOverviewRep.UpdateVisaNodeDetailsAsync(dto);
  25313. if (res.Code == StatusCodes.Status200OK)
  25314. {
  25315. return Ok(JsonView(res.Data));
  25316. }
  25317. return Ok(JsonView(false, res.Msg));
  25318. }
  25319. #endregion
  25320. /// <summary>
  25321. /// 123132123
  25322. /// </summary>
  25323. /// <param name="_dto"></param>
  25324. /// <returns></returns>
  25325. [HttpPost]
  25326. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  25327. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  25328. {
  25329. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  25330. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  25331. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  25332. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  25333. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  25334. dicDetail.Add(789, 1034);
  25335. dicDetail.Add(790, 1035);
  25336. dicDetail.Add(791, 1036);
  25337. dicDetail.Add(792, 1037);
  25338. dicDetail.Add(793, 1038);
  25339. dicDetail.Add(794, 1039);
  25340. dicDetail.Add(795, 1040);
  25341. dicDetail.Add(796, 1041);
  25342. dicDetail.Add(797, 1042);
  25343. dicDetail.Add(798, 1043);
  25344. dicDetail.Add(801, 1044);
  25345. dicDetail.Add(802, 1045);
  25346. dicDetail.Add(803, 1046);
  25347. Dictionary<int, int> dic = new Dictionary<int, int>();
  25348. dic.Add(806, 1027);
  25349. dic.Add(807, 1028);
  25350. dic.Add(808, 1029);
  25351. dic.Add(809, 1030);
  25352. dic.Add(810, 1031);
  25353. dic.Add(811, 1032);
  25354. dic.Add(812, 1033);
  25355. foreach (var item in list_visa)
  25356. {
  25357. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  25358. temp.Coefficient = item.coefficient;
  25359. DateTime dtCrt;
  25360. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  25361. if (b1)
  25362. {
  25363. temp.CreateTime = dtCrt;
  25364. }
  25365. else
  25366. {
  25367. temp.CreateTime = DateTime.Now;
  25368. }
  25369. temp.CreateUserId = item.Operators;
  25370. temp.DeleteTime = "";
  25371. temp.DeleteUserId = 0;
  25372. temp.DiId = int.Parse(item.DIID);
  25373. temp.FilePath = item.FilePath;
  25374. temp.IsDel = item.IsDel;
  25375. temp.Price = item.Price;
  25376. temp.PriceCount = 1;
  25377. temp.PriceCurrency = item.Currency;
  25378. int detailId = 0;
  25379. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  25380. {
  25381. detailId = dicDetail[item.PriceTypeDetail];
  25382. }
  25383. temp.PriceDetailType = detailId;
  25384. temp.PriceDt = DateTime.Now;
  25385. temp.PriceName = item.PriceName;
  25386. temp.PriceSum = item.Price;
  25387. int tid = 0;
  25388. if (dic.ContainsKey(item.PriceType))
  25389. {
  25390. tid = dic[item.PriceType];
  25391. }
  25392. temp.PriceType = tid;
  25393. temp.Remark = item.Remark;
  25394. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  25395. }
  25396. return Ok(JsonView(true, "操作成功!"));
  25397. }
  25398. [HttpPost]
  25399. public IActionResult TimeTest()
  25400. {
  25401. var jw = JsonView(false, "error");
  25402. _sqlSugar.BeginTran();
  25403. try
  25404. {
  25405. var clientList = _sqlSugar.Queryable<Crm_NewClientData>()
  25406. .Select(x => new Crm_NewClientData
  25407. {
  25408. Id = x.Id,
  25409. Client = x.Client,
  25410. Contact = x.Contact,
  25411. Location = x.Location,
  25412. })
  25413. .ToList();
  25414. var ids = clientList.Where(x => !string.IsNullOrEmpty(x.Client) && x.Client.Contains("重庆")).Select(x => x.Id).ToList();
  25415. _sqlSugar.Queryable<Crm_NewClientData>().Where(x => ids.Contains(x.Id)).ToList();
  25416. Stopwatch stopwatch = new Stopwatch();
  25417. // 开始计时
  25418. stopwatch.Start();
  25419. foreach (var item in clientList)
  25420. {
  25421. EncryptionProcessor.DecryptProperties(item);
  25422. }
  25423. stopwatch.Stop();
  25424. jw.Code = 200;
  25425. jw.Data = stopwatch.ElapsedMilliseconds;
  25426. jw.Msg = "运算耗时: " + stopwatch.ElapsedMilliseconds + " 毫秒,解密条数: " + clientList.Count;
  25427. }
  25428. catch (Exception ex)
  25429. {
  25430. jw.Code = 400;
  25431. jw.Msg = ex.Message;
  25432. }
  25433. return Ok(jw);
  25434. }
  25435. [HttpPost]
  25436. public async Task<IActionResult> TimeTest1()
  25437. {
  25438. var infos = await _sqlSugar.Queryable<Crm_DeleClient>().ToListAsync();
  25439. return Ok(infos);
  25440. }
  25441. }
  25442. }