GroupsController.cs 1.3 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514
  1. using Aspose.Cells;
  2. using Aspose.Words;
  3. using Aspose.Words.Drawing;
  4. using Aspose.Words.Tables;
  5. using DiffMatchPatch;
  6. using Microsoft.AspNetCore.SignalR;
  7. using NPOI.SS.Formula.Functions;
  8. using NPOI.SS.UserModel;
  9. using NPOI.SS.Util;
  10. using NPOI.XSSF.UserModel;
  11. using OASystem.API.Middlewares;
  12. using OASystem.API.OAMethodLib;
  13. using OASystem.API.OAMethodLib.APNs;
  14. using OASystem.API.OAMethodLib.DeepSeekAPI;
  15. using OASystem.API.OAMethodLib.File;
  16. using OASystem.API.OAMethodLib.Hub.HubClients;
  17. using OASystem.API.OAMethodLib.Hub.Hubs;
  18. using OASystem.API.OAMethodLib.JuHeAPI;
  19. using OASystem.API.OAMethodLib.KiMiApi;
  20. using OASystem.API.OAMethodLib.Logging;
  21. using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
  22. using OASystem.Domain.AesEncryption;
  23. using OASystem.Domain.Attributes;
  24. using OASystem.Domain.Dtos.CRM;
  25. using OASystem.Domain.Dtos.FileDto;
  26. using OASystem.Domain.Dtos.Financial;
  27. using OASystem.Domain.Dtos.Groups;
  28. using OASystem.Domain.Entities.Customer;
  29. using OASystem.Domain.Entities.Financial;
  30. using OASystem.Domain.Entities.Groups;
  31. using OASystem.Domain.ViewModels.CRM;
  32. using OASystem.Domain.ViewModels.Financial;
  33. using OASystem.Domain.ViewModels.Groups;
  34. using OASystem.Domain.ViewModels.OCR;
  35. using OASystem.Infrastructure.Repositories.CRM;
  36. using OASystem.Infrastructure.Repositories.Financial;
  37. using OASystem.Infrastructure.Repositories.Groups;
  38. using Quartz.Logging;
  39. using Quartz.Util;
  40. using SQLitePCL;
  41. using SqlSugar.Extensions;
  42. using System.Collections;
  43. using System.ComponentModel.DataAnnotations;
  44. using System.Data;
  45. using System.Diagnostics;
  46. using System.Globalization;
  47. using System.IO;
  48. using System.IO.Compression;
  49. using System.Linq.Expressions;
  50. using System.Text.Json;
  51. using System.Text.RegularExpressions;
  52. using System.Threading.Tasks;
  53. using System.Web;
  54. using static OASystem.API.OAMethodLib.JWTHelper;
  55. using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
  56. using static OpenAI.GPT3.ObjectModels.SharedModels.IOpenAiModels;
  57. using Bookmark = Aspose.Words.Bookmark;
  58. using Cell = Aspose.Words.Tables.Cell;
  59. using Table = Aspose.Words.Tables.Table;
  60. namespace OASystem.API.Controllers
  61. {
  62. /// <summary>
  63. /// 团组相关
  64. /// </summary>
  65. //[Authorize]
  66. [Route("api/[controller]/[action]")]
  67. public class GroupsController : ControllerBase
  68. {
  69. private readonly ILogger<GroupsController> _logger;
  70. private readonly ITextFileLogger _eec_textLogger;
  71. private readonly IGroupTextFileLogger _groupTextLogger;
  72. private readonly GrpScheduleRepository _grpScheduleRep;
  73. private readonly IMapper _mapper;
  74. private readonly DelegationInfoRepository _groupRepository;
  75. private readonly TaskAssignmentRepository _taskAssignmentRep;
  76. private readonly AirTicketResRepository _airTicketResRep;
  77. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  78. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  79. private readonly DelegationEnDataRepository _delegationEnDataRep;
  80. private readonly DelegationVisaRepository _delegationVisaRep;
  81. private readonly VisaPriceRepository _visaPriceRep;
  82. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  83. private readonly HotelPriceRepository _hotelPriceRep;
  84. private readonly CustomersRepository _customersRep;
  85. private readonly MessageRepository _message;
  86. private readonly SqlSugarClient _sqlSugar;
  87. private readonly TourClientListRepository _tourClientListRep;
  88. private readonly TeamRateRepository _teamRateRep;
  89. #region 成本相关
  90. private readonly CheckBoxsRepository _checkBoxs;
  91. private readonly GroupCostRepository _GroupCostRepository;
  92. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  93. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  94. #endregion
  95. private readonly SetDataRepository _setDataRep;
  96. private string url;
  97. private string path;
  98. private readonly EnterExitCostRepository _enterExitCostRep;
  99. private readonly IHubContext<ChatHub, IChatClient> _hubContext;
  100. private readonly UsersRepository _usersRep;
  101. private readonly IJuHeApiService _juHeApi;
  102. private readonly InvertedListRepository _invertedListRep;
  103. private readonly VisaFeeInfoRepository _visaFeeInfoRep;
  104. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  105. private readonly ThreeCodeRepository _threeCodeRepository;
  106. private readonly HotelInquiryRepository _hotelInquiryRep;
  107. private readonly FeeAuditRepository _feeAuditRep;
  108. private readonly VisaCommissionRepository _visaCommissionRep;
  109. private readonly ForeignReceivablesRepository _ffrRep; //对外收款账单仓库
  110. private readonly OpinionaireRepository _opinionaireRep; //对外收款账单仓库
  111. private readonly List<CurrencyInfo> _currencyInit;
  112. private readonly List<int> _portTypeData;
  113. private readonly TableOperationRecordRepository _tableorRep;
  114. private readonly EnterExitCostDraftRepository _enterExitCostDraftRep;
  115. private readonly RestaurantRepository _restaurantRep;
  116. private readonly EnterExitCostQuoteRepository _enterExitCostQuoteRep;
  117. private readonly GroupOrderPreInfoRepository _grpOrderPreInfoRep;
  118. private readonly VisaProcessRepository _visaProcessRep;
  119. private readonly IDeepSeekService _deepSeekService;
  120. /// <summary>
  121. /// 构造函数
  122. /// </summary>
  123. /// <param name="logger"></param>
  124. /// <param name="eec_textLogger"></param>
  125. /// <param name="groupTextLogger"></param>
  126. /// <param name="mapper"></param>
  127. /// <param name="hubContext"></param>
  128. /// <param name="sqlSugar"></param>
  129. /// <param name="grpScheduleRep"></param>
  130. /// <param name="groupRepository"></param>
  131. /// <param name="taskAssignmentRep"></param>
  132. /// <param name="airTicketResRep"></param>
  133. /// <param name="decreasePaymentsRep"></param>
  134. /// <param name="InvitationOfficialActivitiesRep"></param>
  135. /// <param name="delegationEnDataRep"></param>
  136. /// <param name="enterExitCostRep"></param>
  137. /// <param name="delegationVisaRep"></param>
  138. /// <param name="message"></param>
  139. /// <param name="visaPriceRep"></param>
  140. /// <param name="carTouristGuideGroundRep"></param>
  141. /// <param name="checkBoxs"></param>
  142. /// <param name="GroupCostRepository"></param>
  143. /// <param name="CostTypeHotelNumberRepository"></param>
  144. /// <param name="GroupCostParameterRepository"></param>
  145. /// <param name="hotelPriceRep"></param>
  146. /// <param name="customersRep"></param>
  147. /// <param name="setDataRep"></param>
  148. /// <param name="tourClientListRep"></param>
  149. /// <param name="teamRateRep"></param>
  150. /// <param name="usersRep"></param>
  151. /// <param name="juHeApi"></param>
  152. /// <param name="invertedListRep"></param>
  153. /// <param name="visaFeeInfoRep"></param>
  154. /// <param name="ticketBlackCodeRep"></param>
  155. /// <param name="hotelInquiryRep"></param>
  156. /// <param name="threeCodeRepository"></param>
  157. /// <param name="feeAuditRep"></param>
  158. /// <param name="visaCommissionRep"></param>
  159. /// <param name="ffrRep"></param>
  160. /// <param name="opinionaireRep"></param>
  161. /// <param name="tableorRep"></param>
  162. /// <param name="enterExitCostDraftRep"></param>
  163. /// <param name="restaurantRep"></param>
  164. /// <param name="enterExitCostQuoteRep"></param>
  165. /// <param name="grpOrderPreInfoRep"></param>
  166. /// <param name="visaProcessRep"></param>
  167. public GroupsController(
  168. ILogger<GroupsController> logger,
  169. ITextFileLogger eec_textLogger,
  170. IGroupTextFileLogger groupTextLogger,
  171. IMapper mapper,
  172. IHubContext<ChatHub, IChatClient> hubContext,
  173. SqlSugarClient sqlSugar,
  174. GrpScheduleRepository grpScheduleRep,
  175. DelegationInfoRepository groupRepository,
  176. TaskAssignmentRepository taskAssignmentRep,
  177. AirTicketResRepository airTicketResRep,
  178. DecreasePaymentsRepository decreasePaymentsRep,
  179. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep,
  180. DelegationEnDataRepository delegationEnDataRep,
  181. EnterExitCostRepository enterExitCostRep,
  182. DelegationVisaRepository delegationVisaRep,
  183. MessageRepository message,
  184. VisaPriceRepository visaPriceRep,
  185. CarTouristGuideGroundRepository carTouristGuideGroundRep,
  186. CheckBoxsRepository checkBoxs,
  187. GroupCostRepository GroupCostRepository,
  188. CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  189. GroupCostParameterRepository GroupCostParameterRepository,
  190. HotelPriceRepository hotelPriceRep,
  191. CustomersRepository customersRep,
  192. SetDataRepository setDataRep,
  193. TourClientListRepository tourClientListRep,
  194. TeamRateRepository teamRateRep,
  195. UsersRepository usersRep,
  196. IJuHeApiService juHeApi,
  197. InvertedListRepository invertedListRep,
  198. VisaFeeInfoRepository visaFeeInfoRep,
  199. TicketBlackCodeRepository ticketBlackCodeRep,
  200. HotelInquiryRepository hotelInquiryRep,
  201. ThreeCodeRepository threeCodeRepository,
  202. FeeAuditRepository feeAuditRep,
  203. VisaCommissionRepository visaCommissionRep,
  204. ForeignReceivablesRepository ffrRep,
  205. OpinionaireRepository opinionaireRep,
  206. TableOperationRecordRepository tableorRep,
  207. EnterExitCostDraftRepository enterExitCostDraftRep,
  208. RestaurantRepository restaurantRep,
  209. EnterExitCostQuoteRepository enterExitCostQuoteRep,
  210. GroupOrderPreInfoRepository grpOrderPreInfoRep,
  211. VisaProcessRepository visaProcessRep
  212. )
  213. {
  214. _logger = logger;
  215. _eec_textLogger = eec_textLogger;
  216. _groupTextLogger = groupTextLogger;
  217. _mapper = mapper;
  218. _grpScheduleRep = grpScheduleRep;
  219. _groupRepository = groupRepository;
  220. _taskAssignmentRep = taskAssignmentRep;
  221. _airTicketResRep = airTicketResRep;
  222. _sqlSugar = sqlSugar;
  223. url = AppSettingsHelper.Get("ExcelBaseUrl");
  224. path = AppSettingsHelper.Get("ExcelBasePath");
  225. if (!System.IO.Directory.Exists(path))
  226. {
  227. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  228. }
  229. _decreasePaymentsRep = decreasePaymentsRep;
  230. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  231. _delegationEnDataRep = delegationEnDataRep;
  232. _enterExitCostRep = enterExitCostRep;
  233. _delegationVisaRep = delegationVisaRep;
  234. _message = message;
  235. _visaPriceRep = visaPriceRep;
  236. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  237. _checkBoxs = checkBoxs;
  238. _GroupCostRepository = GroupCostRepository;
  239. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  240. _GroupCostParameterRepository = GroupCostParameterRepository;
  241. _hotelPriceRep = hotelPriceRep;
  242. _customersRep = customersRep;
  243. _setDataRep = setDataRep;
  244. _tourClientListRep = tourClientListRep;
  245. _teamRateRep = teamRateRep;
  246. _hubContext = hubContext;
  247. _usersRep = usersRep;
  248. _juHeApi = juHeApi;
  249. _invertedListRep = invertedListRep;
  250. _visaFeeInfoRep = visaFeeInfoRep;
  251. _ticketBlackCodeRep = ticketBlackCodeRep;
  252. _hotelInquiryRep = hotelInquiryRep;
  253. _threeCodeRepository = threeCodeRepository;
  254. _feeAuditRep = feeAuditRep;
  255. _visaCommissionRep = visaCommissionRep;
  256. _ffrRep = ffrRep;
  257. _opinionaireRep = opinionaireRep;
  258. _currencyInit = new List<CurrencyInfo>()
  259. {
  260. new(){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  261. new(){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  262. new(){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  263. new(){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  264. new(){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  265. };
  266. _portTypeData = new List<int>() { 2, 3 };
  267. _tableorRep = tableorRep;
  268. _enterExitCostDraftRep = enterExitCostDraftRep;
  269. _restaurantRep = restaurantRep;
  270. _enterExitCostQuoteRep = enterExitCostQuoteRep;
  271. _grpOrderPreInfoRep = grpOrderPreInfoRep;
  272. _visaProcessRep = visaProcessRep;
  273. }
  274. #region 流程管控
  275. /// <summary>
  276. /// 获取团组流程管控信息
  277. /// </summary>
  278. /// <param name="_jsonDto">查询参数</param>
  279. /// <returns></returns>
  280. [HttpPost]
  281. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  282. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  283. {
  284. if (string.IsNullOrEmpty(_jsonDto.Paras))
  285. {
  286. return Ok(JsonView(false, "参数为空"));
  287. }
  288. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  289. if (_ScheduleDto != null)
  290. {
  291. if (_ScheduleDto.SearchType == 2)//获取列表
  292. {
  293. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  294. return Ok(JsonView(_grpScheduleViewList));
  295. }
  296. else//获取对象
  297. {
  298. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  299. if (_grpScheduleView != null)
  300. {
  301. return Ok(JsonView(_grpScheduleView));
  302. }
  303. }
  304. }
  305. else
  306. {
  307. return Ok(JsonView(false, "参数反序列化失败"));
  308. }
  309. return Ok(JsonView(false, "暂无数据!"));
  310. }
  311. /// <summary>
  312. /// 修改团组流程管控详细表数据
  313. /// </summary>
  314. /// <param name="dto"></param>
  315. /// <returns></returns>
  316. [HttpPost]
  317. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  318. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  319. {
  320. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  321. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  322. .SetColumns(it => it.Duty == _detail.Duty)
  323. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  324. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  325. .SetColumns(it => it.JobContent == _detail.JobContent)
  326. .SetColumns(it => it.Remark == _detail.Remark)
  327. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  328. .Where(s => s.Id == dto.Id)
  329. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  330. .ExecuteCommandAsync();
  331. if (result > 0)
  332. {
  333. return Ok(JsonView(true, "保存成功!"));
  334. }
  335. return Ok(JsonView(false, "保存失败!"));
  336. }
  337. /// <summary>
  338. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  339. /// </summary>
  340. /// <param name="dto"></param>
  341. /// <returns></returns>
  342. [HttpPost]
  343. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  344. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  345. {
  346. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  347. _detail.IsDel = 1;
  348. _detail.DeleteUserId = dto.Duty;
  349. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  350. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  351. .SetColumns(it => it.IsDel == _detail.IsDel)
  352. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  353. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  354. .Where(it => it.Id == dto.Id)
  355. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  356. //.WhereColumns(s => s.Id == dto.Id)
  357. .ExecuteCommandAsync();
  358. if (result > 0)
  359. {
  360. return Ok(JsonView(true, "删除成功!"));
  361. }
  362. return Ok(JsonView(false, "删除失败!"));
  363. }
  364. /// <summary>
  365. /// 增加团组流程管控详细表数据
  366. /// </summary>
  367. /// <param name="dto"></param>
  368. /// <returns></returns>
  369. [HttpPost]
  370. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  371. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  372. {
  373. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  374. if (DateTime.Now < _detail.ExpectBeginDt)
  375. {
  376. _detail.StepStatus = 0;
  377. }
  378. else
  379. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  380. _detail.StepStatus = 1;
  381. }
  382. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  383. if (result > 0)
  384. {
  385. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  386. return Ok(JsonView(true, "添加成功!", _result));
  387. }
  388. return Ok(JsonView(false, "添加失败!"));
  389. }
  390. #endregion
  391. #region 团组前期信息
  392. /// <summary>
  393. /// 团组前期信息H5-URL(员工对应地址)
  394. /// </summary>
  395. /// <param name="name">用户名称</param>
  396. /// <returns></returns>
  397. [HttpGet]
  398. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  399. public async Task<IActionResult> GroupOrderPreInfoH5URLList([FromQuery] string name)
  400. {
  401. var userURLs = await _sqlSugar.Queryable<Sys_Users>()
  402. .Where(x => x.IsDel == 0)
  403. .WhereIF(!string.IsNullOrEmpty(name), x => x.CnName.Contains(name))
  404. .OrderBy(x => x.Id)
  405. .Select(x => new
  406. {
  407. name = x.CnName,
  408. url = $"http://oa.pan-american-intl.com:4399/#/MarketplacePick?userid={x.Id}",
  409. })
  410. .ToListAsync();
  411. return Ok(JsonView(true, "操作成功!", userURLs, userURLs.Count));
  412. }
  413. /// <summary>
  414. /// 团组前期信息 List
  415. /// </summary>
  416. /// <returns></returns>
  417. [HttpPost]
  418. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  419. public async Task<IActionResult> GroupOrderPreInfoList(GroupOrderPreInfoListDto dto)
  420. {
  421. var search = dto.Search;
  422. int[] nameTempIds = new int[] { 1, 12, 28 },
  423. countryTempIds = new int[] { 2, 13, 29 },
  424. daysTempIds = new int[] { 4, 15, 31 },
  425. ppNumTempIds = new int[] { 6 };
  426. var list = await _sqlSugar.Queryable<Grp_OrderPreInfo>()
  427. .LeftJoin<Sys_Users>((opi, u) => opi.CreateUserId == u.Id)
  428. .Where((opi, u) => opi.IsDel == 0)
  429. .OrderByDescending((opi, u) => opi.CreateTime)
  430. .Select((opi, u) => new GroupOrderPreInfoListView()
  431. {
  432. Id = opi.Id,
  433. Name = opi.Name,
  434. UnitName = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && nameTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  435. VisitCountryVal = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && countryTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  436. VisitDays = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && daysTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  437. VisiPpNum = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && ppNumTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  438. Operator = u.CnName,
  439. OperationTime = opi.CreateTime
  440. })
  441. //.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search) || x.UnitName.Contains(search) || x.VisitCountrys.Contains(search))
  442. //.ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  443. .ToListAsync();
  444. var listPageData = list.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search) || x.UnitName.Contains(search) || x.VisitCountrys.Contains(search)).ToList();
  445. int total = list.Count;
  446. int totalPageCount = (int)Math.Ceiling(list.Count / (double)dto.PageSize);
  447. var listPageData1 = listPageData
  448. .Skip((dto.PageIndex - 1) * dto.PageSize)
  449. .Take(dto.PageSize)
  450. .ToList();
  451. var infoIds = listPageData1.Select(x => x.Id).ToList();
  452. var typeDatas = await _sqlSugar.Queryable<Sys_SetData>()
  453. .Where(x => x.IsDel == 0 && x.STid == 109)
  454. .ToArrayAsync();
  455. var items = await _sqlSugar.Queryable<Grp_OrderPreItem>()
  456. .LeftJoin<Sys_FormTemp>((opi, ft) => opi.FormTempId == ft.Id)
  457. .Where((opi, ft) => opi.IsDel == 0 && infoIds.Contains(opi.ParentId))
  458. .Select((opi, ft) => new { opi.ParentId, opi.FormTempId, ft.TempId })
  459. .ToListAsync();
  460. foreach (var item in listPageData1)
  461. {
  462. var typeDatas1 = typeDatas.Select(x => new
  463. {
  464. x.Id,
  465. x.Name,
  466. IsNull = !items.Any(x1 => item.Id == x1.ParentId && x.Id == x1.TempId)
  467. }).ToArray();
  468. item.VersionDetails = typeDatas1;
  469. }
  470. return Ok(JsonView(listPageData1, listPageData1.Count));
  471. }
  472. /// <summary>
  473. /// 团组前期信息 Init
  474. /// </summary>
  475. /// <returns></returns>
  476. [HttpGet("{userId}")]
  477. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  478. public async Task<IActionResult> GroupOrderPreInfo(int userId)
  479. {
  480. return Ok(await _grpOrderPreInfoRep.DataInit(userId));
  481. }
  482. /// <summary>
  483. /// 国家数据源
  484. /// </summary>
  485. /// <param name="pageIndex">当前页码</param>
  486. /// <param name="pageSize">每页条数</param>
  487. /// <param name="search">查询条件</param>
  488. /// <returns></returns>
  489. [HttpGet]
  490. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  491. public async Task<IActionResult> CountryInit([FromQuery] int pageIndex, [FromQuery] int pageSize, [FromQuery] string search)
  492. {
  493. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => x.Country).Distinct().ToListAsync();
  494. if (pageIndex == 0 && pageSize == 0)
  495. {
  496. //所有数据
  497. return Ok(JsonView(countrys, countrys.Count));
  498. }
  499. //分页
  500. int skip = (pageIndex - 1) * pageSize;
  501. int take = pageSize;
  502. if (!string.IsNullOrEmpty(search))
  503. {
  504. IEnumerable<char> charSequence = search.Select(c => c);
  505. var pageResult1 = countrys.Where(x => charSequence.All(x1 => x.Contains(x1))).ToList();
  506. var pageData = pageResult1.Skip(skip).Take(take).ToList();
  507. return Ok(JsonView(pageData, pageResult1.Count));
  508. }
  509. var pageResult2 = countrys.Skip(skip).Take(take).ToList();
  510. return Ok(JsonView(pageResult2, countrys.Count));
  511. }
  512. /// <summary>
  513. /// 城市数据源
  514. /// </summary>
  515. /// <param name="countryLabel">国家名称 多个使用英文逗号隔开</param>
  516. /// <param name="pageIndex">当前页码</param>
  517. /// <param name="pageSize">每页条数</param>
  518. /// <param name="search">查询条件</param>
  519. /// <returns></returns>
  520. [HttpGet("{countryLabel}")]
  521. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  522. public async Task<IActionResult> CityByCountry(
  523. string countryLabel,
  524. [FromQuery] int pageIndex,
  525. [FromQuery] int pageSize,
  526. [FromQuery] string search)
  527. {
  528. countryLabel = HttpUtility.UrlDecode(countryLabel);
  529. var countryList = countryLabel.Split(',', StringSplitOptions.RemoveEmptyEntries).ToArray();
  530. var citys = Array.Empty<string?>();
  531. if (countryList.Any())
  532. {
  533. var cityDatas = await _sqlSugar
  534. .Queryable<Grp_NationalTravelFee>()
  535. .Where(x => x.IsDel == 0 && countryList.Contains(x.Country) && !string.IsNullOrEmpty(x.City))
  536. .ToArrayAsync();
  537. foreach (var item in cityDatas)
  538. {
  539. if (item.City.Contains("城市"))
  540. {
  541. item.City = item.Country + "-所有城市";
  542. }
  543. }
  544. var cityDatas1 = cityDatas.OrderBy(x => x.Country);
  545. citys = cityDatas1.Select(x => x.City).Distinct().ToArray();
  546. }
  547. if (pageIndex == 0 && pageSize == 0)
  548. {
  549. //所有数据
  550. return Ok(JsonView(citys, citys?.Length ?? 0));
  551. }
  552. //分页
  553. int skip = (pageIndex - 1) * pageSize;
  554. int take = pageSize;
  555. if (!string.IsNullOrEmpty(search))
  556. {
  557. IEnumerable<char> charSequence = search.Select(c => c);
  558. var pageResult1 = citys.Where(x => charSequence.All(x1 => x.Contains(x1))).ToList();
  559. var pageData = pageResult1.Skip(skip).Take(take).ToList();
  560. return Ok(JsonView(pageData, pageResult1.Count));
  561. }
  562. var pageResult2 = citys.Skip(skip).Take(take).ToList();
  563. return Ok(JsonView(pageResult2, citys?.Length ?? 0));
  564. }
  565. /// <summary>
  566. /// 团组前期信息 Info
  567. /// </summary>
  568. /// <param name="dto">Id</param>
  569. /// <returns></returns>
  570. [HttpGet("{Id}/{TempId}")]
  571. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  572. public async Task<IActionResult> GroupOrderPreInfo([FromRoute] GroupOrderPreInfoDto dto)
  573. {
  574. return Ok(await _grpOrderPreInfoRep.InfoAsync(dto.Id, dto.TempId));
  575. }
  576. /// <summary>
  577. /// 团组前期信息 移动端 Info
  578. /// </summary>
  579. /// <param name="dto">Id</param>
  580. /// <returns></returns>
  581. [HttpGet("{Id}/{TempId}")]
  582. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  583. public async Task<IActionResult> GroupOrderPreMobileInfo([FromRoute] GroupOrderPreInfoDto dto)
  584. {
  585. return Ok(await _grpOrderPreInfoRep.MobileInfoAsync(dto.Id, dto.TempId));
  586. }
  587. /// <summary>
  588. /// 团组前期信息 Save
  589. /// </summary>
  590. /// <param name="dto">Id</param>
  591. /// <returns></returns>
  592. [HttpPost]
  593. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  594. public async Task<IActionResult> GroupOrderPreInfoSave(GroupOrderPreInfoOpDto dto)
  595. {
  596. return Ok(await _grpOrderPreInfoRep.OpAsync(dto));
  597. }
  598. /// <summary>
  599. /// 团组前期信息 Del
  600. /// </summary>
  601. /// <param name="dto">Id</param>
  602. /// <returns></returns>
  603. [HttpPost]
  604. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  605. public async Task<IActionResult> GroupOrderPreInfoDel(GroupOrderPreInfoDelDto dto)
  606. {
  607. return Ok(await _grpOrderPreInfoRep.DelAsync(dto));
  608. }
  609. /// <summary>
  610. /// 团组前期信息 文件下载
  611. /// </summary>
  612. /// <param name="dto">Id</param>
  613. /// <returns></returns>
  614. [HttpGet("{Id}/{TempId}")]
  615. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  616. public async Task<IActionResult> GroupOrderPreInfoFileDownload([FromRoute] GroupOrderPreInfoDto dto)
  617. {
  618. int id = dto.Id, tempId = dto.TempId;
  619. var view = await _grpOrderPreInfoRep.InfoAsync(id, tempId);
  620. var data = view.Data as GrpOrderPreInfoView;
  621. #region Excel
  622. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  623. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  624. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "GroupOrderPreInfo/";
  625. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "GroupOrderPreInfo/";
  626. var fileNamePrefix = string.Empty;
  627. if (tempId == 1405)
  628. {
  629. tempPath += $"前期需客户提供信息_无商邀版Temp.xlsx";
  630. fileNamePrefix = $"{data.Name}_无商邀版";
  631. }
  632. else if (tempId == 1406)
  633. {
  634. tempPath += $"前期需客户提供信息_有商邀版Temp.xlsx";
  635. fileNamePrefix = $"{data.Name}_有商邀版";
  636. }
  637. else
  638. {
  639. //tempId == 1404 默认下载
  640. tempPath += $"前期需客户提供信息_单接送机Temp.xlsx";
  641. fileNamePrefix = $"{data.Name}_单接送机";
  642. }
  643. foreach (var item in data.Items)
  644. {
  645. var obj = item.NewValue;
  646. if (obj == null) item.OriginVal = "";
  647. else if (obj.Equals("有") || obj.Equals("无"))
  648. {
  649. item.OriginVal = obj.ToString();
  650. }
  651. else if (obj is object[] objArray)
  652. {
  653. string[] stringArray = Array.ConvertAll(objArray, item => item?.ToString() ?? string.Empty);
  654. item.OriginVal = string.Join("、", stringArray);
  655. }
  656. else if (obj is string[] stringArray)
  657. {
  658. item.OriginVal = string.Join("、", stringArray);
  659. }
  660. else if (obj.Equals("-"))
  661. {
  662. item.OriginVal = "";
  663. }
  664. }
  665. var fileName = $"{fileNamePrefix}{CommonFun.GUID}.xlsx";
  666. fileName = CommonFun.ValidFileName(fileName);
  667. //载入模板
  668. var designer = new WorkbookDesigner
  669. {
  670. Workbook = new Workbook(tempPath)
  671. };
  672. if (tempId == 1406)
  673. {
  674. var view1 = data.Items.Where(x => x.Index < 11).ToArray();
  675. var view2 = data.Items.Where(x => x.Index > 10).ToArray();
  676. for (int i = 1; i <= view2.Length; i++)
  677. {
  678. view2[i - 1].Index = i;
  679. }
  680. designer.SetDataSource("View1", view1);
  681. designer.SetDataSource("View2", view2);
  682. }
  683. else
  684. {
  685. designer.SetDataSource("View", data.Items);
  686. }
  687. designer.Process();
  688. if (!Directory.Exists(savePath))
  689. {
  690. Directory.CreateDirectory(savePath);
  691. }
  692. string serverPath = $"{savePath}{fileName}";
  693. designer.Workbook.Save(serverPath);
  694. string rst = $"{servicePath}{ftpPath}{fileName}";
  695. #endregion
  696. return Ok(JsonView(new { url = rst }));
  697. }
  698. #endregion
  699. #region 团组基本信息
  700. /// <summary>
  701. /// 接团信息列表
  702. /// </summary>
  703. /// <param name="dto">团组列表请求dto</param>
  704. /// <returns></returns>
  705. [HttpPost]
  706. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  707. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  708. {
  709. var groupData = await _groupRepository.GetGroupList(dto);
  710. if (groupData.Code != 0)
  711. {
  712. return Ok(JsonView(false, groupData.Msg));
  713. }
  714. return Ok(JsonView(groupData.Data));
  715. }
  716. /// <summary>
  717. /// 分页查询团组列表
  718. /// </summary>
  719. /// <param name="dto"></param>
  720. /// <returns></returns>
  721. [HttpPost]
  722. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  723. public async Task<IActionResult> QueryGroupListOffset(QueryGroupListOffsetDto dto)
  724. {
  725. var watch = new Stopwatch();
  726. watch.Start();
  727. RefAsync<int> total = 0;
  728. var countyDatas = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  729. .Where((di) => di.IsDel == 0 && !string.IsNullOrWhiteSpace(di.TeamName))
  730. .WhereIF(!string.IsNullOrEmpty(dto.Search), (di) => di.TeamName.Contains(dto.Search))
  731. .OrderBy((di) => new { id = SqlFunc.Desc(di.Id) })
  732. .Select((di) => new { id = di.Id, name = di.TeamName, di.ClientName, di.VisitPNumber, di.VisitCountry, di.VisitDays, di.VisitStartDate, di.VisitEndDate, di.TourCode })
  733. .Distinct()
  734. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  735. watch.Stop();
  736. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  737. }
  738. /// <summary>
  739. /// 接团信息列表 Page Init
  740. /// </summary>
  741. /// <returns></returns>
  742. [HttpPost]
  743. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  744. public async Task<IActionResult> PostGroupPageListInit()
  745. {
  746. var depDatas = await GeneralMethod.GroupOpAffiliationBranchInit();
  747. var rankDatas = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 56).Select(x => new { x.Id, x.Name }).ToListAsync();
  748. rankDatas.Insert(0, new { Id = 0, Name = "全部" });
  749. var _view = new
  750. {
  751. depData = depDatas,
  752. rankData = rankDatas
  753. };
  754. return Ok(JsonView(true, "查询成功!", _view));
  755. }
  756. /// <summary>
  757. /// 接团信息列表 Page
  758. /// </summary>
  759. /// <param name="dto">团组列表请求dto</param>
  760. /// <returns></returns>
  761. [HttpPost]
  762. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  763. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  764. {
  765. #region 参数验证
  766. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  767. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  768. #region 页面操作权限验证
  769. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  770. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  771. #endregion
  772. #endregion
  773. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  774. {
  775. string sqlWhere = string.Empty;
  776. if (dto.IsSure == 0) //未完成
  777. {
  778. sqlWhere += string.Format(@" And IsSure = 0");
  779. }
  780. else if (dto.IsSure == 1) //已完成
  781. {
  782. sqlWhere += string.Format(@" And IsSure = 1");
  783. }
  784. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  785. {
  786. string tj = dto.SearchCriteria;
  787. 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}%')",
  788. tj, tj, tj, tj, tj);
  789. }
  790. if (int.TryParse(dto.Rank, out int rankId))
  791. {
  792. if (rankId > 0) sqlWhere += string.Format("And gdi.TeamLevSId = {0}", rankId);
  793. }
  794. string sqlWhere1 = string.Empty;
  795. if (!string.IsNullOrEmpty(dto.Department) && !dto.Department.Equals("全部"))
  796. {
  797. sqlWhere1 = string.Format("Where Department = '{0}'", dto.Department);
  798. }
  799. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,Department,
  800. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  801. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  802. JietuanOperator,IsSure,CreateTime,IsBid,Step
  803. From (
  804. Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
  805. CASE WHEN gdi.JietuanOperator = 4 OR gdi.JietuanOperator = 21 THEN '国交部'
  806. ELSE (Select DepName FROM OA2023DB.dbo.Sys_Department WHERE Id = su.DepId) END AS 'Department',
  807. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,gdi.Step,
  808. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  809. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  810. su.CnName JietuanOperator,IsSure,gdi.CreateTime,gdi.IsBid
  811. From Grp_DelegationInfo gdi
  812. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  813. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  814. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  815. Where gdi.IsDel = 0 {0}
  816. ) temp {1}", sqlWhere, sqlWhere1);
  817. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  818. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  819. //处理 团组模块实际操作人
  820. _DelegationList.ForEach(async x =>
  821. {
  822. var operators = GeneralMethod.GetGroupModuleOperators(x.Id);
  823. var operatorNames = new StringBuilder();
  824. //operatorNames.AppendLine("各模块实际操作人:");
  825. if (operators.Any())
  826. {
  827. operators.ForEach(y =>
  828. {
  829. string label = string.Empty;
  830. if (y.OperationUsers.Any())
  831. {
  832. var users = y.OperationUsers.Select(x => x.UserName).ToList();
  833. label = string.Join('、', users);
  834. }
  835. else label = "暂未指定";
  836. operatorNames.AppendLine($"{y.CTableName}:{label}");
  837. operatorNames.AppendLine();
  838. });
  839. }
  840. x.OperatorLabel = operatorNames.ToString().TrimEnd('\n', '\r');
  841. });
  842. var _view = new
  843. {
  844. PageFuncAuth = pageFunAuthView,
  845. Data = _DelegationList
  846. };
  847. return Ok(JsonView(true, "查询成功!", _view, total));
  848. }
  849. else
  850. {
  851. return Ok(JsonView(false, "查询失败"));
  852. }
  853. }
  854. /// <summary>
  855. /// 团组列表
  856. /// </summary>
  857. /// <returns></returns>
  858. [HttpPost]
  859. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  860. {
  861. #region 参数验证
  862. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  863. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  864. #region 页面操作权限验证
  865. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  866. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  867. #endregion
  868. #endregion
  869. if (dto.PortType != 1 && dto.PortType != 2)
  870. {
  871. return Ok(JsonView(false, "查询失败!"));
  872. }
  873. string orderbyStr = "order by gdi.CreateTime Desc";
  874. string sqlWhere = string.Empty;
  875. if (dto.IsSure == 0) //未完成
  876. {
  877. sqlWhere += string.Format(@" And IsSure = 0");
  878. }
  879. else if (dto.IsSure == 1) //已完成
  880. {
  881. sqlWhere += string.Format(@" And IsSure = 1");
  882. }
  883. //团组类型
  884. if (dto.TeamDid > 0)
  885. {
  886. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  887. }
  888. //团组名称
  889. if (!string.IsNullOrEmpty(dto.TeamName))
  890. {
  891. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  892. }
  893. //客户名称
  894. if (!string.IsNullOrEmpty(dto.ClientName))
  895. {
  896. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  897. }
  898. //客户单位
  899. if (!string.IsNullOrEmpty(dto.ClientUnit))
  900. {
  901. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  902. }
  903. //出访时间
  904. if (!string.IsNullOrEmpty(dto.visitDataTime))
  905. {
  906. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  907. orderbyStr = "order by gdi.VisitDate";
  908. }
  909. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  910. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  911. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  912. JietuanOperator,IsSure,CreateTime
  913. From (
  914. Select row_number() over({0}) as Row_Number,
  915. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  916. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  917. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  918. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  919. From Grp_DelegationInfo gdi
  920. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  921. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  922. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  923. Where gdi.IsDel = 0 {1}
  924. ) temp ", orderbyStr, sqlWhere);
  925. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  926. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  927. #region 处理所属部门
  928. /*
  929. * 1.sq 和 gyy 等显示 市场部
  930. * 2.王鸽和主管及张总还有管理员号统一国交部
  931. * 2-1. 4 管理员 ,21 张海麟
  932. */
  933. var userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  934. var userIds1 = new List<int>() { 4, 21 };
  935. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  936. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  937. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  938. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  939. .ToList();
  940. foreach (var item in _DelegationList)
  941. {
  942. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  943. }
  944. #endregion
  945. var _view = new
  946. {
  947. PageFuncAuth = pageFunAuthView,
  948. Data = _DelegationList
  949. };
  950. return Ok(JsonView(true, "查询成功!", _view, total));
  951. }
  952. /// <summary>
  953. /// 接团信息详情
  954. /// </summary>
  955. /// <param name="dto">团组info请求dto</param>
  956. /// <returns></returns>
  957. [HttpPost]
  958. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  959. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  960. {
  961. var groupData = await _groupRepository.GetGroupInfo(dto);
  962. if (groupData.Code != 0)
  963. {
  964. return Ok(JsonView(false, groupData.Msg));
  965. }
  966. return Ok(JsonView(groupData.Data));
  967. }
  968. /// <summary>
  969. /// 接团信息 编辑添加
  970. /// 基础信息数据源
  971. /// </summary>
  972. /// <param name="dto"></param>
  973. /// <returns></returns>
  974. [HttpPost]
  975. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  976. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  977. {
  978. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  979. if (groupData.Code != 0)
  980. {
  981. return Ok(JsonView(false, groupData.Msg));
  982. }
  983. return Ok(JsonView(groupData.Data));
  984. }
  985. /// <summary>
  986. /// 成本修改团组信息
  987. /// </summary>
  988. /// <param name="dto"></param>
  989. /// <returns></returns>
  990. [HttpPost]
  991. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  992. public async Task<IActionResult> GroupCostEditGroupInfo(GroupCostEditGroupInfoDto dto)
  993. {
  994. var jw = JsonView(false, "操作失败");
  995. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  996. if (di == null)
  997. {
  998. jw.Msg = "参数有误!";
  999. return Ok(jw);
  1000. }
  1001. #region 添加出访起止时间
  1002. var startTime = new DateTime();
  1003. var endTime = new DateTime();
  1004. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1005. {
  1006. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1007. }
  1008. else
  1009. {
  1010. jw.Msg = "参数有误!";
  1011. return Ok(jw);
  1012. }
  1013. #endregion
  1014. di.VisitDate = startTime;
  1015. di.VisitPNumber = dto.VisitPNumber;
  1016. di.VisitDays = dto.VisitDays;
  1017. di.VisitStartDate = startTime;
  1018. di.VisitEndDate = endTime;
  1019. var count = _sqlSugar.Updateable(di)
  1020. .UpdateColumns(x => new { x.VisitDate, x.VisitPNumber, x.VisitDays, x.VisitStartDate, x.VisitEndDate })
  1021. .ExecuteCommand();
  1022. return Ok(count > 0 ? JsonView(true, "操作成功") : jw);
  1023. }
  1024. /// <summary>
  1025. /// 接团信息 编辑添加
  1026. /// 省份-城市 基础信息数据源
  1027. /// </summary>
  1028. /// <param name="dto"></param>
  1029. /// <returns></returns>
  1030. [HttpPost]
  1031. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1032. public async Task<IActionResult> GroupProvCityBasicSource(GroupProvCityBasicSourceDto dto)
  1033. {
  1034. int pageIndex = dto.PageIndex, pageSize = dto.PageSize;
  1035. string search = dto.Search;
  1036. var data = await _groupRepository.CityBasicSource();
  1037. int total = data.Length;
  1038. data = data.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search))
  1039. .Skip((pageIndex - 1) * pageSize)
  1040. .Take(pageSize)
  1041. .ToArray();
  1042. return Ok(JsonView(data, total));
  1043. }
  1044. /// <summary>
  1045. /// 接团信息 操作(增改)
  1046. /// </summary>
  1047. /// <param name="dto"></param>
  1048. /// <returns></returns>
  1049. [HttpPost]
  1050. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1051. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  1052. {
  1053. // 创建 Stopwatch 实例
  1054. Stopwatch stopwatch = Stopwatch.StartNew();
  1055. decimal ffrPrice = 0.00M;
  1056. DateTime? visitDt = null;
  1057. if (dto.Status == 2)
  1058. {
  1059. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1060. if (groupInfo != null)
  1061. {
  1062. ffrPrice = groupInfo.PaymentMoney;
  1063. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1064. }
  1065. }
  1066. var groupData = await _groupRepository.GroupOperation(dto);
  1067. if (groupData.Code != 0)
  1068. {
  1069. return Ok(JsonView(false, groupData.Msg));
  1070. }
  1071. int diId = 0;
  1072. try
  1073. {
  1074. //添加时 默认加入团组汇率
  1075. if (dto.Status == 1) //添加
  1076. {
  1077. diId = groupData.Data;
  1078. //添加默认币种
  1079. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1080. //默认分配权限
  1081. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1082. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1083. var _managerIds = new List<int>() { 22, 32, 21 };
  1084. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1085. if (userIds.Count > 0)
  1086. {
  1087. userIds.Add(208);
  1088. //创建团组管控
  1089. GroupStepForDelegation.CreateWorkStep(diId);
  1090. //发送消息
  1091. string groupName = dto.TeamName;
  1092. string createGroupUser = string.Empty;
  1093. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1094. if (userInfo != null) createGroupUser = userInfo.CnName;
  1095. string title = $"系统通知";
  1096. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1097. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1098. }
  1099. //默认创建倒推表
  1100. await _invertedListRep._Create(dto.UserId, diId);
  1101. //默认创建签证流程
  1102. await _visaProcessRep.Create(dto.UserId, diId);
  1103. }
  1104. else if (dto.Status == 2)
  1105. {
  1106. diId = dto.Id;
  1107. }
  1108. #region 签证人员团组时间通知
  1109. #region 计算出访起止时间
  1110. var startTime = new DateTime();
  1111. var endTime = new DateTime();
  1112. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1113. {
  1114. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1115. }
  1116. #endregion
  1117. #endregion
  1118. #region 团组操作默认添加/修改收款账单
  1119. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1120. {
  1121. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1122. .Where(x => x.IsDel == 0 &&
  1123. x.Diid == diId &&
  1124. x.Remark.Equals("预付款")
  1125. )
  1126. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1127. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1128. .FirstAsync();
  1129. ffrInfo = new Fin_ForeignReceivables()
  1130. {
  1131. Diid = diId,
  1132. PriceName = dto.ClientUnit,
  1133. Price = dto.PaymentMoney,
  1134. Count = 1,
  1135. Unit = $"元",
  1136. ItemSumPrice = dto.PaymentMoney,
  1137. Rate = 1.0000M,
  1138. Currency = 836,
  1139. AddingWay = 0,
  1140. CreateUserId = dto.UserId,
  1141. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1142. Remark = $"预付款"
  1143. };
  1144. if (ffrInfo == null) //Add
  1145. {
  1146. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1147. }
  1148. else //修改
  1149. {
  1150. await _sqlSugar.Updateable(ffrInfo)
  1151. .UpdateColumns(x => new
  1152. {
  1153. x.PriceName,
  1154. x.Price,
  1155. x.ItemSumPrice,
  1156. x.CreateTime,
  1157. x.CreateUserId
  1158. })
  1159. .WhereColumns(x => x.Id)
  1160. .ExecuteCommandAsync();
  1161. }
  1162. }
  1163. #endregion
  1164. if (diId > 0)
  1165. {
  1166. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1167. }
  1168. // 停止计时
  1169. stopwatch.Stop();
  1170. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  1171. }
  1172. catch (Exception ex)
  1173. {
  1174. // 停止计时
  1175. stopwatch.Stop();
  1176. Logs("[response]" + JsonConvert.SerializeObject(dto));
  1177. Logs(ex.Message);
  1178. //return Ok(JsonView(false, $"{ex.Message}[{stopwatch.ElapsedMilliseconds}ms]"));
  1179. }
  1180. // 停止计时
  1181. stopwatch.Stop();
  1182. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  1183. }
  1184. /// <summary>
  1185. /// 接团流程操作(增改)
  1186. /// 安卓端使用 建团时添加客户名单
  1187. /// </summary>
  1188. /// <param name="dto"></param>
  1189. /// <returns></returns>
  1190. [HttpPost]
  1191. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1192. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  1193. {
  1194. #region 参数验证
  1195. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  1196. #region 页面操作权限验证
  1197. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  1198. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  1199. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  1200. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  1201. #endregion
  1202. #endregion
  1203. try
  1204. {
  1205. //_sqlSugar.BeginTran();
  1206. decimal ffrPrice = 0.00M;
  1207. DateTime? visitDt = null;
  1208. if (dto.Status == 2)
  1209. {
  1210. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1211. if (groupInfo != null)
  1212. {
  1213. ffrPrice = groupInfo.PaymentMoney;
  1214. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1215. }
  1216. }
  1217. var _dto = new GroupOperationDto();
  1218. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  1219. var groupData = await _groupRepository.GroupOperation(_dto);
  1220. if (groupData.Code != 0)
  1221. {
  1222. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  1223. }
  1224. int diId = 0;
  1225. //添加时 默认加入团组汇率
  1226. if (dto.Status == 1) //添加
  1227. {
  1228. diId = groupData.Data;
  1229. //添加默认币种
  1230. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1231. //默认分配权限
  1232. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1233. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1234. var _managerIds = new List<int>() { 21, 22, 32 };
  1235. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1236. if (userIds.Count > 0)
  1237. {
  1238. userIds.Add(208);
  1239. //创建团组管控
  1240. GroupStepForDelegation.CreateWorkStep(diId);
  1241. //发送消息
  1242. string groupName = dto.TeamName;
  1243. string createGroupUser = string.Empty;
  1244. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1245. if (userInfo != null) createGroupUser = userInfo.CnName;
  1246. string title = $"系统通知";
  1247. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1248. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1249. }
  1250. #region 应用推送
  1251. try
  1252. {
  1253. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1254. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1255. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1256. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1257. {
  1258. var userList = new List<string>() { users.QiyeChatUserId };
  1259. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1260. }
  1261. }
  1262. catch (Exception ex)
  1263. {
  1264. }
  1265. #endregion
  1266. //默认创建倒推表
  1267. await _invertedListRep._Create(dto.UserId, diId);
  1268. }
  1269. if (dto.Status == 2)
  1270. {
  1271. diId = dto.Id;
  1272. if (diId == 0)
  1273. {
  1274. //_sqlSugar.RollbackTran();
  1275. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  1276. }
  1277. }
  1278. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1279. if (viewData.Code != 0)
  1280. {
  1281. //_sqlSugar.RollbackTran();
  1282. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1283. }
  1284. #region 团组操作默认添加/修改收款账单
  1285. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1286. {
  1287. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1288. .Where(x => x.IsDel == 0 &&
  1289. x.Diid == diId &&
  1290. x.Remark.Equals("预付款")
  1291. )
  1292. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1293. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1294. .FirstAsync();
  1295. ffrInfo = new Fin_ForeignReceivables()
  1296. {
  1297. Diid = diId,
  1298. PriceName = dto.ClientUnit,
  1299. Price = dto.PaymentMoney,
  1300. Count = 1,
  1301. Unit = $"元",
  1302. ItemSumPrice = dto.PaymentMoney,
  1303. Rate = 1.0000M,
  1304. Currency = 836,
  1305. AddingWay = 0,
  1306. CreateUserId = dto.UserId,
  1307. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1308. Remark = $"预付款"
  1309. };
  1310. if (ffrInfo == null) //Add
  1311. {
  1312. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1313. }
  1314. else //修改
  1315. {
  1316. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1317. .UpdateColumns(x => new
  1318. {
  1319. x.PriceName,
  1320. x.Price,
  1321. x.ItemSumPrice,
  1322. x.CreateTime,
  1323. x.CreateUserId
  1324. })
  1325. .WhereColumns(x => x.Id)
  1326. .ExecuteCommandAsync();
  1327. }
  1328. }
  1329. #endregion
  1330. #region 签证人员团组时间通知
  1331. #region 计算出访起止时间
  1332. var startTime = new DateTime();
  1333. var endTime = new DateTime();
  1334. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1335. {
  1336. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1337. }
  1338. #endregion
  1339. if (diId > 0)
  1340. {
  1341. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1342. }
  1343. #endregion
  1344. //_sqlSugar.CommitTran();
  1345. return Ok(JsonView(true, "添加成功"));
  1346. }
  1347. catch (Exception ex)
  1348. {
  1349. _sqlSugar.RollbackTran();
  1350. return Ok(JsonView(false, ex.Message));
  1351. }
  1352. }
  1353. /// <summary>
  1354. /// 接团流程操作(增改)
  1355. /// 安卓端使用 建团时添加客户名单
  1356. /// </summary>
  1357. /// <param name="dto"></param>
  1358. /// <returns></returns>
  1359. [HttpPost]
  1360. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1361. public async Task<IActionResult> GroupProcessOperation1(GroupProcessOperationDto dto)
  1362. {
  1363. #region 参数验证
  1364. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  1365. #region 页面操作权限验证
  1366. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  1367. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  1368. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  1369. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  1370. #endregion
  1371. #endregion
  1372. _sqlSugar.BeginTran();
  1373. decimal ffrPrice = 0.00M;
  1374. DateTime? visitDt = null;
  1375. if (dto.Status == 2)
  1376. {
  1377. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1378. if (groupInfo != null)
  1379. {
  1380. ffrPrice = groupInfo.PaymentMoney;
  1381. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1382. }
  1383. }
  1384. var _dto = new GroupOperationDto();
  1385. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  1386. var groupData = await _groupRepository.GroupOperation(_dto);
  1387. if (groupData.Code != 0)
  1388. {
  1389. _sqlSugar.RollbackTran();
  1390. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  1391. }
  1392. try
  1393. {
  1394. int diId = 0;
  1395. //添加时 默认加入团组汇率
  1396. if (dto.Status == 1) //添加
  1397. {
  1398. diId = groupData.Data;
  1399. //添加默认币种
  1400. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1401. //默认分配权限
  1402. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1403. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1404. var _managerIds = new List<int>() { 21, 22, 32 };
  1405. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1406. if (userIds.Count > 0)
  1407. {
  1408. userIds.Add(208);
  1409. //创建团组管控
  1410. GroupStepForDelegation.CreateWorkStep(diId);
  1411. //发送消息
  1412. string groupName = dto.TeamName;
  1413. string createGroupUser = string.Empty;
  1414. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1415. if (userInfo != null) createGroupUser = userInfo.CnName;
  1416. string title = $"系统通知";
  1417. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1418. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1419. }
  1420. #region 应用推送
  1421. try
  1422. {
  1423. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1424. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1425. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1426. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1427. {
  1428. var userList = new List<string>() { users.QiyeChatUserId };
  1429. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1430. }
  1431. }
  1432. catch (Exception ex)
  1433. {
  1434. _sqlSugar.CommitTran();
  1435. return Ok(JsonView(true, "操作成功! 应用推送异常:" + groupData.Msg));
  1436. }
  1437. #endregion
  1438. //默认创建倒推表
  1439. await _invertedListRep._Create(dto.UserId, diId);
  1440. }
  1441. else if (dto.Status == 2)
  1442. {
  1443. diId = dto.Id;
  1444. if (diId == 0)
  1445. {
  1446. _sqlSugar.RollbackTran();
  1447. return Ok(JsonView(false, "操作失败! 未添加团组id" + groupData.Msg));
  1448. }
  1449. }
  1450. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1451. if (viewData.Code != 0)
  1452. {
  1453. _sqlSugar.RollbackTran();
  1454. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1455. }
  1456. #region 团组操作默认添加/修改收款账单
  1457. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1458. {
  1459. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1460. .Where(x => x.IsDel == 0 &&
  1461. x.Diid == diId &&
  1462. x.Remark.Equals("预付款")
  1463. )
  1464. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1465. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1466. .FirstAsync();
  1467. ffrInfo = new Fin_ForeignReceivables()
  1468. {
  1469. Diid = diId,
  1470. PriceName = dto.ClientUnit,
  1471. Price = dto.PaymentMoney,
  1472. Count = 1,
  1473. Unit = $"元",
  1474. ItemSumPrice = dto.PaymentMoney,
  1475. Rate = 1.0000M,
  1476. Currency = 836,
  1477. AddingWay = 0,
  1478. CreateUserId = dto.UserId,
  1479. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1480. Remark = $"预付款"
  1481. };
  1482. if (ffrInfo == null) //Add
  1483. {
  1484. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1485. }
  1486. else //修改
  1487. {
  1488. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1489. .UpdateColumns(x => new
  1490. {
  1491. x.PriceName,
  1492. x.Price,
  1493. x.ItemSumPrice,
  1494. x.CreateTime,
  1495. x.CreateUserId
  1496. })
  1497. .WhereColumns(x => x.Id)
  1498. .ExecuteCommandAsync();
  1499. }
  1500. }
  1501. #endregion
  1502. #region 签证人员团组时间通知
  1503. #region 计算出访起止时间
  1504. var startTime = new DateTime();
  1505. var endTime = new DateTime();
  1506. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1507. {
  1508. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1509. }
  1510. #endregion
  1511. if (diId > 0)
  1512. {
  1513. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1514. }
  1515. #endregion
  1516. _sqlSugar.CommitTran();
  1517. return Ok(JsonView(true));
  1518. }
  1519. catch (Exception ex)
  1520. {
  1521. _sqlSugar.RollbackTran();
  1522. return Ok(JsonView(false, ex.Message));
  1523. }
  1524. }
  1525. /// <summary>
  1526. /// 接团信息 操作(删除)
  1527. /// </summary>
  1528. /// <param name="dto"></param>
  1529. /// <returns></returns>
  1530. [HttpPost]
  1531. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1532. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  1533. {
  1534. var diId = dto.Id;
  1535. if (diId < 1) return Ok(JsonView(false, MsgTips.Id));
  1536. #region 删除 验证
  1537. /*
  1538. * 1、收款账单数据:0 条
  1539. * 2、收款退还数据:0 条
  1540. * 3、机票费用数据:0 条
  1541. * 4、签证费用数据:0 条
  1542. * 5、保险费用数据:0 条
  1543. * 6、酒店费用数据:0 条
  1544. * 7、公务出访数据:1 条
  1545. * 8、邀请公务活动费用数据:1 条
  1546. * 9、OP费用数据:5 条
  1547. * 10、其他费用数据:0 条
  1548. * 11、团组日付报销费用数据:0 条
  1549. *
  1550. * 温馨提示:该团组已产生费用,不允许删除;如需删除,请先删除对应版块费用,谢谢!
  1551. */
  1552. //收款账单
  1553. int frCount = _sqlSugar.Queryable<Fin_ForeignReceivables>().Where(x => x.IsDel == 0 && x.Diid == diId).Count();
  1554. //收款退还
  1555. int fraomCount = _sqlSugar.Queryable<Fin_PaymentRefundAndOtherMoney>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1556. //机票费用
  1557. int arCount = _sqlSugar.Queryable<Grp_AirTicketReservations>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
  1558. //签证费用
  1559. int viCount = _sqlSugar.Queryable<Grp_VisaInfo>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
  1560. //保险费用
  1561. int cCount = _sqlSugar.Queryable<Grp_Customers>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1562. //酒店费用
  1563. int hrCount = _sqlSugar.Queryable<Grp_HotelReservations>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1564. //公务出访
  1565. int oaCount = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1566. //邀请公务活动费用
  1567. int ioaCount = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1568. //OP费用
  1569. int ctggrCount = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1570. //其他费用
  1571. int dpCount = _sqlSugar.Queryable<Grp_DecreasePayments>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1572. //团组日付报销费用
  1573. int dfpCount = _sqlSugar.Queryable<Fin_DailyFeePayment>().Where(x => x.IsDel == 0 && x.GroupId == diId).Count();
  1574. var feeCount = frCount + fraomCount + arCount + viCount + cCount + hrCount + oaCount + ioaCount + ctggrCount + dpCount + dfpCount;
  1575. if (feeCount > 0)
  1576. {
  1577. var delMsgTips = new StringBuilder();
  1578. delMsgTips.AppendLine($"1、收款账单数据:{frCount} 条");
  1579. delMsgTips.AppendLine($"2、收款退换数据:{fraomCount} 条");
  1580. delMsgTips.AppendLine($"3、机票费用数据:{arCount} 条");
  1581. delMsgTips.AppendLine($"4、签证费用数据:{viCount} 条");
  1582. delMsgTips.AppendLine($"5、保险费用数据:{cCount} 条");
  1583. delMsgTips.AppendLine($"6、酒店费用数据:{hrCount} 条");
  1584. delMsgTips.AppendLine($"7、公务出访数据:{oaCount} 条");
  1585. delMsgTips.AppendLine($"8、邀请公务活动费用数据:{ioaCount} 条");
  1586. delMsgTips.AppendLine($"9、OP费用数据:{ctggrCount} 条");
  1587. delMsgTips.AppendLine($"10、其他费用数据:{dpCount} 条");
  1588. delMsgTips.AppendLine($"11、团组日付报销费用数据:{dfpCount} 条");
  1589. delMsgTips.AppendLine($"");
  1590. delMsgTips.AppendLine($"温馨提示:该团组已产生费用,不允许删除;如需删除,请先删除对应版块费用,谢谢!");
  1591. return Ok(JsonView(false, delMsgTips.ToString()));
  1592. }
  1593. #endregion
  1594. var groupData = await _groupRepository.GroupDel(dto);
  1595. if (groupData.Code != 0)
  1596. {
  1597. return Ok(JsonView(false, groupData.Msg));
  1598. }
  1599. return Ok(JsonView(true));
  1600. }
  1601. /// <summary>
  1602. /// 获取团组销售报价号
  1603. /// 团组添加时 使用
  1604. /// </summary>
  1605. /// <returns></returns>
  1606. [HttpPost]
  1607. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1608. public async Task<IActionResult> GetGroupSalesQuoteNo()
  1609. {
  1610. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  1611. if (groupData.Code != 0)
  1612. {
  1613. return Ok(JsonView(false, groupData.Msg));
  1614. }
  1615. object salesQuoteNo = new
  1616. {
  1617. SalesQuoteNo = groupData.Data
  1618. };
  1619. return Ok(JsonView(salesQuoteNo));
  1620. }
  1621. /// <summary>
  1622. /// 设置确认出团
  1623. /// </summary>
  1624. /// <param name="dto"></param>
  1625. /// <returns></returns>
  1626. [HttpPost]
  1627. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1628. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  1629. {
  1630. var groupData = await _groupRepository.ConfirmationGroup(dto);
  1631. if (groupData.Code != 0)
  1632. {
  1633. return Ok(JsonView(false, groupData.Msg));
  1634. }
  1635. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  1636. #region OA消息推送
  1637. try
  1638. {
  1639. string groupName = groupInfo.TeamName;
  1640. var userIds = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).Select(x => x.Id).ToList();
  1641. string title = $"系统通知";
  1642. string content = $"团组[{groupName}]已确认出团!";
  1643. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  1644. }
  1645. catch (Exception ex)
  1646. {
  1647. }
  1648. #endregion
  1649. #region 应用推送
  1650. try
  1651. {
  1652. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  1653. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  1654. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1655. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1656. {
  1657. var userList = new List<string>() { users.QiyeChatUserId };
  1658. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  1659. }
  1660. }
  1661. catch (Exception ex)
  1662. {
  1663. }
  1664. #endregion
  1665. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  1666. return Ok(JsonView(true, "操作成功!", groupData.Data));
  1667. }
  1668. /// <summary>
  1669. /// 获取团组名称data And 签证国别Data
  1670. /// </summary>
  1671. /// <param name="dto"></param>
  1672. /// <returns></returns>
  1673. [HttpPost]
  1674. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1675. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  1676. {
  1677. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  1678. if (groupData.Code != 0)
  1679. {
  1680. return Ok(JsonView(false, groupData.Msg));
  1681. }
  1682. return Ok(JsonView(groupData.Data));
  1683. }
  1684. /// <summary>
  1685. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  1686. /// </summary>
  1687. /// <returns></returns>
  1688. [HttpPost]
  1689. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1690. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  1691. {
  1692. try
  1693. {
  1694. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  1695. if (groupData.Code != 0)
  1696. {
  1697. return Ok(JsonView(false, groupData.Msg));
  1698. }
  1699. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1700. }
  1701. catch (Exception ex)
  1702. {
  1703. return Ok(JsonView(false, ex.Message));
  1704. throw;
  1705. }
  1706. }
  1707. /// <summary>
  1708. /// 团组清单 Excel
  1709. /// </summary>
  1710. /// <param name="beginDt">开始时间 EG:“2024-01-01”</param>
  1711. /// <param name="endDt">结束时间 EG;“2024-12-31”</param>
  1712. /// <returns></returns>
  1713. [HttpGet]
  1714. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1715. public async Task<IActionResult> GroupListFile([FromQuery] string beginDt, [FromQuery] string endDt)
  1716. {
  1717. bool beginBool = DateTime.TryParse($"{beginDt} 00:00:00", out DateTime _beginDt),
  1718. endBool = DateTime.TryParse($"{endDt} 23:59:59", out DateTime _endDt);
  1719. if (!beginBool && !endBool)
  1720. {
  1721. return Ok(JsonView(false, "开始或结束时间不正确!"));
  1722. }
  1723. string sql = string.Format(@"
  1724. SELECT
  1725. ROW_NUMBER,
  1726. Id,
  1727. SalesQuoteNo,
  1728. TourCode,
  1729. TeamTypeId,
  1730. TeamType,
  1731. TeamLevId,
  1732. TeamLev,
  1733. TeamName,
  1734. ClientName,
  1735. ClientUnit,
  1736. VisitDate,
  1737. VisitDays,
  1738. VisitPNumber,
  1739. JietuanOperatorId,
  1740. JietuanOperator,
  1741. IsSure,
  1742. CreateUserName,
  1743. IsBid
  1744. FROM
  1745. (
  1746. SELECT
  1747. ROW_NUMBER() OVER(
  1748. ORDER BY
  1749. gdi.VisitDate Desc
  1750. ) AS ROW_NUMBER,
  1751. gdi.Id,
  1752. SalesQuoteNo,
  1753. TourCode,
  1754. ssd.Id TeamTypeId,
  1755. ssd.Name TeamType,
  1756. ssd1.Id TeamLevId,
  1757. ssd1.Name TeamLev,
  1758. TeamName,
  1759. ClientName,
  1760. ClientUnit,
  1761. VisitDate,
  1762. VisitDays,
  1763. VisitPNumber,
  1764. JietuanOperator JietuanOperatorId,
  1765. su.CnName JietuanOperator,
  1766. IsSure,
  1767. gdi.CreateTime,
  1768. su1.CnName As CreateUserName,
  1769. gdi.IsBid
  1770. FROM
  1771. Grp_DelegationInfo gdi
  1772. LEFT JOIN Sys_SetData ssd ON gdi.TeamDid = ssd.Id
  1773. LEFT JOIN Sys_SetData ssd1 ON gdi.TeamLevSId = ssd1.Id
  1774. LEFT JOIN Sys_Users su ON gdi.JietuanOperator = su.Id
  1775. LEFT JOIN Sys_Users su1 ON gdi.CreateUserId = su1.Id
  1776. WHERE
  1777. gdi.IsDel = 0
  1778. AND gdi.IsBid = 0
  1779. AND gdi.VisitDate BETWEEN '{0}' AND '{1}'
  1780. ) temp", _beginDt.ToString("yyyy-MM-dd HH:mm:ss"), _endDt.ToString("yyyy-MM-dd HH:mm:ss"));
  1781. var groupList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToListAsync();
  1782. #region 处理所属部门
  1783. /*
  1784. * 1.sq 和 gyy 等显示 市场部
  1785. * 2.王鸽和主管及张总还有管理员号统一国交部
  1786. * 2-1. 4 管理员 ,21 张海麟
  1787. */
  1788. var userIds = groupList.Select(it => it.JietuanOperatorId).ToList();
  1789. var userIds1 = new List<int>() { 4, 21 };
  1790. var userDepDatas = await _sqlSugar.Queryable<Sys_Users>()
  1791. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  1792. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  1793. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  1794. .ToListAsync();
  1795. var droupIds = groupList.Select(it => it.Id).ToList();
  1796. var deleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  1797. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  1798. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  1799. .Where((tcl, dc, cc) => tcl.IsDel == 0 && droupIds.Contains(tcl.DiId))
  1800. .Select((tcl, dc, cc) => new ClientInfoInfo_Group
  1801. {
  1802. DiId = tcl.DiId,
  1803. LastName = dc.LastName,
  1804. FirstName = dc.FirstName,
  1805. Sex = dc.Sex,
  1806. Birthday = dc.BirthDay,
  1807. Company = cc.CompanyFullName,
  1808. Job = dc.Job,
  1809. CreateTime = tcl.CreateTime,
  1810. })
  1811. .ToList();
  1812. foreach (var item in groupList)
  1813. {
  1814. item.Department = userDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  1815. string groupFirstName = "";
  1816. var currDatas = deleClientList.Where(x => x.DiId == item.Id).ToList();
  1817. if (currDatas.Any())
  1818. {
  1819. groupFirstName = AesEncryptionHelper.Decrypt(currDatas[0].LastName) + AesEncryptionHelper.Decrypt(currDatas[0].FirstName);
  1820. }
  1821. item.GroupFirst = groupFirstName;
  1822. }
  1823. #endregion
  1824. #region Excel
  1825. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  1826. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  1827. var savePath = AppSettingsHelper.Get("GrpListFileBasePath");
  1828. var ftpPath = AppSettingsHelper.Get("GrpListFileFtpPath");
  1829. var fileName = $"团组清单({beginDt}~{endDt}){DateTime.Now:yyyyMMddHHmmss}.xlsx";
  1830. //载入模板
  1831. var designer = new WorkbookDesigner
  1832. {
  1833. Workbook = new Workbook($"{tempPath}团组清单模板.xlsx")
  1834. };
  1835. designer.SetDataSource("Titel", $"团组清单({beginDt}~{endDt})");
  1836. DataTable dt = CommonFun.GetDataTableFromIList<DelegationListView>(groupList); ;
  1837. dt.TableName = "GroupList";
  1838. designer.SetDataSource(dt);
  1839. designer.Process();
  1840. if (!Directory.Exists(savePath))
  1841. {
  1842. Directory.CreateDirectory(savePath);
  1843. }
  1844. string serverPath = $"{savePath}{fileName}";
  1845. designer.Workbook.Save(serverPath);
  1846. string rst = $"{servicePath}{ftpPath}{fileName}";
  1847. #endregion
  1848. return Ok(JsonView(true, "操作成功!", rst));
  1849. }
  1850. /// <summary>
  1851. /// 团组合同下载(1.付款80% 2.付全款)
  1852. /// </summary>
  1853. /// <param name="dto"></param>
  1854. /// <returns></returns>
  1855. /// <exception cref="Exception"></exception>
  1856. [HttpPost]
  1857. public async Task<IActionResult> DownGroupContractFile(DownGroupContractFileDto dto)
  1858. {
  1859. var jw = JsonView(false);
  1860. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  1861. .FirstAsync(x => x.Id == dto.GroupId && x.IsDel == 0);
  1862. if (di == null)
  1863. {
  1864. jw.Msg = "团组Id有误!";
  1865. return Ok(jw);
  1866. }
  1867. #region 权限校验
  1868. var allDownFile = new List<int>() { 21 };
  1869. try
  1870. {
  1871. var setting = _sqlSugar.Queryable<Sys_SetData>()
  1872. .First(x => x.Id == 1418 && x.IsDel == 0);
  1873. allDownFile.AddRange(JsonConvert.DeserializeObject<List<int>>(setting.Remark));
  1874. }
  1875. catch (Exception)
  1876. { }
  1877. var guojiaoDownFile = new List<int>() { 330, 383 };
  1878. var shichangDownFile = new List<int>() { 95 };
  1879. if (allDownFile.Contains(dto.UserId))
  1880. {
  1881. }
  1882. else if (guojiaoDownFile.Contains(dto.UserId))
  1883. {
  1884. var guojiaobuDi = new List<int>() { 4, 21 };
  1885. var departmentStr = _sqlSugar.Queryable<Sys_Department>()
  1886. .LeftJoin<Sys_Users>((d, u) => d.Id == u.DepId && u.IsDel == 0)
  1887. .Where((d, u) => u.Id == di.JietuanOperator)
  1888. .Select((d, u) => d.DepName)
  1889. .First();
  1890. if (!guojiaobuDi.Contains(di.JietuanOperator) && departmentStr != "策划部" && departmentStr != "国交部")
  1891. {
  1892. jw.Msg = "暂无下载权限!";
  1893. return Ok(jw);
  1894. }
  1895. }
  1896. else if (shichangDownFile.Contains(dto.UserId))
  1897. {
  1898. var dic = new Dictionary<int, int[]>()
  1899. {
  1900. { 95, new int []{ 95 , 337 , 302, 350, 355, 357, 353 , 359 , 361, 368, 364, 366, 369} }
  1901. };
  1902. try
  1903. {
  1904. var sqSetting = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1417);
  1905. if (sqSetting != null)
  1906. {
  1907. Dictionary<int, int[]> result = JsonConvert.DeserializeObject<Dictionary<int, int[]>>(sqSetting.Remark);
  1908. foreach (var item in result.Keys)
  1909. {
  1910. if (dic.ContainsKey(item))
  1911. {
  1912. int[] dilatation = new int[dic[item].Length + result[item].Length];
  1913. Array.Copy(dic[item], dilatation, dic[item].Length);
  1914. Array.Copy(result[item], 0, dilatation, dic[item].Length, result[item].Length);
  1915. dic[item] = dilatation;
  1916. }
  1917. else
  1918. {
  1919. dic.Add(item, result[item]);
  1920. }
  1921. }
  1922. }
  1923. if (!dic[95].Contains(di.CreateUserId))
  1924. {
  1925. jw.Msg = "暂无下载权限!";
  1926. return Ok(jw);
  1927. }
  1928. }
  1929. catch (Exception)
  1930. { }
  1931. }
  1932. else if (dto.UserId == di.CreateUserId)
  1933. {
  1934. }
  1935. else
  1936. {
  1937. jw.Msg = "暂无下载权限!";
  1938. return Ok(jw);
  1939. }
  1940. #endregion
  1941. var blackCodeList = await _sqlSugar.Queryable<Air_TicketBlackCode>()
  1942. .Where(x => x.DiId == dto.GroupId && x.IsDel == 0)
  1943. .ToListAsync();
  1944. if (!blackCodeList.Any())
  1945. {
  1946. jw.Msg = "该团无机票行程代码!";
  1947. return Ok(jw);
  1948. }
  1949. var groupEnterExitCost = await _sqlSugar.Queryable<Grp_EnterExitCost>()
  1950. .FirstAsync(x => x.DiId == dto.GroupId && x.IsDel == 0);
  1951. if (groupEnterExitCost == null)
  1952. {
  1953. jw.Msg = "暂无三公费用信息!";
  1954. return Ok(jw);
  1955. }
  1956. var rateList = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(groupEnterExitCost.CurrencyRemark);
  1957. rateList ??= new List<CurrencyInfo>();
  1958. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == di.Id).ToList();
  1959. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  1960. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  1961. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  1962. .Where((x, a, b) => x.IsDel == 0 && x.Diid == di.Id)
  1963. .Select((x, a, b) => new
  1964. {
  1965. x.Index,
  1966. itemName = a.Name,
  1967. CurrencyStr = b.Name,
  1968. x.Cost,
  1969. x.SubTotal,
  1970. x.Remark
  1971. })
  1972. .OrderBy((x) => x.Index)
  1973. .ToList();
  1974. decimal stayFeeTotal = groupEnterExitCost.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  1975. decimal mealsFeeTotal = groupEnterExitCost.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  1976. decimal miscellaneousFeeTotal = groupEnterExitCost.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  1977. decimal tainFeeTotal = groupEnterExitCost.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  1978. decimal otherPriceTotal = groupEnterExitCost.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  1979. decimal insidePayTotal = groupEnterExitCost.ChoiceOne == 1 ? groupEnterExitCost.InsidePay : 0.00M;
  1980. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  1981. decimal subJJC = 0.00M,
  1982. subGWC = 0.00M,
  1983. subTDC = 0.00M;
  1984. //经济舱
  1985. if (groupEnterExitCost.SumJJC == 1)
  1986. {
  1987. subJJC = otherFeeTotal + groupEnterExitCost.OutsideJJPay;
  1988. }
  1989. //公务舱
  1990. if (groupEnterExitCost.SumGWC == 1)
  1991. {
  1992. subGWC = otherFeeTotal + groupEnterExitCost.OutsideGWPay;
  1993. }
  1994. //头等舱
  1995. if (groupEnterExitCost.SumTDC == 1)
  1996. {
  1997. subTDC = otherFeeTotal + groupEnterExitCost.OutsideTDPay;
  1998. }
  1999. var groupClints = await _sqlSugar.Queryable<Grp_TourClientList>()
  2000. .LeftJoin<Sys_SetData>((x, s) => s.Id == x.ShippingSpaceTypeId && s.IsDel == 0)
  2001. .LeftJoin<Crm_DeleClient>((x, s, dc) => x.ClientId == dc.Id && dc.IsDel == 0)
  2002. .LeftJoin<Crm_CustomerCompany>((x, s, dc, cc) => dc.CrmCompanyId == cc.Id && cc.IsDel == 0)
  2003. .Where((x, s, dc, cc) => x.DiId == dto.GroupId && x.IsDel == 0)
  2004. .Select((x, s, dc, cc) => new GroupClints
  2005. {
  2006. Id = x.Id,
  2007. Name = s.Name,
  2008. IsAccompany = x.IsAccompany,
  2009. CompanyFullName = cc.CompanyFullName
  2010. })
  2011. .ToListAsync();
  2012. groupClints.ForEach(x => x.CompanyFullName = AesEncryptionHelper.Decrypt(x.CompanyFullName));
  2013. //获取舱位人数
  2014. var cabinCount = groupClints.Where(x => x.IsAccompany != 2 && !x.CompanyFullName.Contains("泛美国际"))
  2015. .GroupBy(x => x.Name)
  2016. .Select(x => new { Cabin = x.Key, Count = x.Count() })
  2017. .ToList();
  2018. string cityPath = string.Empty;
  2019. string startCity = string.Empty;
  2020. string endCity = string.Empty;
  2021. foreach (var item in blackCodeList)
  2022. {
  2023. string city = GeneralMethod.GetGroupCityLine(item, "-");
  2024. cityPath += city + "\r\n";
  2025. if (item.Equals(blackCodeList.First()))
  2026. {
  2027. var sp = city.Split('-');
  2028. startCity = sp[0];
  2029. endCity = sp[^1];
  2030. }
  2031. }
  2032. di.VisitCountry = Regex.Replace(di.VisitCountry, @"[|-]", "、");
  2033. var bookMarkDic = new Dictionary<string, string>
  2034. {
  2035. { "ClientUnit", di.ClientUnit },
  2036. { "VisitCountry", di.VisitCountry },
  2037. { "VisitDate", di.VisitDate.ToString("yyyy年MM月dd日") },
  2038. { "VisitPNumber", di.VisitPNumber.ToString() },
  2039. { "CityPath", cityPath },
  2040. { "StartCity", startCity },
  2041. { "EndCity", endCity },
  2042. { "StayDays", $"{di.VisitDays}天{di.VisitDays - 1}晚" }
  2043. };
  2044. Document doc = null;
  2045. var percentage = 0.8M;
  2046. var fileNameadd = "预付";
  2047. if (dto.FileType == 1)
  2048. {
  2049. doc = new Document($"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Template/团组合同bookmarkFormat.doc");
  2050. }
  2051. else if (dto.FileType == 2)
  2052. {
  2053. doc = new Document($"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Template/团组合同全款无表格.doc");
  2054. percentage = 1;
  2055. fileNameadd = "全款";
  2056. }
  2057. else
  2058. {
  2059. throw new Exception("FileType有误!");
  2060. }
  2061. var builder = new DocumentBuilder(doc);
  2062. decimal totalPrice = 0.00M;
  2063. Table firstTable = (Table)doc.GetChild(NodeType.Table, 0, true);
  2064. if (firstTable != null)
  2065. {
  2066. // 遍历表格的行和单元格
  2067. foreach (Aspose.Words.Tables.Row row in firstTable.Rows)
  2068. {
  2069. for (int i = 0; i < row.Cells.Count; i++)
  2070. {
  2071. var cell = row.Cells[i];
  2072. // 读取单元格内容
  2073. string cellTextFirst = row.Cells[0].FirstParagraph.ToString(Aspose.Words.SaveFormat.Text).Trim();
  2074. if (cellTextFirst.Contains("舱位"))
  2075. {
  2076. break;
  2077. }
  2078. if (cellTextFirst == "经济舱" || cellTextFirst == "公务舱")
  2079. {
  2080. if (i == 2)
  2081. {
  2082. if (cellTextFirst == "经济舱")
  2083. {
  2084. // 设置单元格内容
  2085. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2086. cell.FirstParagraph.AppendChild(new Run(doc, subJJC.ToString())); // 添加
  2087. }
  2088. else
  2089. {
  2090. // 设置单元格内容
  2091. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2092. cell.FirstParagraph.AppendChild(new Run(doc, subGWC.ToString())); // 添加
  2093. }
  2094. }
  2095. if (i == 3)
  2096. {
  2097. var count = cabinCount.Find(x => x.Cabin == cellTextFirst)?.Count;
  2098. if (count != null)
  2099. {
  2100. // 设置单元格内容
  2101. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2102. cell.FirstParagraph.AppendChild(new Run(doc, count.ToString())); // 添加
  2103. }
  2104. }
  2105. if (i == 4)
  2106. {
  2107. var rowPrice = 0.00M;
  2108. var count = cabinCount.Find(x => x.Cabin == cellTextFirst)?.Count;
  2109. count ??= 0;
  2110. if (cellTextFirst == "经济舱")
  2111. {
  2112. rowPrice = subJJC * (int)count;
  2113. }
  2114. else
  2115. {
  2116. rowPrice = subGWC * (int)count;
  2117. }
  2118. totalPrice += rowPrice;
  2119. // 设置单元格内容
  2120. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2121. cell.FirstParagraph.AppendChild(new Run(doc, rowPrice.ToString())); // 添加
  2122. }
  2123. }
  2124. }
  2125. }
  2126. }
  2127. bookMarkDic.Add("TotalPrice", (totalPrice).ToString("#0.00"));
  2128. bookMarkDic.Add("TotalPrice1", (totalPrice * percentage).ToString("#0.00"));
  2129. bookMarkDic.Add("TotalPriceChinese", decimal.Parse((totalPrice * percentage).ToString("#0.00")).ConvertCNYUpper());
  2130. //--合同表格部分
  2131. bookMarkDic.Add("TimeNowDate", DateTime.Now.ToString("yyyy年MM月dd日"));
  2132. bookMarkDic.Add("ClientUnit1", di.ClientUnit);
  2133. bookMarkDic.Add("VisitCountry1", di.VisitCountry);
  2134. bookMarkDic.Add("DayCount", di.VisitDays.ToString());
  2135. bookMarkDic.Add("VisitingArea", di.VisitDate.ToString("yyyy年MM月dd日") + "-" + di.VisitEndDate.ToString("yyyy年MM月dd日"));
  2136. bookMarkDic.Add("CityPath1", cityPath);
  2137. bookMarkDic.Add("CityPath2", cityPath);
  2138. Table contractTable = (Table)doc.GetChild(NodeType.Table, 1, true);
  2139. if (contractTable != null)
  2140. {
  2141. //数据源
  2142. var _DayAndCostsAndCity = _sqlSugar.Queryable<Grp_DayAndCost>()
  2143. .LeftJoin<Grp_NationalTravelFee>((it, y) => it.NationalTravelFeeId == y.Id && y.IsDel == 0)
  2144. .LeftJoin<Sys_SetData>((it, y, s) => s.IsDel == 0 && s.Id == it.Currency)
  2145. .Where((it, y, s) => it.IsDel == 0 && it.DiId == di.Id)
  2146. .Select((it, y, s) => new
  2147. {
  2148. it.Cost,
  2149. it.SubTotal,
  2150. it.Type,
  2151. y.Id,
  2152. y.City,
  2153. s.Name,
  2154. CurrencyCodeCn = s.Remark
  2155. })
  2156. .ToList()
  2157. .Select(x => new
  2158. {
  2159. CurrencyCode = x.Name,
  2160. CityId = x.Id,
  2161. x.City,
  2162. di.VisitPNumber,
  2163. x.Type,
  2164. x.Cost,
  2165. x.SubTotal,
  2166. rateList.Find(y => y.CurrencyCode == x.Name)?.Rate,
  2167. x.CurrencyCodeCn,
  2168. });
  2169. var dac1 = _DayAndCostsAndCity.Where(it => it.Type == 1).GroupBy(x => x.CityId).ToList(); //住宿费
  2170. var dac2 = _DayAndCostsAndCity.Where(it => it.Type == 2).GroupBy(x => x.CityId).ToList(); //伙食费
  2171. var dac3 = _DayAndCostsAndCity.Where(it => it.Type == 3).GroupBy(x => x.CityId).ToList(); //公杂费
  2172. var dac4 = _DayAndCostsAndCity.Where(it => it.Type == 4).GroupBy(x => x.CityId).ToList(); //培训费
  2173. var tableSettings = new List<tableSetting>()
  2174. {
  2175. new(){ Index = 1 , Property = "City"},
  2176. new(){ Index = 2 , Property = "CurrencyCodeCn"},
  2177. new(){ Index = 3 , Property = "Cost"},
  2178. new(){ Index = 4 , Property = "VisitPNumber"},
  2179. //new tableSetting{ Index = 5 , Property = ""},
  2180. //new tableSetting{ Index = 6 , Property = ""},
  2181. new(){ Index = 7 , Property = "Rate"},
  2182. //new tableSetting{ Index = 8 , Property = ""},
  2183. };
  2184. //1.住宿费
  2185. int cloneRow = 8;
  2186. int startDayPrice = 8; //写入index
  2187. decimal ZSPriceSum = 0.00M, HSPriceSum = 0.00M, GZPriceSum = 0.00M;
  2188. foreach (var dac in dac1)
  2189. {
  2190. var first = dac.First();
  2191. var dayCount = dac.Count();
  2192. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2193. for (int i = 1; i < row.Cells.Count; i++)
  2194. {
  2195. var cell = row.Cells[i];
  2196. var findProperty = tableSettings.Find(x => x.Index == i);
  2197. if (findProperty != null)
  2198. {
  2199. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2200. // 设置单元格内容
  2201. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2202. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2203. }
  2204. else
  2205. {
  2206. switch (i)
  2207. {
  2208. case 5:
  2209. cell.FirstParagraph.Runs.Clear();
  2210. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2211. break;
  2212. case 6:
  2213. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2214. cell.FirstParagraph.Runs.Clear();
  2215. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2216. break;
  2217. case 8:
  2218. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2219. cell.FirstParagraph.Runs.Clear();
  2220. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2221. ZSPriceSum += xiaojiRMB;
  2222. break;
  2223. default:
  2224. break;
  2225. }
  2226. }
  2227. }
  2228. startDayPrice++;
  2229. if (!dac1.Last().Equals(dac))
  2230. {
  2231. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2232. // 将克隆的行追加到原行后面
  2233. contractTable.Rows.Insert(startDayPrice, newRow);
  2234. }
  2235. else
  2236. {
  2237. cloneRow += dac1.Count + 1;
  2238. startDayPrice = cloneRow;
  2239. }
  2240. }
  2241. //2.伙食费
  2242. foreach (var dac in dac2)
  2243. {
  2244. var first = dac.First();
  2245. var dayCount = dac.Count();
  2246. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2247. for (int i = 1; i < row.Cells.Count; i++)
  2248. {
  2249. var cell = row.Cells[i];
  2250. var findProperty = tableSettings.Find(x => x.Index == i);
  2251. if (findProperty != null)
  2252. {
  2253. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2254. // 设置单元格内容
  2255. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2256. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2257. }
  2258. else
  2259. {
  2260. switch (i)
  2261. {
  2262. case 5:
  2263. cell.FirstParagraph.Runs.Clear();
  2264. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2265. break;
  2266. case 6:
  2267. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2268. cell.FirstParagraph.Runs.Clear();
  2269. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2270. break;
  2271. case 8:
  2272. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2273. cell.FirstParagraph.Runs.Clear();
  2274. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2275. HSPriceSum += xiaojiRMB;
  2276. break;
  2277. default:
  2278. break;
  2279. }
  2280. }
  2281. }
  2282. startDayPrice++;
  2283. if (!dac2.Last().Equals(dac))
  2284. {
  2285. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2286. // 将克隆的行追加到原行后面
  2287. contractTable.Rows.Insert(startDayPrice, newRow);
  2288. }
  2289. else
  2290. {
  2291. cloneRow += dac2.Count + 1;
  2292. startDayPrice = cloneRow;
  2293. }
  2294. }
  2295. //3.公杂费
  2296. foreach (var dac in dac3)
  2297. {
  2298. var first = dac.First();
  2299. var dayCount = dac.Count();
  2300. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2301. for (int i = 1; i < row.Cells.Count; i++)
  2302. {
  2303. var cell = row.Cells[i];
  2304. var findProperty = tableSettings.Find(x => x.Index == i);
  2305. if (findProperty != null)
  2306. {
  2307. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2308. // 设置单元格内容
  2309. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2310. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2311. }
  2312. else
  2313. {
  2314. switch (i)
  2315. {
  2316. case 5:
  2317. cell.FirstParagraph.Runs.Clear();
  2318. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2319. break;
  2320. case 6:
  2321. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2322. cell.FirstParagraph.Runs.Clear();
  2323. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2324. break;
  2325. case 8:
  2326. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2327. cell.FirstParagraph.Runs.Clear();
  2328. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2329. GZPriceSum += xiaojiRMB;
  2330. break;
  2331. default:
  2332. break;
  2333. }
  2334. }
  2335. }
  2336. startDayPrice++;
  2337. if (!dac3.Last().Equals(dac))
  2338. {
  2339. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2340. // 将克隆的行追加到原行后面
  2341. contractTable.Rows.Insert(startDayPrice, newRow);
  2342. }
  2343. else
  2344. {
  2345. cloneRow += dac3.Count + 1;
  2346. startDayPrice = cloneRow;
  2347. }
  2348. }
  2349. //合并单元格
  2350. for (int i = 8; i < contractTable.Rows.Count - 1; i++)
  2351. {
  2352. var currentRow = contractTable.Rows[i];
  2353. var nextRow = contractTable.Rows[i + 1];
  2354. // 获取当前行和下一行的第一个单元格
  2355. Cell currentCell = currentRow.Cells[0];
  2356. Cell nextCell = nextRow.Cells[0];
  2357. // 检查单元格内容是否一致(去除尾部的换行符)
  2358. string currentText = currentCell.GetText().Trim();
  2359. string nextText = nextCell.GetText().Trim();
  2360. if (currentText == nextText)
  2361. {
  2362. // 如果当前单元格已经被合并,找到合并的起始单元格
  2363. if (currentCell.CellFormat.VerticalMerge == CellMerge.Previous)
  2364. {
  2365. // 找到合并的起始单元格
  2366. int mergeStartIndex = FindMergeStartRowIndex(contractTable, i);
  2367. // 将下一行的单元格设置为合并的后续单元格
  2368. nextCell.CellFormat.VerticalMerge = CellMerge.Previous;
  2369. }
  2370. else
  2371. {
  2372. // 如果当前单元格是合并的起始单元格
  2373. currentCell.CellFormat.VerticalMerge = CellMerge.First;
  2374. // 将下一行的单元格设置为合并的后续单元格
  2375. nextCell.CellFormat.VerticalMerge = CellMerge.Previous;
  2376. }
  2377. }
  2378. else
  2379. {
  2380. // 如果内容不一致,重置当前单元格的合并属性
  2381. if (currentCell.CellFormat.VerticalMerge == CellMerge.Previous)
  2382. {
  2383. // 如果当前单元格是合并的后续单元格,找到合并的起始单元格并重置
  2384. int mergeStartIndex = FindMergeStartRowIndex(contractTable, i);
  2385. contractTable.Rows[mergeStartIndex].Cells[0].CellFormat.VerticalMerge = CellMerge.First;
  2386. }
  2387. else
  2388. {
  2389. currentCell.CellFormat.VerticalMerge = CellMerge.None;
  2390. }
  2391. }
  2392. }
  2393. bookMarkDic.Add("ZSPriceSum", ZSPriceSum.ToString("F2"));
  2394. bookMarkDic.Add("HSPriceSum", HSPriceSum.ToString("F2"));
  2395. bookMarkDic.Add("GZPriceSum", GZPriceSum.ToString("F2"));
  2396. }
  2397. foreach (var bookmarkName in bookMarkDic.Keys)
  2398. {
  2399. Bookmark bookmark = doc.Range.Bookmarks[bookmarkName];
  2400. if (bookmark != null)
  2401. {
  2402. if (bookmarkName == "ClientUnit")
  2403. {
  2404. // 移动到书签位置
  2405. builder.MoveTo(bookmark.BookmarkStart);
  2406. // 设置字体样式为下划线
  2407. builder.Font.Underline = Aspose.Words.Underline.Single;
  2408. // 插入书签值
  2409. builder.Write(bookMarkDic[bookmarkName]);
  2410. // 清除字体格式,避免影响后续文本
  2411. builder.Font.ClearFormatting();
  2412. }
  2413. else
  2414. {
  2415. builder.MoveToBookmark(bookmarkName);
  2416. builder.Write(bookMarkDic[bookmarkName]);
  2417. }
  2418. }
  2419. }
  2420. string savePaht = $"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Export/{di.TeamName}_{fileNameadd}版本合同文件.doc";
  2421. doc.Save(savePaht);
  2422. jw.Msg = "生成成功!";
  2423. jw.Code = 200;
  2424. jw.Data = new { Url = AppSettingsHelper.Get("WordBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("WordBasePath"), AppSettingsHelper.Get("WordFtpPath")) };
  2425. return Ok(jw);
  2426. }
  2427. static int FindMergeStartRowIndex(Table table, int rowIndex)
  2428. {
  2429. int index = rowIndex;
  2430. while (index > 0 && table.Rows[index].Cells[0].CellFormat.VerticalMerge == CellMerge.Previous)
  2431. {
  2432. index--;
  2433. }
  2434. return index;
  2435. }
  2436. /// <summary>
  2437. /// 报批完成企微通知
  2438. /// </summary>
  2439. /// <param name="dto"></param>
  2440. /// <returns></returns>
  2441. [HttpPost]
  2442. public async Task<IActionResult> EnterpriseWeChatNotificationAsyncBaoPi(EnterpriseWeChatNotificationAsyncBaoPiDto dto)
  2443. {
  2444. int currUserId = dto.currUserId;
  2445. int diid = dto.diid;
  2446. var jw = JsonView(true);
  2447. var users = new List<string>();
  2448. var ssd = _sqlSugar.Queryable<Sys_SetData>()
  2449. .First(x => x.Id == 1460);
  2450. try
  2451. {
  2452. users = JsonConvert.DeserializeObject<List<string>>(ssd.Remark);
  2453. var groupModuleOperators = GeneralMethod.GetGroupModuleOperators(dto.diid);
  2454. //添加分配人员
  2455. // 79 车/导游地接
  2456. // 80 签证
  2457. // 81 邀请/公务活动
  2458. var setdataids = new List<int>() { 79, 81 };
  2459. foreach (var groupModule in groupModuleOperators)
  2460. {
  2461. if (setdataids.Contains(groupModule.CTableId))
  2462. {
  2463. users.AddRange(groupModule.OperationUsers.Select(x => x.UserId.ToString()));
  2464. }
  2465. }
  2466. var res = await AppNoticeLibrary.SendUserMsg_BaoPi_ToUser(users, diid);
  2467. //消息通知成功 更改团组step、记录日志
  2468. if (res)
  2469. {
  2470. var groupStep = 0; //0-新建 1-企微消息通知
  2471. //更改团组step
  2472. var updStatus = await _sqlSugar.Updateable<Grp_DelegationInfo>()
  2473. .SetColumns(x => new Grp_DelegationInfo()
  2474. {
  2475. Step = 2
  2476. })
  2477. .Where(x => x.Id == diid && x.IsDel == 0)
  2478. .ExecuteCommandAsync();
  2479. if (updStatus > 0) groupStep = 2;
  2480. string groupStepLabel = groupStep switch
  2481. {
  2482. 1 => "新建",
  2483. 2 => "企微消息通知(报批)",
  2484. _ => "未设置"
  2485. };
  2486. //记录日志
  2487. var teamName = _sqlSugar.Queryable<Grp_DelegationInfo>()
  2488. .Where(x => x.Id == diid && x.IsDel == 0)
  2489. .Select(x => x.TeamName)
  2490. .First() ?? "-";
  2491. var operationName = _sqlSugar.Queryable<Sys_Users>()
  2492. .Where(x => x.Id == currUserId && x.IsDel == 0)
  2493. .Select(x => x.CnName)
  2494. .First() ?? "-";
  2495. _groupTextLogger.LogInformation("团组:【{teamName}({groupId})】 操作人:【{operationName}】 操作时间:【{operationTime}】{logContent}", teamName, diid, operationName, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), groupStepLabel);
  2496. //设置 签证流程初始值
  2497. await _visaProcessRep.UpdateBatchTop4Step(dto.diid, dto.currUserId);
  2498. }
  2499. }
  2500. catch (Exception ex)
  2501. {
  2502. return Ok(JsonView(false, ex.Message));
  2503. }
  2504. return Ok(jw);
  2505. }
  2506. #endregion
  2507. #region 团组&签证
  2508. #region 团组&签证 New
  2509. /// <summary>
  2510. /// 团组&签证 New
  2511. /// DeepSeek API:测试API连通性
  2512. /// </summary>
  2513. /// <param name="file">请求dto</param>
  2514. /// <returns></returns>
  2515. [HttpPost]
  2516. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2517. public async Task<IActionResult> TestDeepSeekApiConnectivityAsync()
  2518. {
  2519. return Ok(JsonView(await _deepSeekService.TestApiConnectivityAsync()));
  2520. }
  2521. /// <summary>
  2522. /// 团组&签证 New
  2523. /// DeepSeek API:检查可用端点
  2524. /// </summary>
  2525. /// <param name="file">请求dto</param>
  2526. /// <returns></returns>
  2527. [HttpPost]
  2528. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2529. public async Task<IActionResult> DiscoverAvailableEndpointsAsync()
  2530. {
  2531. return Ok(JsonView(await _deepSeekService.DiscoverAvailableEndpointsAsync()));
  2532. }
  2533. /// <summary>
  2534. /// 团组&签证 New
  2535. /// 上传签证文件(客户填写签证文件),新增或更新 签证信息
  2536. /// </summary>
  2537. /// <param name="visaFile">文件</param>
  2538. /// <param name="fileTypeId">
  2539. /// 1. 澳新签证个人申请表
  2540. /// 2. 出国个人申请表
  2541. /// 3. 美国签证个人申请表格
  2542. /// 4. 沙特个人信息表格
  2543. /// 5. 申根签证个人资料表
  2544. /// 6. 中文个人简历模板
  2545. /// </param>
  2546. /// <returns></returns>
  2547. [HttpPost]
  2548. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2549. public async Task<IActionResult> VisaFileUploadAndUpdate(IFormFile visaFile, int fileTypeId)
  2550. {
  2551. //文件验证
  2552. if (visaFile.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  2553. //var visaFiles = new VisaUploadFileTypeView();
  2554. //var filetypes = VisaUploadFileTypeView.GetVisaUploadFileTypeViewItemInit();
  2555. //if (!filetypes.Any(x => x.FileId == fileTypeId)) return Ok(JsonView(false, "请选择文件类型!"));
  2556. //服务器存储文件
  2557. var fileServerPath = $"D:/FTP/File/OA2023/Office/Word/VisaClientData/Uploads";
  2558. if (!Directory.Exists(fileServerPath)) Directory.CreateDirectory(fileServerPath);
  2559. var filePath = Path.Combine(fileServerPath, visaFile.FileName);
  2560. using (var stream = new FileStream(filePath, FileMode.Create))
  2561. {
  2562. await visaFile.CopyToAsync(stream);
  2563. }
  2564. //日志记录-上传文件
  2565. _logger.LogInformation("【签证上传文件操作信息】签证文件存储成功!路径:{fileServerPath} 文件名称:{fileName}", fileServerPath, visaFile.FileName);
  2566. #region 上传文件到DeepSeekAPI
  2567. //IFormFile localFile = null;
  2568. ////获取项目中的cs文件
  2569. //try
  2570. //{
  2571. // _logger.LogInformation("读取并上传项目文件请求");
  2572. // // 1. 读取项目文件
  2573. // var readResponse = await _deepSeekService.ReadProjectFilesAsync(new List<string>() { @"OASystem.Domain\ViewModels\VisaFormDetails\AusNewVisaApplicationForm.cs" });
  2574. // if (readResponse.SuccessCount == 0)
  2575. // {
  2576. // return Ok(JsonView(false, "读取项目文件失败"));
  2577. // }
  2578. // localFile = readResponse.FileInfos.FirstOrDefault().FormFile;
  2579. //}
  2580. //catch (Exception ex)
  2581. //{
  2582. // _logger.LogError(ex, "读取项目文件失败");
  2583. // return Ok(JsonView(false, "读取项目文件失败"));
  2584. //}
  2585. //if (localFile == null)
  2586. //{
  2587. // return Ok(JsonView(false, "读取项目文件失败"));
  2588. //}
  2589. //var fileReq = new DeepSeekFileUploadRequest()
  2590. //{
  2591. // Files = new List<IFormFile> { localFile, visaFile },
  2592. //};
  2593. //var filesResult = new List<FileUploadResult>();
  2594. //try
  2595. //{
  2596. // _logger.LogInformation("开始上传 {FileCount} 个文件到DeepSeek API", fileReq.Files.Count);
  2597. // filesResult = await _deepSeekService.UploadFilesAsync(fileReq.Files, fileReq.Purpose);
  2598. // // 需要等待处理完成
  2599. // if (fileReq.WaitForProcessing)
  2600. // {
  2601. // foreach (var result in filesResult)
  2602. // {
  2603. // if (result.Success)
  2604. // {
  2605. // try
  2606. // {
  2607. // var processedFile = await _deepSeekService.WaitForFileProcessingAsync(result.FileId);
  2608. // result.Status = processedFile.Status;
  2609. // }
  2610. // catch (Exception ex)
  2611. // {
  2612. // _logger.LogError(ex, "DeepSeek API文件上传失败");
  2613. // return Ok(JsonView(false, $"DeepSeek API文件上传处理失败: {ex.Message}"));
  2614. // }
  2615. // }
  2616. // }
  2617. // }
  2618. //}
  2619. //catch (Exception ex)
  2620. //{
  2621. // _logger.LogError(ex, "DeepSeek API文件上传失败");
  2622. // return Ok(JsonView(false, $"DeepSeek API文件上传处理失败: {ex.Message}"));
  2623. //}
  2624. //#endregion
  2625. //if (filesResult == null || filesResult.Count < 1)
  2626. //{
  2627. // return Ok(JsonView(false, $"DeepSeek API文件上传处理失败"));
  2628. //}
  2629. ////
  2630. //try
  2631. //{
  2632. // var fileIds = filesResult.Where(x => x.Success).Select(x => x.FileId).ToList();
  2633. // _logger.LogInformation("使用 {FileCount} 个文件进行聊天", fileIds.Count);
  2634. // string question = string.Format("将上传的文件内容按照识别为JSON格式,并按照 AusNewVisaApplicationForm 指定的实体类结构进行映射。确保字段和值对应、文档中数据的完整性、复选框选择打勾后的文本。第一项从不识别\"比如美国(2024年7月29日)\"相关文字。");
  2635. // var response = await _deepSeekService.ChatWithFilesAsync(fileIds, question);
  2636. // return Ok(response);
  2637. //}
  2638. //catch (Exception ex)
  2639. //{
  2640. // _logger.LogError(ex, "使用文件聊天失败");
  2641. // return Ok(JsonView(false, $"聊天失败: {ex.Message}"));
  2642. //}
  2643. #endregion
  2644. #region kimi API
  2645. //加载文件OpCarTouristGuideGroundContent
  2646. //kimi AI 识别文档返回json结果
  2647. int kimiAI_API_Index = 0; //KIMI-AI-API 访问计次
  2648. var KiMiApi = new KiMiApiClient();
  2649. var files = new List<IFormFile>() { visaFile };
  2650. var seedConter = await KiMiApi.UploadFilesAsync(files);
  2651. if (seedConter.Count == 0) return Ok(JsonView(false, "Kimi AI 文件上传结果为空!"));
  2652. //var seedMessage = filetypes.Where(x => x.FileId == fileTypeId).FirstOrDefault()?.KimiAITips;
  2653. var seedMessage = string.Format(@"你是领事馆电子材料审核员,只关注 Word 里的表格,正文、页眉页脚、水印、批注全部忽略。
  2654. 任务:把表格里的每个可填字段转换成“标题:值”的键值对,标题用原文,值用原文,不翻译。
  2655. 规则如下:
  2656. 1. 行列对齐:先按视觉补齐所有合并单元格——纵向合并则重复上方单元格内容,横向合并则留空字符串;无线表按对齐虚拟列线。
  2657. 2. 单格内出现多个“□”时,把被勾选(☑、√、×、■)的选项原文输出;若没有任何勾选,该字段输出 null。
  2658. 3. 所有日期统一转 yyyy-mm-dd,原格式“1990年1月1日”→1990-01-01;若缺日/月,用-01补位。
  2659. 4. 电话、传真、手机号:输出连续数字,遇到“(0 )”或“-”一律删除,只保留 7~15 位数字;若缺区号,原样保留。
  2660. 5. 金额:保留原数字,如“3000”。
  2661. 6. 地址:省、市、区、街道、门牌、邮编用空格分隔,不省略。
  2662. 7. 若同一张表出现“现住址”“家庭地址”“单位地址”等多列,依次编号 address_home / address_unit / address_legal。
  2663. 8. 输出顺序:按表格从左到右、从上到下逐行扫描,字段名重复时加序号,如 child_name_1、child_name_2。
  2664. 9. 结果格式:每行一个键值对,字段名与值之间用英文冒号+空格分隔,不要表格 Markdown,不要多余说明。
  2665. 10. 文件命名空间:每份表的最前面加一行 filename 作为起始标记(例:出国个人申请表.doc)。
  2666. 11. 内容为空的字段,显示标题,记空值。
  2667. 12. 只返回json结果,不需要其他内容;json内容去掉换行。");
  2668. var messages = new List<SeedMessages>
  2669. {
  2670. new() { Role = KimiRole.system, Content = "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长识别文件为Json格式的对话。你会为用户提供安全,有帮助,准确的回答。同时,你会拒绝一切涉及恐怖主义,种族歧视,黄色暴力等问题的回答。Moonshot AI 为专有名词,不可翻译成其他语言。" },
  2671. new() { Role = KimiRole.user, Content = seedMessage }
  2672. };
  2673. messages.InsertRange(1, seedConter);
  2674. string jsonString = string.Empty;
  2675. object jsonData = null;
  2676. bool isJson = false; // 是否是json格式 不是json格式继续访问AI
  2677. while (!isJson)
  2678. {
  2679. kimiAI_API_Index++;
  2680. var kimiApiResult = await KiMiApi.SeedMessage(messages);
  2681. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  2682. jsonString += kimiApiResult_JObject["content"].ToString();
  2683. string startStr = "```json", endStr = "```";
  2684. // 判断并清除开头部分
  2685. if (jsonString.StartsWith(startStr))
  2686. {
  2687. jsonString = jsonString.Replace(startStr, "");
  2688. }
  2689. // 判断并清除结尾部分
  2690. if (jsonString.EndsWith(endStr))
  2691. {
  2692. jsonString = jsonString.Replace(endStr, "");
  2693. }
  2694. //验证json格式是否正确
  2695. try
  2696. {
  2697. jsonData = JsonDocument.Parse(jsonString);
  2698. isJson = true; // 如果解析成功,则是json格式
  2699. }
  2700. catch (Exception)
  2701. {
  2702. //messages = new List<SeedMessages>() { new() { Role = KimiRole.user, Content = "接着说" } };
  2703. messages.Add(new() { Role = KimiRole.user, Content = "接着上一个话题继续完成未完成的内容。" });
  2704. }
  2705. }
  2706. if (jsonData == null)
  2707. {
  2708. return Ok(JsonView(false, "kimi识别json转换失败。"));
  2709. }
  2710. var visaDetails = new VisaDetailsView();
  2711. //按照表格类型分别进行参数处理
  2712. // 1. 澳新签证个人申请表
  2713. // 2. 出国个人申请表
  2714. // 3. 美国签证个人申请表格
  2715. // 4. 沙特个人信息表格
  2716. // 5. 申根签证个人资料表
  2717. // 6. 中文个人简历模板
  2718. switch (fileTypeId)
  2719. {
  2720. //澳新签证个人申请表
  2721. case 1:
  2722. _logger.LogInformation("【签证上传文件操作信息】【澳新签证个人申请表】【KIMI-AI-API访问计次】{count} 次", kimiAI_API_Index);
  2723. VisaApplication resInfo = System.Text.Json.JsonSerializer.Deserialize<VisaApplication>(jsonString);
  2724. break;
  2725. //美国签证个人申请表格
  2726. case 3:
  2727. _logger.LogInformation("【签证上传文件操作信息】【美国签证个人申请表格】【KIMI-AI-API访问计次】{count} 次", kimiAI_API_Index);
  2728. string name = (string)jsonData.GetType().GetProperty("姓名")!.GetValue(jsonData)!;
  2729. string passportNo = (string)jsonData.GetType().GetProperty("护照号码")!.GetValue(jsonData)!;
  2730. string passportPlace = (string)jsonData.GetType().GetProperty("护照签发地")!.GetValue(jsonData)!;
  2731. string idNo = (string)jsonData.GetType().GetProperty("身份证号码")!.GetValue(jsonData)!;
  2732. string maritalStatusText = (string)jsonData.GetType().GetProperty("婚姻状况")!.GetValue(jsonData)!;
  2733. int maritalStatus = maritalStatusText switch
  2734. {
  2735. "未设置" => 0,
  2736. "未婚" => 1,
  2737. "已婚" => 2,
  2738. "离异" => 3,
  2739. "丧偶" => 4,
  2740. _ => -1
  2741. };
  2742. string birthDay = (string)jsonData.GetType().GetProperty("出生日期")!.GetValue(jsonData)!;
  2743. DateTime.TryParse(birthDay, out DateTime birthDayDt);
  2744. string birthPlace = (string)jsonData.GetType().GetProperty("出生地点")!.GetValue(jsonData)!;
  2745. var birthDay1 = CommonFun.SplitProvinceCity(birthPlace);
  2746. string birthDay_mate = (string)jsonData.GetType().GetProperty("配偶出生日期")!.GetValue(jsonData)!;
  2747. DateTime.TryParse(birthDay_mate, out DateTime birthDayDt_mate);
  2748. string birthPlace_mate = (string)jsonData.GetType().GetProperty("配偶出生地")!.GetValue(jsonData)!;
  2749. var birthDay1_mate = CommonFun.SplitProvinceCity(birthPlace_mate);
  2750. var addressText = (string)jsonData.GetType().GetProperty("家庭地址")!.GetValue(jsonData)!;
  2751. var address = SplitAddressZip(addressText);
  2752. //美国驾照信息
  2753. string driveText = (string)jsonData.GetType().GetProperty("是否有美国驾照")!.GetValue(jsonData)!;
  2754. var driveInfo = LicenseParser(driveText);
  2755. //美国社会安全号或者纳税ID号
  2756. string ssnText = (string)jsonData.GetType().GetProperty("是否有美国社会安全号或者纳税ID号")!.GetValue(jsonData)!;
  2757. //单位信息
  2758. string clientName = (string)jsonData.GetType().GetProperty("目前就职单位或就读学校")!.GetValue(jsonData)!;
  2759. string clientAddr = (string)jsonData.GetType().GetProperty("目前就职单位或就读学校地址")!.GetValue(jsonData)!;//
  2760. var (hasSsnItin, number) = SsnItinParser(ssnText);
  2761. //婚姻相关
  2762. var WeddingText = (string)jsonData.GetType().GetProperty("若离婚,婚姻起止时间")!.GetValue(jsonData)!;
  2763. var (f, t) = WeddingParser(WeddingText);
  2764. //美国联系人电话和邮箱
  2765. var peText = (string)jsonData.GetType().GetProperty("联系人电话及邮箱")!.GetValue(jsonData)!;
  2766. var usa_phone = Regex.Match(peText ?? "", @"[\d-]+").Value; // 数字和中横线
  2767. var usa_email = Regex.Match(peText ?? "", @"[^@\s]+@[^@\s]+\.[^@\s]+").Value;
  2768. //赴美时间、停留时间处理
  2769. var usa_dateText = (string)jsonData.GetType().GetProperty("联系人电话及邮箱")!.GetValue(jsonData)!;
  2770. var (usa_d, usa_days) = TravelParser(usa_dateText);
  2771. //赴美同行人
  2772. string usaCmpNameText = (string)jsonData.GetType().GetProperty("赴美同行人")!.GetValue(jsonData)!;
  2773. string usaCmpName = string.Empty;
  2774. if (usaCmpNameText.Contains("是"))
  2775. {
  2776. var usaCmpNameTextSplit = usaCmpNameText.Replace(":", "-").Replace("", "-").Split("-");
  2777. if (usaCmpNameTextSplit.Length > 1)
  2778. {
  2779. usaCmpName = usaCmpNameTextSplit[1];
  2780. }
  2781. }
  2782. //是否丢失过护照
  2783. string loseCodeText = (string)jsonData.GetType().GetProperty("是否丢失过护照")!.GetValue(jsonData)!;
  2784. string loseCode = string.Empty;
  2785. if (loseCodeText.Contains("是"))
  2786. {
  2787. var loseCodeTextSplit = loseCodeText.Replace(":", "-").Replace("", "-").Split("-");
  2788. if (loseCodeTextSplit.Length > 1)
  2789. {
  2790. usaCmpName = loseCodeTextSplit[1];
  2791. }
  2792. }
  2793. //是否获得过美国签证
  2794. string usaVisaText = (string)jsonData.GetType().GetProperty("是否丢失过护照")!.GetValue(jsonData)!;
  2795. string usaVisaDateText = (string)jsonData.GetType().GetProperty("获得日期")!.GetValue(jsonData)!;
  2796. //DateTime usaVisaDate;
  2797. if (!string.IsNullOrEmpty(usaVisaDateText))
  2798. {
  2799. if (DateTime.TryParse(usaVisaDateText, out DateTime usaVisaDate))
  2800. {
  2801. visaDetails.ClientInfo.GetUSAVisaDate = usaVisaDate;
  2802. }
  2803. }
  2804. string usaFingerText = (string)jsonData.GetType().GetProperty("是否留过十指指纹")!.GetValue(jsonData)!;
  2805. int usaFinger = 0;
  2806. if (usaFingerText.Contains('是')) usaFinger = 1;
  2807. string usaLoseText = (string)jsonData.GetType().GetProperty("签证是否曾遗失")!.GetValue(jsonData)!;
  2808. int usaLose = 0;
  2809. if (usaLoseText.Contains("是")) usaLose = 1;
  2810. //是否曾抵达过美国
  2811. string usaHadArrival‌Text = (string)jsonData.GetType().GetProperty("是否曾抵达过美国")!.GetValue(jsonData)!;
  2812. var (usaHadArrivalf, usaHadArrivalD, usaHadArrivalDays) = TravelHadFlagParser(usaHadArrival‌Text);
  2813. //是否有被美国拒发签证的经历
  2814. string usaRejecteVisaTest = (string)jsonData.GetType().GetProperty("是否有被美国拒发签证的经历")!.GetValue(jsonData)!;
  2815. var (denied, rejectedDate, rejectedPlace, rejectedType) = VisaDenialParser(usaRejecteVisaTest);
  2816. if (denied)
  2817. {
  2818. visaDetails.ClientInfo.RejectedDate = rejectedDate;
  2819. visaDetails.ClientInfo.RejectedPlace = rejectedPlace;
  2820. visaDetails.ClientInfo.RejectedVisa = rejectedType;
  2821. }
  2822. //是否在申请或曾经申请过美国移民签证
  2823. string usaImmVisaText‌ = (string)jsonData.GetType().GetProperty("是否在申请或曾经申请过美国移民签证")!.GetValue(jsonData)!;
  2824. var (immDenied, immDate, immPlace, immType) = VisaDenialParser(usaImmVisaText‌);
  2825. if (immDenied)
  2826. {
  2827. visaDetails.ClientInfo.USAImmVisa‌Date = immDate;
  2828. visaDetails.ClientInfo.USAImmVisa‌Place = immPlace;
  2829. visaDetails.ClientInfo.USAImmVisa‌ = immType;
  2830. }
  2831. //在美直系
  2832. string usaImmedText‌ = (string)jsonData.GetType().GetProperty("是否有直系亲属在美国")!.GetValue(jsonData)!;
  2833. var (immedDenied, immedName, immedRel, immedStat) = FourFieldParser(usaImmedText‌);
  2834. if (immedDenied)
  2835. {
  2836. visaDetails.ClientInfo.USAImmedFamName = immedName;
  2837. visaDetails.ClientInfo.USAImmedFamRel = immedRel;
  2838. visaDetails.ClientInfo.USAImmedFamStat = immedStat;
  2839. }
  2840. //在美旁系
  2841. string usaUncleText‌ = (string)jsonData.GetType().GetProperty("是否有旁系亲属在美国")!.GetValue(jsonData)!;
  2842. var (uncleDenied, uncleName, uncleRel, uncleStat) = FourFieldParser(usaUncleText‌);
  2843. if (immedDenied)
  2844. {
  2845. visaDetails.ClientInfo.USAUncleFamName = uncleName;
  2846. visaDetails.ClientInfo.USAUncleFamRel = uncleName;
  2847. visaDetails.ClientInfo.USAUncleFamStat = uncleStat;
  2848. }
  2849. //服役时间 MilitaryParser
  2850. string militaryText‌ = (string)jsonData.GetType().GetProperty("是否曾参过军")!.GetValue(jsonData)!;
  2851. var (militaryH, militaryB, militaryR, militaryS, (militaryStart, militaryEnd)) = MilitaryParser(militaryText‌);
  2852. var militarys = new List<MilitaryInfo>();
  2853. if (militaryH)
  2854. {
  2855. militarys.Add(new()
  2856. {
  2857. MilBranch = militaryB,
  2858. MilRank = militaryR,
  2859. MilSkill = militaryS,
  2860. ServeTimeBegin = militaryStart,
  2861. ServeTimeEnd = militaryEnd,
  2862. });
  2863. }
  2864. //申请人父母信息 ParentParser
  2865. string fthMthText‌ = (string)jsonData.GetType().GetProperty("申请人父母信息")!.GetValue(jsonData)!;
  2866. if (!string.IsNullOrEmpty(fthMthText‌))
  2867. {
  2868. var (fName, fDob, mName, mDob) = ParentParser(fthMthText‌);
  2869. visaDetails.ClientInfo.FthName = fName;
  2870. visaDetails.ClientInfo.FthBirth = fDob;
  2871. visaDetails.ClientInfo.MthName = mName;
  2872. visaDetails.ClientInfo.MthBirth = mDob;
  2873. }
  2874. visaDetails.ClientInfo = new()
  2875. {
  2876. LastName = name.GetLastName(),
  2877. FirstName = name.GetFirstName(),
  2878. Sex = (string)jsonData.GetType().GetProperty("性别")!.GetValue(jsonData)! == "男" ? 0 : 1,
  2879. OldName = (string)jsonData.GetType().GetProperty("曾用名")!.GetValue(jsonData)!,
  2880. BirthDay = birthDayDt,
  2881. BirthProvince = birthDay1.province,
  2882. BirthCity = birthDay1.city,
  2883. Address = address.address,
  2884. PostCodes = address.zipCode,
  2885. Marriage = maritalStatus,
  2886. MateName = (string)jsonData.GetType().GetProperty("配偶姓名")!.GetValue(jsonData)!,
  2887. MateBirthDay = birthDayDt_mate,
  2888. MateBirthCountry = birthDay1_mate.province,
  2889. MateBirthCity = birthDay1_mate.city,
  2890. USA_DLNo = driveInfo.number,
  2891. USA_DLPlace = driveInfo.place,
  2892. USA_SSNOrITIN = number,
  2893. Resident = CleanPrefix((string)jsonData.GetType().GetProperty("是否是其他国家的永久居民")!.GetValue(jsonData)!),
  2894. HasSocialAcc‌ = CleanPrefix((string)jsonData.GetType().GetProperty("近五年内是否使用过任何社交账号")!.GetValue(jsonData)!),
  2895. WeddingDate = f,
  2896. DivorceDate = t,
  2897. DivorceRsn = (string)jsonData.GetType().GetProperty("离婚原因")!.GetValue(jsonData)!,
  2898. Job = (string)jsonData.GetType().GetProperty("职务")!.GetValue(jsonData)!,
  2899. Wage = (string)jsonData.GetType().GetProperty("月薪")!.GetValue(jsonData)!,
  2900. WorkState = (string)jsonData.GetType().GetProperty("工作职责")!.GetValue(jsonData)!,
  2901. WorkDate = (string)jsonData.GetType().GetProperty("入职/入学时间(详细到月)")!.GetValue(jsonData)!,
  2902. USAAddress = (string)jsonData.GetType().GetProperty("请提供美国详细住址")!.GetValue(jsonData)!,
  2903. USAPurpose = (string)jsonData.GetType().GetProperty("赴美目的")!.GetValue(jsonData)!,
  2904. CostBearers = (string)jsonData.GetType().GetProperty("费用谁付")!.GetValue(jsonData)!,
  2905. USAContact = (string)jsonData.GetType().GetProperty("美国联系人或组织")!.GetValue(jsonData)!,
  2906. USAContactTel = usa_phone,
  2907. USAContactEmail = usa_email,
  2908. USADate = usa_d,
  2909. USADays = usa_days,
  2910. USAArrivalCity‌ = (string)jsonData.GetType().GetProperty("赴美的到达城市")!.GetValue(jsonData)!,
  2911. USADepartCity‌ = (string)jsonData.GetType().GetProperty("赴美的离开城市")!.GetValue(jsonData)!,
  2912. USAVisitSites‌ = (string)jsonData.GetType().GetProperty("计划在美国访问的景点")!.GetValue(jsonData)!,
  2913. USACmpName = usaCmpName,
  2914. USACmpRelation = (string)jsonData.GetType().GetProperty("同行人关系")!.GetValue(jsonData)!,
  2915. Tel = (string)jsonData.GetType().GetProperty("家庭电话")!.GetValue(jsonData)!,
  2916. ClientPhone = (string)jsonData.GetType().GetProperty("单位电话")!.GetValue(jsonData)!,
  2917. Phone = (string)jsonData.GetType().GetProperty("移动电话")!.GetValue(jsonData)!,
  2918. Cntry5Y‌ = (string)jsonData.GetType().GetProperty("过去5年内到过的国家")!.GetValue(jsonData)!,
  2919. LangSkill‌ = (string)jsonData.GetType().GetProperty("面签时能流利交流的语言")!.GetValue(jsonData)!,
  2920. LoseCode = loseCode,
  2921. DenyNationRsn = (string)jsonData.GetType().GetProperty("曾被哪些国家拒签/拒签原因")!.GetValue(jsonData)!,
  2922. USAVisaCode = (string)jsonData.GetType().GetProperty("签证号码")!.GetValue(jsonData)!,
  2923. USAVisaCate = (string)jsonData.GetType().GetProperty("获签类型")!.GetValue(jsonData)!,
  2924. //GetUSAVisaDate = usaVisaDate,
  2925. USAFinger = usaFinger,
  2926. IsLose = usaLose,
  2927. USAHadArrival = usaHadArrivalD,
  2928. USAHadDays = usaHadArrivalDays,
  2929. ArmyState = JsonConvert.SerializeObject(militarys)
  2930. };
  2931. visaDetails.ClientCerts = new() {
  2932. new(){ SdId = 74,CertNo = passportNo,IDCardAddress = passportPlace },
  2933. new(){ SdId = 73,CertNo = idNo},
  2934. };
  2935. visaDetails.ClientCompany = new() { CompanyFullName = clientName, Address = clientAddr };
  2936. break;
  2937. //中文个人简历模板
  2938. case 6:
  2939. _logger.LogInformation("【签证上传文件操作信息】【中文个人简历模板】【KIMI-AI-API访问计次】{count} 次", kimiAI_API_Index);
  2940. visaDetails.ClientInfo.LastName = (string)jsonData.GetType().GetProperty("姓名(中英文拼音)")!.GetValue(jsonData)!;
  2941. visaDetails.ClientInfo.Sex = (string)jsonData.GetType().GetProperty("性别")!.GetValue(jsonData)! == "男" ? 0 : 1;
  2942. DateTime.TryParse((string)jsonData.GetType().GetProperty("出生日期")!.GetValue(jsonData)!, out DateTime birthDay11);
  2943. visaDetails.ClientInfo.BirthDay = birthDay11;
  2944. visaDetails.ClientInfo.BirthProvince = (string)jsonData.GetType().GetProperty("出生地")!.GetValue(jsonData)!;
  2945. visaDetails.ClientInfo.Address = (string)jsonData.GetType().GetProperty("家庭地址")!.GetValue(jsonData)!;
  2946. visaDetails.ClientInfo.Tel = (string)jsonData.GetType().GetProperty("家庭电话")!.GetValue(jsonData)!;
  2947. visaDetails.ClientInfo.TableOpTel = (string)jsonData.GetType().GetProperty("工作电话")!.GetValue(jsonData)!;
  2948. visaDetails.ClientInfo.Phone = (string)jsonData.GetType().GetProperty("移动电话")!.GetValue(jsonData)!;
  2949. visaDetails.ClientInfo.Email = (string)jsonData.GetType().GetProperty("电子邮件")!.GetValue(jsonData)!;
  2950. //学校信息
  2951. visaDetails.ClientSchools.Add(new()
  2952. {
  2953. School = (string)jsonData.GetType().GetProperty("教育学校名称")!.GetValue(jsonData)!,
  2954. Education = (string)jsonData.GetType().GetProperty("教育学位")!.GetValue(jsonData)!,
  2955. Subject = (string)jsonData.GetType().GetProperty("教育专业")!.GetValue(jsonData)!,
  2956. Remark = (string)jsonData.GetType().GetProperty("教育论文题目/研究重点(硕士、博士)")!.GetValue(jsonData)!,
  2957. });
  2958. //工作信息
  2959. visaDetails.ClientCompany=new()
  2960. {
  2961. CompanyFullName = (string)jsonData.GetType().GetProperty("工作经历雇主")!.GetValue(jsonData)!,
  2962. };
  2963. visaDetails.ClientInfo.Job = (string)jsonData.GetType().GetProperty("工作经历职位或头衔职责")!.GetValue(jsonData)!;
  2964. break;
  2965. default:
  2966. break;
  2967. }
  2968. //数据提交
  2969. #region 数据提交
  2970. _sqlSugar.BeginTran();
  2971. // 客户公司表
  2972. var compId = UpsertReturnId<Crm_CustomerCompany>(visaDetails.ClientCompany, o => o.CompanyFullName);
  2973. if (compId < 1)
  2974. {
  2975. _sqlSugar.RollbackTran();
  2976. return Ok(JsonView(false,"公司信息更新失败!"));
  2977. }
  2978. visaDetails.ClientInfo.CrmCompanyId = compId;
  2979. // 客户资料表
  2980. var clientId = UpsertReturnId<Crm_DeleClient>(visaDetails.ClientInfo, o => new { o.LastName, o.FirstName });
  2981. if (clientId < 1)
  2982. {
  2983. _sqlSugar.RollbackTran();
  2984. return Ok(JsonView(false, "客户信息更新失败!"));
  2985. }
  2986. for (int i = 0; i < visaDetails.ClientFamilys.Count(); i++)
  2987. {
  2988. visaDetails.ClientFamilys[i].DcId = clientId;
  2989. }
  2990. for (int i = 0; i < visaDetails.ClientCerts.Count(); i++)
  2991. {
  2992. visaDetails.ClientCerts[i].DcId = clientId;
  2993. }
  2994. for (int i = 0; i < visaDetails.ClientSchools.Count(); i++)
  2995. {
  2996. visaDetails.ClientSchools[i].DcId = clientId;
  2997. }
  2998. // 客户家庭表
  2999. foreach (var item in visaDetails.ClientFamilys)
  3000. {
  3001. var famId = UpsertReturnId<Crm_VisaCustomerFamily>(item, o => o.Name);
  3002. if (famId < 1)
  3003. {
  3004. _sqlSugar.RollbackTran();
  3005. return Ok(JsonView(false, "客户家庭信息更新失败!"));
  3006. }
  3007. }
  3008. // 客户证件表
  3009. foreach (var item in visaDetails.ClientCerts)
  3010. {
  3011. var certId = UpsertReturnId<Crm_CustomerCert>(item, o => o.CertNo);
  3012. if (certId < 1)
  3013. {
  3014. _sqlSugar.RollbackTran();
  3015. return Ok(JsonView(false, "客户证件信息更新失败!"));
  3016. }
  3017. }
  3018. // 客户学历表
  3019. foreach (var item in visaDetails.ClientSchools)
  3020. {
  3021. var schoolId = UpsertReturnId<Crm_VisaCustomerSchool>(item, o => o.School);
  3022. if (schoolId < 1)
  3023. {
  3024. _sqlSugar.RollbackTran();
  3025. return Ok(JsonView(false, "客户证件信息更新失败!"));
  3026. }
  3027. }
  3028. _sqlSugar.CommitTran();
  3029. #endregion
  3030. #endregion
  3031. return Ok(JsonView(true,jsonString));
  3032. }
  3033. #region 扩展处理
  3034. // 从 Expression<Func<T,object>> 里取出属性名
  3035. static string GetPropName<T>(Expression<Func<T, object>> expr)
  3036. {
  3037. if (expr.Body is UnaryExpression ue) expr = Expression.Lambda<Func<T, object>>(ue.Operand, expr.Parameters);
  3038. return ((MemberExpression)expr.Body).Member.Name;
  3039. }
  3040. /// <summary>
  3041. /// 5.1.4.193 可用:存在更新(非NULL非空串),不存在插入,返回主键ID
  3042. /// </summary>
  3043. public int UpsertReturnId<T>(T entity, Expression<Func<T, object>> whereExpr) where T : class, new()
  3044. {
  3045. // 1. 空字符串→NULL,让后续忽略
  3046. foreach (var pi in typeof(T).GetProperties())
  3047. if (pi.PropertyType == typeof(string) &&
  3048. pi.GetValue(entity) is string s &&
  3049. string.IsNullOrWhiteSpace(s))
  3050. pi.SetValue(entity, null);
  3051. // 2. 从表达式里拿属性名
  3052. string propName = GetPropName(whereExpr);
  3053. var propValue = typeof(T).GetProperty(propName)?.GetValue(entity);
  3054. // 3. 判断存在
  3055. bool exists = _sqlSugar.Queryable<T>().Where(propName, propValue).Any();
  3056. // 4. 执行 Upsert
  3057. if (exists)
  3058. {
  3059. _sqlSugar.Updateable(entity)
  3060. .WhereColumns(propName) // 指定条件列
  3061. .IgnoreColumns(ignoreAllNullColumns: true) // 忽略 NULL
  3062. .ExecuteCommand();
  3063. }
  3064. else
  3065. {
  3066. _sqlSugar.Insertable(entity).ExecuteReturnIdentity();
  3067. }
  3068. // 5. 返回主键值(自增/雪花已回填)
  3069. var idProp = typeof(T).GetProperties()
  3070. .First(p => p.GetCustomAttributes<SugarColumn>()
  3071. .Any(a => a.IsPrimaryKey));
  3072. return (int)idProp.GetValue(entity)!;
  3073. }
  3074. /// <summary>
  3075. /// 地址喊邮编 相关处理
  3076. /// </summary>
  3077. public static (string address, string zipCode) SplitAddressZip(string? s)
  3078. {
  3079. if (string.IsNullOrWhiteSpace(s))
  3080. return ("", "");
  3081. ReadOnlySpan<char> src = s.AsSpan();
  3082. int i = src.IndexOf("邮编".AsSpan());
  3083. if (i < 0) // 没有“邮编”字样
  3084. return (src.Trim().ToString(), "");
  3085. ReadOnlySpan<char> addr = src[..i].TrimEnd();
  3086. ReadOnlySpan<char> zip = src[(i + 3)..].Trim(); // 跳过“邮编:”
  3087. // 可能只有“邮编:”而没有数字
  3088. return (addr.IsEmpty ? "" : addr.ToString(),
  3089. zip.IsEmpty ? "" : zip.ToString());
  3090. }
  3091. /// <summary>
  3092. /// 驾照相 关处理
  3093. /// </summary>
  3094. /// <param name="raw"></param>
  3095. /// <returns></returns>
  3096. public static (bool hasLicense, string number, string place) LicenseParser(string? raw)
  3097. {
  3098. if (string.IsNullOrWhiteSpace(raw))
  3099. return (false, "", "");
  3100. // 1. 是否持有
  3101. bool has = raw.StartsWith("是", System.StringComparison.OrdinalIgnoreCase) ||
  3102. raw.StartsWith("Y", System.StringComparison.OrdinalIgnoreCase);
  3103. // 2. 去掉前缀,按空格切
  3104. ReadOnlySpan<char> s = raw.AsSpan();
  3105. int colon = s.IndexOf(':');
  3106. ReadOnlySpan<char> after = colon < 0 ? s : s[(colon + 1)..];
  3107. after = after.Trim();
  3108. int space = after.IndexOf(' ');
  3109. ReadOnlySpan<char> num = space < 0 ? after : after[..space];
  3110. ReadOnlySpan<char> st = space < 0 ? ReadOnlySpan<char>.Empty : after[(space + 1)..];
  3111. return (has, num.ToString().Trim(), st.ToString().Trim());
  3112. }
  3113. /// <summary>
  3114. /// 美国社会安全号或者纳税ID号 相关处理
  3115. /// </summary>
  3116. /// <param name="raw"></param>
  3117. /// <returns></returns>
  3118. public static (bool hasSsnItin, string number) SsnItinParser(string? raw)
  3119. {
  3120. if (string.IsNullOrWhiteSpace(raw))
  3121. return (false, "");
  3122. ReadOnlySpan<char> s = raw.AsSpan();
  3123. // 1. 是否持有
  3124. bool has = s.StartsWith("是", System.StringComparison.Ordinal) ||
  3125. s.StartsWith("Y", System.StringComparison.OrdinalIgnoreCase);
  3126. // 2. 取号码(去掉前缀和空格)
  3127. int colon = s.IndexOf(':');
  3128. ReadOnlySpan<char> num = colon < 0
  3129. ? ReadOnlySpan<char>.Empty
  3130. : s[(colon + 1)..].Trim();
  3131. return (has, num.ToString());
  3132. }
  3133. /// <summary>
  3134. /// 取消开始的“是:”或者“是”或者“ :”
  3135. /// </summary>
  3136. /// <param name="raw"></param>
  3137. /// <returns></returns>
  3138. public static string CleanPrefix(string? raw)
  3139. {
  3140. if (string.IsNullOrWhiteSpace(raw)) return "";
  3141. // 跳过第一个“是”或“Y”
  3142. ReadOnlySpan<char> s = raw.AsSpan();
  3143. int start = 0;
  3144. if (s.StartsWith("是") || s.StartsWith("Y", StringComparison.OrdinalIgnoreCase))
  3145. start = 1;
  3146. // 跳过连续 : 或空格
  3147. while (start < s.Length && (s[start] == ':' || s[start] == ' '))
  3148. start++;
  3149. return s[start..].Trim().ToString();
  3150. }
  3151. /// <summary>
  3152. /// 婚姻起止时间处理
  3153. /// </summary>
  3154. /// <param name="raw"></param>
  3155. /// <returns></returns>
  3156. public static (DateTime? fromDate, DateTime? toDate) WeddingParser(string? raw)
  3157. {
  3158. if (string.IsNullOrWhiteSpace(raw)) return (null, null);
  3159. Regex _clean = new(@"[\s~至]+", RegexOptions.Compiled);
  3160. // 1. 把所有“空格~至”统一成 '-'
  3161. string normalized = _clean.Replace(raw, "-");
  3162. // 2. 切两段
  3163. string[] parts = normalized.Split('-', StringSplitOptions.RemoveEmptyEntries);
  3164. if (parts.Length != 2) return (null, null);
  3165. // 3. 解析
  3166. bool ff = DateTime.TryParse(parts[0].Trim(),out var from);
  3167. bool tf = DateTime.TryParse(parts[1].Trim(),out var to);
  3168. return (tf ? from : null, tf ? to : null);
  3169. }
  3170. /// <summary>
  3171. /// 出行日期和天数处理
  3172. /// </summary>
  3173. /// <param name="raw"></param>
  3174. /// <returns></returns>
  3175. public static (DateTime? travelDate, int? days) TravelParser(string? raw)
  3176. {
  3177. if (string.IsNullOrWhiteSpace(raw)) return (null, null);
  3178. // 切成两段:第一段日期,第二段天数
  3179. Regex sep = new(@"[^0-9./-]+", RegexOptions.Compiled);
  3180. string[] parts = sep.Split(raw.Trim());
  3181. if (parts.Length < 2) return (null, null);
  3182. bool okDate = DateTime.TryParse(parts[0], out DateTime date);
  3183. bool okDays = int.TryParse(parts[1], out int days) && days > 0;
  3184. return (okDate ? date : null, okDays ? days : null);
  3185. }
  3186. /// <summary>
  3187. /// 是否曾抵达过美国
  3188. /// </summary>
  3189. /// <param name="raw"></param>
  3190. /// <returns></returns>
  3191. public static (bool hasTravel, string date, string days) TravelHadFlagParser(string? raw)
  3192. {
  3193. if (string.IsNullOrWhiteSpace(raw)) return (false, string.Empty, string.Empty);
  3194. Regex sep = new(@"[^0-9./-]+", RegexOptions.Compiled);
  3195. // 1. 是否持有
  3196. bool has = raw.AsSpan().TrimStart().StartsWith("是") ||
  3197. raw.AsSpan().TrimStart().StartsWith("Y", StringComparison.OrdinalIgnoreCase);
  3198. // 2. 用非数字分隔符切成三段:第一段空,第二段日期,第三段天数
  3199. string[] parts = sep.Split(raw.Trim());
  3200. if (parts.Length < 3) return (has, string.Empty, string.Empty);
  3201. return (has, parts[1], parts[2]);
  3202. }
  3203. /// <summary>
  3204. /// 是否有被美国拒发签证的经历
  3205. /// </summary>
  3206. /// <param name="raw"></param>
  3207. /// <returns></returns>
  3208. public static (bool wasDenied, DateTime? date, string place, string visaType) VisaDenialParser(string? raw)
  3209. {
  3210. if (string.IsNullOrWhiteSpace(raw)) return (false, null, "", "");
  3211. bool denied = raw.AsSpan().TrimStart().StartsWith("有") ||
  3212. raw.AsSpan().TrimStart().StartsWith("Y", StringComparison.OrdinalIgnoreCase);
  3213. var parts = Regex.Split(raw.Trim(), @"[^0-9A-Za-z-]+");
  3214. if (parts.Length < 4) return (denied, null, "", "");
  3215. DateTime.TryParse(parts[1], out var dt); // ← 这里改为 DateTime
  3216. return (denied, dt, parts[2], parts[3]);
  3217. }
  3218. /// <summary>
  3219. /// 在美直系、旁系 处理
  3220. /// </summary>
  3221. /// <param name="raw"></param>
  3222. /// <returns></returns>
  3223. public static (bool flag, string name, string rel, string stat) FourFieldParser(string? raw)
  3224. {
  3225. if (string.IsNullOrWhiteSpace(raw)) return (false, "", "", "");
  3226. var parts = raw.Split((char[]?)null, StringSplitOptions.RemoveEmptyEntries);
  3227. if (parts.Length < 4) return (false, "", "", "");
  3228. bool flag = parts[0] is "有" or "是" or "Y" or "Yes";
  3229. string name = parts[1];
  3230. string rel = parts[2];
  3231. string stat = parts[3];
  3232. return (flag, name, rel, stat);
  3233. }
  3234. /// <summary>
  3235. /// 服役时间处理
  3236. /// </summary>
  3237. /// <param name="raw"></param>
  3238. /// <returns></returns>
  3239. public static (bool hasService, string branch, string rank, string specialty,(DateTime? start, DateTime? end) period) MilitaryParser(string? raw)
  3240. {
  3241. const string fmt = "yyyy年MM月dd日";
  3242. if (string.IsNullOrWhiteSpace(raw))
  3243. return (false, "", "", "", (null, null));
  3244. var parts = raw.Split((char[]?)null, StringSplitOptions.RemoveEmptyEntries);
  3245. if (parts.Length < 5) return (false, "", "", "", (null, null));
  3246. bool has = parts[0] is "是" or "Y" or "Yes";
  3247. string branch = parts[1];
  3248. string rank = parts[2];
  3249. string specialty = parts[3];
  3250. // 拼回时间字符串
  3251. string periodRaw = string.Join(" ", parts[4..]);
  3252. var span = periodRaw.AsSpan();
  3253. int zhi = span.IndexOf("至");
  3254. if (zhi < 0) return (has, branch, rank, specialty, (null, null));
  3255. var startStr = span.Slice(0, zhi).Trim();
  3256. var endStr = span.Slice(zhi + 1).Trim();
  3257. bool okStart = DateTime.TryParseExact(startStr.ToString(), fmt, null, DateTimeStyles.None, out var start);
  3258. bool okEnd = DateTime.TryParseExact(endStr.ToString(), fmt, null, DateTimeStyles.None, out var end);
  3259. return (has, branch, rank, specialty, (okStart ? start : null, okEnd ? end : null));
  3260. }
  3261. /// <summary>
  3262. /// 申请人父母信息
  3263. /// </summary>
  3264. /// <param name="raw"></param>
  3265. /// <returns></returns>
  3266. public static (string fatherName, DateTime? fatherDob,string motherName, DateTime? motherDob)ParentParser(string? raw)
  3267. {
  3268. const string fmt = "yyyy年MM月dd日";
  3269. if (string.IsNullOrWhiteSpace(raw)) return ("", null, "", null);
  3270. // 按空格切,去掉空元素
  3271. var parts = raw.Split((char[]?)null, StringSplitOptions.RemoveEmptyEntries);
  3272. if (parts.Length < 4) return ("", null, "", null);
  3273. // 父亲
  3274. string fName = parts[0];
  3275. DateTime.TryParseExact(parts[1], fmt, null, DateTimeStyles.None, out var fDob);
  3276. // 母亲
  3277. string mName = parts[2];
  3278. DateTime.TryParseExact(parts[3], fmt, null, DateTimeStyles.None, out var mDob);
  3279. return (fName, fDob, mName, mDob);
  3280. }
  3281. public class VisaDetailsView
  3282. {
  3283. /// <summary>
  3284. /// 客户资料表
  3285. /// </summary>
  3286. public Crm_DeleClient ClientInfo { get; set; }
  3287. /// <summary>
  3288. /// 客户家庭表
  3289. /// </summary>
  3290. public List<Crm_VisaCustomerFamily> ClientFamilys { get; set; }
  3291. /// <summary>
  3292. /// 客户公司表
  3293. /// </summary>
  3294. public Crm_CustomerCompany ClientCompany { get; set; }
  3295. /// <summary>
  3296. /// 客户证件表
  3297. /// </summary>
  3298. public List<Crm_CustomerCert> ClientCerts { get; set; }
  3299. /// <summary>
  3300. /// 客户学历表
  3301. /// </summary>
  3302. public List<Crm_VisaCustomerSchool> ClientSchools { get; set; }
  3303. }
  3304. private int GetSuccessCount(List<FileUploadResult> results)
  3305. {
  3306. var count = 0;
  3307. foreach (var result in results)
  3308. {
  3309. if (result.Success) count++;
  3310. }
  3311. return count;
  3312. }
  3313. #endregion
  3314. /// <summary>
  3315. /// 根据团组Id获取签证客户信息List
  3316. /// </summary>
  3317. /// <param name="dto">请求dto</param>
  3318. /// <returns></returns>
  3319. [HttpPost]
  3320. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3321. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  3322. {
  3323. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  3324. if (groupData.Code != 0)
  3325. {
  3326. return Ok(JsonView(false, groupData.Msg));
  3327. }
  3328. return Ok(JsonView(groupData.Data));
  3329. }
  3330. /// <summary>
  3331. /// IOS获取团组签证拍照上传进度01(团组列表)
  3332. /// </summary>
  3333. /// <param name="dto">请求dto</param>
  3334. /// <returns></returns>
  3335. [HttpPost]
  3336. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3337. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  3338. {
  3339. if (dto == null)
  3340. {
  3341. return Ok(JsonView(false, "参数为空"));
  3342. }
  3343. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  3344. return Ok(JsonView(visaList));
  3345. }
  3346. /// <summary>
  3347. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  3348. /// </summary>
  3349. /// <returns></returns>
  3350. [HttpPost]
  3351. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3352. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  3353. {
  3354. if (dto == null)
  3355. {
  3356. return Ok(JsonView(false, "请求错误:"));
  3357. }
  3358. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  3359. return Ok(JsonView(list));
  3360. }
  3361. /// <summary>
  3362. /// IOS获取团组签证拍照上传进度03(相册)
  3363. /// </summary>
  3364. /// <returns></returns>
  3365. [HttpPost]
  3366. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3367. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  3368. {
  3369. if (dto == null)
  3370. {
  3371. return Ok(JsonView(false, "请求错误:"));
  3372. }
  3373. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  3374. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  3375. list.ForEach(s => s.url = url);
  3376. return Ok(JsonView(list));
  3377. }
  3378. /// <summary>
  3379. /// IOS获取团组签证拍照上传进度04(图片上传)
  3380. /// </summary>
  3381. /// <param name="dto"></param>
  3382. /// <returns></returns>
  3383. [HttpPost]
  3384. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3385. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  3386. {
  3387. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  3388. //if (!string.IsNullOrEmpty(result))
  3389. //{
  3390. //}
  3391. //else {
  3392. // return Ok(JsonView(false, "上传失败"));
  3393. //}
  3394. var dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  3395. int sucNum = 0;
  3396. try
  3397. {
  3398. foreach (var item in dto.base64DataList)
  3399. {
  3400. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  3401. string result = DecodeBase64ToImage(item, imageName);
  3402. if (!string.IsNullOrEmpty(result))
  3403. {
  3404. var pic = new Grp_VisaProgressCustomerPicture
  3405. {
  3406. CreateUserId = dto.CreateUserId,
  3407. PicName = imageName,
  3408. PicPath = result,
  3409. VisaProgressCustomerId = dto.visaProgressCustomerId
  3410. };
  3411. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  3412. if (insertResult > 0)
  3413. {
  3414. sucNum++;
  3415. }
  3416. }
  3417. }
  3418. }
  3419. catch (Exception ex)
  3420. {
  3421. return Ok(JsonView(false, ex.Message));
  3422. }
  3423. string msg = string.Format(@"成功上传{0}张", sucNum);
  3424. return Ok(JsonView(true, msg));
  3425. }
  3426. private string DecodeBase64ToImage(string base64DataURL, string imgName)
  3427. {
  3428. string filename = "";//声明一个string类型的相对路径
  3429. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  3430. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  3431. try//会有异常抛出,try,catch一下
  3432. {
  3433. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  3434. var ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  3435. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  3436. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  3437. //文件名称
  3438. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  3439. //上传的文件的路径
  3440. string filePath = "";
  3441. if (!Directory.Exists(fileDir))
  3442. {
  3443. Directory.CreateDirectory(fileDir);
  3444. }
  3445. //上传的文件的路径
  3446. filePath = fileDir + filename;
  3447. //string url = HttpRuntime.AppDomainAppPath.ToString();
  3448. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  3449. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  3450. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  3451. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  3452. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  3453. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  3454. ms.Close();//关闭当前流,并释放所有与之关联的资源
  3455. bitmap.Dispose();
  3456. }
  3457. catch (Exception e)
  3458. {
  3459. string massage = e.Message;
  3460. Logs("IOS图片上传Error:" + massage);
  3461. //filename = e.Message;
  3462. }
  3463. return filename;//返回相对路径
  3464. }
  3465. /// <summary>
  3466. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  3467. /// </summary>
  3468. /// <param name="dto"></param>
  3469. /// <returns></returns>
  3470. [HttpPost]
  3471. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3472. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  3473. {
  3474. if (dto == null)
  3475. {
  3476. return Ok(JsonView(false, "请求错误:"));
  3477. }
  3478. string msg = "参数错误";
  3479. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  3480. {
  3481. try
  3482. {
  3483. //_delegationVisaRep.BeginTran();
  3484. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  3485. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  3486. .Where(s => s.Id == dto.visaProgressCustomerId)
  3487. .ExecuteCommandAsync();
  3488. if (updCount > 0 && dto.publishCode == 1)
  3489. {
  3490. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  3491. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  3492. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  3493. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  3494. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  3495. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  3496. if (groupData == null)
  3497. {
  3498. _delegationVisaRep.RollbackTran();
  3499. }
  3500. string title = string.Format(@"[签证进度更新]");
  3501. string content = string.Format(@"测试文本");
  3502. bool rst = await _message.AddMsg(new MessageDto()
  3503. {
  3504. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  3505. IssuerId = dto.publisher,
  3506. Title = title,
  3507. Content = content,
  3508. ReleaseTime = DateTime.Now,
  3509. UIdList = new List<int> {
  3510. 234
  3511. }
  3512. });
  3513. if (rst)
  3514. {
  3515. return Ok(JsonView(true, "发送通知成功"));
  3516. }
  3517. }
  3518. //_delegationVisaRep.CommitTran();
  3519. }
  3520. catch (Exception)
  3521. {
  3522. //_delegationVisaRep.RollbackTran();
  3523. }
  3524. }
  3525. return Ok(JsonView(true, msg));
  3526. }
  3527. #endregion
  3528. #endregion
  3529. #region 团组任务分配
  3530. /// <summary>
  3531. /// 团组任务分配初始化
  3532. /// </summary>
  3533. /// <returns></returns>
  3534. [HttpPost]
  3535. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3536. public async Task<IActionResult> GetTaskAssignmen()
  3537. {
  3538. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  3539. if (groupData.Code != 0)
  3540. {
  3541. return Ok(JsonView(false, groupData.Msg));
  3542. }
  3543. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3544. }
  3545. /// <summary>
  3546. /// 团组任务分配查询
  3547. /// </summary>
  3548. /// <param name="dto"></param>
  3549. /// <returns></returns>
  3550. [HttpPost]
  3551. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3552. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  3553. {
  3554. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  3555. if (groupData.Code != 0)
  3556. {
  3557. return Ok(JsonView(false, groupData.Msg));
  3558. }
  3559. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3560. }
  3561. /// <summary>
  3562. /// 团组任务分配操作
  3563. /// </summary>
  3564. /// <param name="dto"></param>
  3565. /// <returns></returns>
  3566. [HttpPost]
  3567. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3568. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  3569. {
  3570. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  3571. if (groupData.Code != 0)
  3572. {
  3573. return Ok(JsonView(false, groupData.Msg));
  3574. }
  3575. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3576. }
  3577. /// <summary>
  3578. /// 团组任务分配
  3579. /// 批量分配
  3580. /// 查询团组
  3581. /// </summary>
  3582. /// <param name="dto"></param>
  3583. /// <returns></returns>
  3584. [HttpPost]
  3585. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3586. public async Task<IActionResult> TaskAllocationGroupSelect(TaskAllocationGroupSelectDto dto)
  3587. {
  3588. //参数验证
  3589. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  3590. if (!DateTime.TryParse(dto.VisitBeginDt, out _) || !DateTime.TryParse(dto.VisitEndDt, out _))
  3591. return Ok(JsonView(false, "团组出访开始/结束日期格式不正确!"));
  3592. return Ok(await _taskAssignmentRep.TaskAllocationGroupSelect(dto));
  3593. }
  3594. /// <summary>
  3595. /// 团组任务分配
  3596. /// 批量分配
  3597. /// </summary>
  3598. /// <param name="dto"></param>
  3599. /// <returns></returns>
  3600. [HttpPost]
  3601. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3602. public async Task<IActionResult> TaskAllocationBulkAdd(TaskAllocationBulkAddDto dto)
  3603. {
  3604. //参数验证
  3605. if (dto.UserIds.Length < 1) return Ok(JsonView(false, $"请选择分配人员!"));
  3606. if (dto.PermissionTypeIds.Length < 1) return Ok(JsonView(false, $"请选择分配类型!"));
  3607. if (dto.GroupIds.Length < 1) return Ok(JsonView(false, "请选择分配团组Id"));
  3608. if (dto.CurrUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId数组参数"));
  3609. return Ok(await _taskAssignmentRep.TaskAllocationBulkAdd(dto));
  3610. }
  3611. #endregion
  3612. #region 团组费用审核
  3613. /// <summary>
  3614. /// 费用审核
  3615. /// 团组列表 Page
  3616. /// </summary>
  3617. /// <param name="_dto">团组列表请求dto</param>
  3618. /// <returns></returns>
  3619. [HttpPost]
  3620. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3621. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  3622. {
  3623. #region 参数验证
  3624. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  3625. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  3626. #region 页面操作权限验证
  3627. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  3628. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  3629. #endregion
  3630. #endregion
  3631. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  3632. {
  3633. string sqlWhere = string.Empty;
  3634. if (_dto.IsSure == 0) //未完成
  3635. {
  3636. sqlWhere += string.Format(@" And IsSure = 0");
  3637. }
  3638. else if (_dto.IsSure == 1) //已完成
  3639. {
  3640. sqlWhere += string.Format(@" And IsSure = 1");
  3641. }
  3642. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  3643. {
  3644. string tj = _dto.SearchCriteria;
  3645. 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}%')",
  3646. tj, tj, tj, tj, tj);
  3647. }
  3648. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  3649. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  3650. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  3651. From (
  3652. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  3653. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  3654. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  3655. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  3656. From Grp_DelegationInfo gdi
  3657. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  3658. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  3659. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  3660. Where gdi.IsDel = 0 {0}
  3661. ) temp ", sqlWhere);
  3662. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  3663. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  3664. var _view = new
  3665. {
  3666. PageFuncAuth = pageFunAuthView,
  3667. Data = _DelegationList
  3668. };
  3669. return Ok(JsonView(true, "查询成功!", _view, total));
  3670. }
  3671. else
  3672. {
  3673. return Ok(JsonView(false, "查询失败"));
  3674. }
  3675. }
  3676. /// <summary>
  3677. /// 获取团组费用审核
  3678. /// </summary>
  3679. /// <param name="_dto"></param>
  3680. /// <returns></returns>
  3681. [HttpPost]
  3682. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3683. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  3684. {
  3685. try
  3686. {
  3687. #region 参数验证
  3688. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  3689. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  3690. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  3691. #region 页面操作权限验证
  3692. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  3693. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  3694. #endregion
  3695. #endregion
  3696. var _view = new Grp_CreditCardPaymentView();
  3697. var clientNameList = GetSimplClientList(_dto.DiId);
  3698. #region 费用清单
  3699. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  3700. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  3701. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  3702. var entityList = _groupRepository.Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0).Where(exp.ToExpression()).ToList();
  3703. var detailList = new List<Grp_CreditCardPaymentDetailView>();
  3704. var ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  3705. /*
  3706. * 76://酒店预订
  3707. */
  3708. var _HotelReservations = await _groupRepository.Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3709. var _HotelReservationsContents = await _groupRepository.Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3710. /*
  3711. * 79://车/导游地接
  3712. */
  3713. var _CarTouristGuideGroundReservations = await _groupRepository.Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3714. var _CarTouristGuideGroundReservationsContent = await _groupRepository.Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3715. /*
  3716. * 80: //签证
  3717. */
  3718. var _VisaInfos = await _groupRepository.Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3719. /*
  3720. *81: //邀请/公务活动
  3721. */
  3722. var _InvitationOfficialActivities = await _groupRepository.Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3723. /*
  3724. * 82: //团组客户保险
  3725. */
  3726. var _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3727. /*
  3728. * Lable = 85 机票预订
  3729. */
  3730. var p_AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3731. /*
  3732. * 85 机票预定
  3733. */
  3734. var _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3735. /*
  3736. * 98 其他款项
  3737. */
  3738. var _DecreasePayments = await _groupRepository.Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3739. /*
  3740. * 285:收款退还
  3741. */
  3742. var _PaymentRefundAndOtherMoneys = await _groupRepository.Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3743. /*
  3744. * 1015: //超支费用
  3745. */
  3746. var _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3747. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  3748. /*
  3749. * 币种信息
  3750. */
  3751. var currencyItems = initDatas.Where(s => s.STid == 66).ToList();
  3752. /*
  3753. * 车/导游地接 费用类型
  3754. */
  3755. var carFeeTypeItems = initDatas.Where(s => s.STid == 17).ToList();
  3756. /*
  3757. * 车/导游地接 费用类型
  3758. */
  3759. var carFeeItems = initDatas.Where(s => s.STid == 83).ToList();
  3760. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  3761. /*
  3762. * 用户信息
  3763. */
  3764. var userItems = await _groupRepository._sqlSugar.Queryable<Sys_Users>().ToListAsync();
  3765. /*
  3766. * 费用模块
  3767. */
  3768. var sdPriceName = initDatas.Where(s => s.Id == _dto.Label).First();
  3769. string priceModule = string.Empty;
  3770. if (sdPriceName != null)
  3771. {
  3772. priceModule = sdPriceName.Name;
  3773. }
  3774. /*
  3775. * 成本信息
  3776. */
  3777. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  3778. decimal _groupRate = 0.0000M;
  3779. string _groupCurrencyCode = "-";
  3780. if (groupCost != null)
  3781. {
  3782. _groupRate = groupCost.Rate;
  3783. if (int.TryParse(groupCost.Currency, out int _currency))
  3784. {
  3785. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  3786. }
  3787. else _groupCurrencyCode = groupCost.Currency;
  3788. }
  3789. string costContentSql = $"Select * From Grp_GroupCost";
  3790. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  3791. //处理日期为空的天数
  3792. for (int i = 0; i < groupCostDetails.Count; i++)
  3793. if (i != 0)
  3794. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  3795. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  3796. /*
  3797. * 处理详情数据
  3798. */
  3799. foreach (var entity in entityList)
  3800. {
  3801. var _detail = new Grp_CreditCardPaymentDetailView
  3802. {
  3803. Id = entity.Id,
  3804. PriceName = priceModule,
  3805. PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-"
  3806. };
  3807. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  3808. else _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  3809. //处理金额
  3810. if (entity.CTable == 1015)
  3811. {
  3812. var czInfo = _GroupExtraCosts.Find(x => entity.CId == x.Id);
  3813. if (czInfo != null)
  3814. {
  3815. entity.PayMoney = czInfo.Price * czInfo.PriceCount;
  3816. entity.RMBPrice = czInfo.Price * czInfo.PriceCount * entity.DayRate;
  3817. }
  3818. }
  3819. /*
  3820. * 应付款金额
  3821. */
  3822. var sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  3823. string PaymentCurrency_WaitPay = "Unknown";
  3824. string hotelCurrncyCode = "Unknown";
  3825. string hotelCurrncyName = "Unknown";
  3826. if (sdPaymentCurrency_WaitPay != null)
  3827. {
  3828. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  3829. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  3830. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  3831. if (hotelCurrncyCode.Equals("CNY"))
  3832. {
  3833. entity.DayRate = 1.0000M;
  3834. }
  3835. }
  3836. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  3837. /*
  3838. * 此次付款金额
  3839. */
  3840. decimal CurrPayStr = 0.00M,
  3841. OriginalCurrPay = 0.00M;
  3842. if (entity.PayPercentage == 0)
  3843. {
  3844. if (entity.PayThenMoney != 0)
  3845. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  3846. }
  3847. else
  3848. {
  3849. if (entity.PayMoney != 0)
  3850. {
  3851. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  3852. }
  3853. }
  3854. //if (_dto.Label == 79)
  3855. //{
  3856. // string original = string.Empty;
  3857. // if (hotelCurrncyCode.Equals("CNY"))
  3858. // {
  3859. // OriginalCurrPay = CurrPayStr;
  3860. // _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  3861. // }
  3862. // else
  3863. // {
  3864. // OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  3865. // //760 EUR(7600.00 CNY)
  3866. // _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  3867. // }
  3868. //}
  3869. //else _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  3870. string original = string.Empty;
  3871. if (hotelCurrncyCode.Equals("CNY"))
  3872. {
  3873. OriginalCurrPay = CurrPayStr;
  3874. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  3875. }
  3876. else
  3877. {
  3878. OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  3879. //760 EUR(7600.00 CNY)
  3880. _detail.CurrPay = $"{OriginalCurrPay:#0.00} {hotelCurrncyCode}({CurrPayStr:#0.00} CNY)";
  3881. }
  3882. /*
  3883. * 剩余尾款
  3884. */
  3885. decimal BalanceStr = 0;
  3886. if (CurrPayStr != 0)
  3887. {
  3888. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  3889. BalanceStr = 0;
  3890. else
  3891. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  3892. }
  3893. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  3894. /*
  3895. * Bus名称
  3896. */
  3897. _detail.BusName = "待增加";
  3898. /*
  3899. *费用所属
  3900. */
  3901. switch (entity.CTable)
  3902. {
  3903. case 76://酒店预订
  3904. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  3905. if (hotelReservations != null)
  3906. {
  3907. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  3908. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  3909. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  3910. string roomFeeStr = "", roomFeestr1 = "";
  3911. //是否比较房型价格
  3912. //bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  3913. //roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  3914. roomFeeStr += $"<br/>";
  3915. var roomTotal = 0.00M;
  3916. if (hotelReservations.SingleRoomPrice > 0)
  3917. {
  3918. var fee = hotelReservations.SingleRoomPrice * hotelReservations.SingleRoomCount * hotel_days;
  3919. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice:#0.00} * {hotelReservations.SingleRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  3920. //__isSingle = true;
  3921. roomTotal += fee;
  3922. }
  3923. if (hotelReservations.DoubleRoomPrice > 0)
  3924. {
  3925. var fee = hotelReservations.DoubleRoomPrice * hotelReservations.DoubleRoomCount * hotel_days;
  3926. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice:#0.00} * {hotelReservations.DoubleRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  3927. // __isDouble = true;
  3928. roomTotal += fee;
  3929. }
  3930. if (hotelReservations.SuiteRoomPrice > 0)
  3931. {
  3932. var fee = hotelReservations.SuiteRoomPrice * hotelReservations.SuiteRoomCount * hotel_days;
  3933. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice:#0.00} * {hotelReservations.SuiteRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  3934. //__isSuite = true;
  3935. roomTotal += fee;
  3936. }
  3937. if (hotelReservations.OtherRoomPrice > 0)
  3938. {
  3939. var fee = hotelReservations.OtherRoomPrice * hotelReservations.OtherRoomCount * hotel_days;
  3940. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice:#0.00} * {hotelReservations.OtherRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  3941. //__isOther = true;
  3942. roomTotal += fee;
  3943. }
  3944. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1 + $"<span style='width:70px;display: inline-block;'></span>房费总金额:{roomTotal:#0.00}";
  3945. else roomFeeStr += " 0.00 * 0";
  3946. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  3947. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  3948. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  3949. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  3950. /*
  3951. * 费用类型
  3952. * 1:房费
  3953. * 2:早餐
  3954. * 3:地税
  3955. * 4:城市税
  3956. * </summary>
  3957. */
  3958. //地税
  3959. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  3960. if (governmentRentData != null)
  3961. {
  3962. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  3963. governmentRentFee = governmentRentData.Price;
  3964. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  3965. if (governmentRentCurrData != null)
  3966. {
  3967. governmentRentCode = governmentRentCurrData.Name;
  3968. governmentRentName = $"({governmentRentCurrData.Remark})";
  3969. }
  3970. }
  3971. //城市税
  3972. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  3973. if (cityTaxData != null)
  3974. {
  3975. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  3976. cityTaxFee = cityTaxData.Price;
  3977. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  3978. if (cityTaxCurrData != null)
  3979. {
  3980. cityTaxCode = cityTaxCurrData.Name;
  3981. cityTaxName = $"({cityTaxCurrData.Remark})";
  3982. }
  3983. }
  3984. //酒店早餐
  3985. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  3986. if (breakfastData != null)
  3987. {
  3988. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  3989. breakfastFee = breakfastData.Price;
  3990. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  3991. if (breakfastCurrData != null)
  3992. {
  3993. breakfastCode = breakfastCurrData.Name;
  3994. breakfastName = $"({breakfastCurrData.Remark})";
  3995. }
  3996. }
  3997. //房间费用
  3998. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  3999. if (roomData != null)
  4000. {
  4001. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  4002. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  4003. else _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  4004. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  4005. roomFee = roomData.Price;
  4006. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  4007. if (roomCurrData != null)
  4008. {
  4009. roomCode = roomCurrData.Name;
  4010. roomName = $"({roomCurrData.Remark})";
  4011. }
  4012. }
  4013. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  4014. string hotelCostStr = "";
  4015. decimal hotelCsotTotal = 0.00M;
  4016. if (groupCost != null)
  4017. {
  4018. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  4019. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate:#0.0000})<br/>";
  4020. }
  4021. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  4022. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  4023. string hotelCost_day = "";
  4024. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  4025. foreach (var item in hotelCostDetails1)
  4026. {
  4027. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  4028. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  4029. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee):#0.00}";
  4030. //else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  4031. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee):#0.00}";
  4032. //else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  4033. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee):#0.00}";
  4034. //else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  4035. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee):#0.00}";
  4036. //else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  4037. hotelCost_day += @$"<br/>";
  4038. }
  4039. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  4040. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee:#0.00} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate:#0.0000} <br/>是否由地接或其他人代付:{breakfastBool}<br/><br/>";
  4041. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee:#0.00} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate:#0.0000} <br/>是否由地接或其他人代付:{governmentRentBool}<br/><br/>";
  4042. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee:#0.00} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate:#0.0000)} <br/>是否由地接或其他人代付:{cityTaxBool}<br/>";
  4043. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  4044. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  4045. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  4046. $"酒店费用总额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  4047. $"房间说明: {hotelReservations.Remark} <br/>" +
  4048. $"房间费用: {roomCode} {roomName} 当时汇率:{roomData?.Rate.ToString("#0.0000")}{roomFeeStr} <br/>是否由地接或其他人代付:{roomBool}<br/><br/>" +
  4049. $"{hotelBreakfastStr}" +
  4050. $"{hotelGovernmentRentStr}" +
  4051. $"{hotelCityTaxStr}";
  4052. _detail.PriceNameContent = hotelReservations.HotelName;
  4053. }
  4054. break;
  4055. case 79://车/导游地接
  4056. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  4057. if (touristGuideGroundReservations != null)
  4058. {
  4059. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  4060. {
  4061. _detail.BusName = touristGuideGroundReservations.BusName;
  4062. }
  4063. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  4064. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  4065. //if (isInt)
  4066. //{
  4067. // var cityInfo = cityData.Find(it => it.Id == cityId);
  4068. // if (cityInfo != null)
  4069. // {
  4070. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  4071. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  4072. // if (carFeeItem != null)
  4073. // {
  4074. // nameContent += $@"({carFeeItem.Name})";
  4075. // }
  4076. // _detail.PriceNameContent = nameContent;
  4077. // }
  4078. //}
  4079. //else
  4080. //{
  4081. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  4082. //}
  4083. var touristGuideGroundReservationsContents =
  4084. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  4085. var opContent_sb = new StringBuilder();
  4086. string contetTitle = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  4087. opContent_sb.AppendLine(contetTitle);
  4088. foreach (var item in touristGuideGroundReservationsContents)
  4089. {
  4090. string typeName = "Unknown";
  4091. string carCurrencyCode = "Unknown";
  4092. string carCurrencyName = "Unknown";
  4093. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  4094. if (carTypeData != null) typeName = carTypeData.Name;
  4095. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  4096. if (currencyData != null)
  4097. {
  4098. carCurrencyCode = currencyData.Name;
  4099. carCurrencyName = currencyData.Remark;
  4100. }
  4101. //op、成本 币种是否一致 (币种一致只比较金额:2025-04-18)
  4102. bool IsCurrencyAgreement = false;
  4103. if (carCurrencyCode.Equals(_groupCurrencyCode)) IsCurrencyAgreement = true;
  4104. string opCostStr = string.Empty;
  4105. decimal opCostTypePrice = 0.00M;
  4106. #region 处理成本各项费用
  4107. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  4108. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  4109. decimal aduitOPFeeCNY = 0.00M, //费用审核 op费用
  4110. costOPFeeCNY = 0.00M, //团组成本 op费用
  4111. opPayPercentage = entity.PayPercentage == 0.00M ? 1.00M : entity.PayPercentage / 100M; //费用审核 op付款百分比
  4112. if (opCost.Count > 0)
  4113. {
  4114. switch (item.SId)
  4115. {
  4116. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  4117. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  4118. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  4119. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  4120. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  4121. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  4122. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  4123. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  4124. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  4125. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  4126. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  4127. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  4128. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  4129. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  4130. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  4131. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  4132. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  4133. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  4134. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  4135. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  4136. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  4137. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  4138. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  4139. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  4140. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  4141. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  4142. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  4143. }
  4144. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice:#0.00} {_groupCurrencyCode}(汇率:{_groupRate:#0.0000})";
  4145. costOPFeeCNY = opCostTypePrice * _groupRate;
  4146. if (!IsCurrencyAgreement) opCostStr += $" ≈ {costOPFeeCNY:#0.00} CNY";
  4147. }
  4148. #endregion
  4149. string opTypeStr = $"{typeName}:{item.Price:#0.00} {carCurrencyCode}(汇率:{entity.DayRate:#0.0000})";
  4150. aduitOPFeeCNY = item.Price * entity.DayRate;
  4151. if (!IsCurrencyAgreement) opTypeStr += $" ≈ {aduitOPFeeCNY:#0.0000} CNY";
  4152. var opContent = $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  4153. $"{opTypeStr} {opCostStr}<br/>" +
  4154. $"明细:{item.PriceContent ?? "-"}<br/>" +
  4155. $"备注:{item.Remark ?? "-"}<br/><br/>";
  4156. if (entity.IsAuditGM != 3) //状态 != 自动审核
  4157. {
  4158. if (IsCurrencyAgreement)
  4159. {
  4160. if (item.Price > opCostTypePrice)
  4161. {
  4162. opContent_sb.Append("<span style='color:red;'>");
  4163. opContent_sb.Append(opContent);
  4164. opContent_sb.Append("</span>");
  4165. opContent_sb.AppendLine();
  4166. }
  4167. else
  4168. {
  4169. opContent_sb.Append(opContent);
  4170. opContent_sb.AppendLine();
  4171. }
  4172. }
  4173. else
  4174. {
  4175. //验证是否超成本 按付款比例计算
  4176. if (aduitOPFeeCNY * opPayPercentage > costOPFeeCNY * opPayPercentage)
  4177. {
  4178. opContent_sb.Append("<span style='color:red;'>");
  4179. opContent_sb.Append(opContent);
  4180. opContent_sb.Append("</span>");
  4181. opContent_sb.AppendLine();
  4182. }
  4183. else
  4184. {
  4185. opContent_sb.Append(opContent);
  4186. opContent_sb.AppendLine();
  4187. }
  4188. }
  4189. }
  4190. else
  4191. {
  4192. opContent_sb.Append(opContent);
  4193. opContent_sb.AppendLine();
  4194. }
  4195. }
  4196. _detail.PriceMsgContent = opContent_sb.ToString();
  4197. }
  4198. break;
  4199. case 80: //签证
  4200. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  4201. if (visaInfo != null)
  4202. {
  4203. string visaName = GetClientNameStr1(clientNameList, visaInfo.VisaClient);
  4204. _detail.PriceNameContent = visaInfo.VisaDescription;
  4205. _detail.PriceMsgContent = $"签证描述:{visaName}<br/> 备注:{visaInfo.Remark}";
  4206. }
  4207. break;
  4208. case 81: //邀请/公务活动
  4209. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  4210. if (_ioa != null)
  4211. {
  4212. string inviteCurrName = "Unknown", //邀请费用币种 Name
  4213. inviteCurrCode = "Unknown", //邀请费用币种 Code
  4214. sendCurrName = "Unknown", //快递费用币种 Name
  4215. sendCurrCode = "Unknown", //快递费用币种 Code
  4216. eventsCurrName = "Unknown", //公务活动费币种 Name
  4217. eventsCurrCode = "Unknown", //公务活动费币种 Code
  4218. translateCurrName = "Unknown", //公务翻译费 Name
  4219. translateCurrCode = "Unknown"; //公务翻译费 Code
  4220. #region 处理费用币种
  4221. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  4222. if (inviteCurrData != null)
  4223. {
  4224. inviteCurrName = inviteCurrData.Remark;
  4225. inviteCurrCode = inviteCurrData.Name;
  4226. }
  4227. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  4228. if (sendCurrData != null)
  4229. {
  4230. sendCurrName = sendCurrData.Remark;
  4231. sendCurrCode = sendCurrData.Name;
  4232. }
  4233. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  4234. if (eventsCurrData != null)
  4235. {
  4236. eventsCurrName = eventsCurrData.Remark;
  4237. eventsCurrCode = eventsCurrData.Name;
  4238. }
  4239. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  4240. if (translateCurrData != null)
  4241. {
  4242. translateCurrName = translateCurrData.Remark;
  4243. translateCurrCode = translateCurrData.Name;
  4244. }
  4245. #endregion
  4246. _detail.PriceNameContent = _ioa.InviterArea;
  4247. //2025-09-08 商邀费用名称更改:单项费用不等于0,则在名称后面最加费用类型名称。
  4248. List<string> priceExpNames = new List<string>();
  4249. if (_ioa.InviteCost != 0.00M) priceExpNames.Add("邀请费");
  4250. if (_ioa.SendCost != 0.00M) priceExpNames.Add("快递费");
  4251. if (_ioa.EventsCost != 0.00M) priceExpNames.Add("公务活动费");
  4252. if (_ioa.TranslateCost != 0.00M) priceExpNames.Add("公务翻译费");
  4253. if (priceExpNames != null && priceExpNames.Count > 0)
  4254. {
  4255. _detail.PriceNameContent += $"({string.Join("+", priceExpNames)})";
  4256. }
  4257. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost:#0.00} {inviteCurrCode}({inviteCurrName})<br/>" +
  4258. $@"快递费用:{_ioa.SendCost:#0.00} {sendCurrCode}({sendCurrName})<br/>" +
  4259. $@"公务活动费:{_ioa.EventsCost:#0.00} {eventsCurrCode}({eventsCurrName})<br/>" +
  4260. $@"公务翻译费:{_ioa.TranslateCost:#0.00} {translateCurrCode}({translateCurrName})<br/>" +
  4261. $@"备注:" + _ioa.Remark + "<br/>";
  4262. }
  4263. break;
  4264. case 82: //团组客户保险
  4265. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  4266. if (customers != null)
  4267. {
  4268. _detail.PriceNameContent = GetClientNameStr(clientNameList, customers.ClientName);
  4269. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  4270. }
  4271. break;
  4272. case 85: //机票预订
  4273. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  4274. if (jpRes != null)
  4275. {
  4276. string FlightsDescription = jpRes.FlightsDescription;
  4277. string PriceDescription = jpRes.PriceDescription;
  4278. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  4279. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  4280. }
  4281. break;
  4282. case 98://其他款项
  4283. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  4284. if (gdpRes != null)
  4285. {
  4286. //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/";
  4287. //if (!string.IsNullOrEmpty(gdpRes.FilePath))
  4288. //{
  4289. // _detail.FileUrl = $"{urlBase}{gdpRes.FilePath}";
  4290. //}
  4291. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  4292. _detail.PriceNameContent = gdpRes.PriceName;
  4293. }
  4294. break;
  4295. case 285://收款退还
  4296. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  4297. if (refundAndOtherMoney != null)
  4298. {
  4299. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  4300. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  4301. }
  4302. break;
  4303. case 751://酒店早餐
  4304. break;
  4305. case 1015://超支费用
  4306. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  4307. if (groupExtraCost != null)
  4308. {
  4309. _detail.PriceNameContent = groupExtraCost.PriceName;
  4310. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  4311. }
  4312. break;
  4313. default:
  4314. break;
  4315. }
  4316. /*
  4317. * 申请人
  4318. */
  4319. string operatorName = " - ";
  4320. var _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  4321. if (_opUser != null)
  4322. {
  4323. operatorName = _opUser.CnName;
  4324. }
  4325. _detail.OperatorName = operatorName;
  4326. /*
  4327. * 审核人
  4328. */
  4329. string auditOperatorName = " - ";
  4330. if (entity.IsAuditGM != 0)
  4331. {
  4332. if (entity.AuditGMOperate == 0) auditOperatorName = " - ";
  4333. else if (entity.AuditGMOperate == 4) auditOperatorName = "自动审核";
  4334. else
  4335. {
  4336. var _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  4337. if (_adUser != null)
  4338. {
  4339. auditOperatorName = _adUser.CnName;
  4340. }
  4341. }
  4342. }
  4343. _detail.AuditOperatorName = auditOperatorName;
  4344. /*
  4345. * 超预算比例
  4346. */
  4347. string overBudgetStr = "";
  4348. if (entity.ExceedBudget == -1) overBudgetStr = sdPriceName.Name + "尚无预算";
  4349. else if (entity.ExceedBudget == 0)
  4350. {
  4351. if (entity.CTable == 76 || entity.CTable == 79)
  4352. {
  4353. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  4354. else overBudgetStr = _feeAuditRep.IsOverBudget(entity.CTable, entity.DIId, entity.CId);
  4355. }
  4356. else
  4357. {
  4358. overBudgetStr = "未超预算";
  4359. }
  4360. }
  4361. else overBudgetStr = entity.ExceedBudget.ToString("P");
  4362. _detail.OverBudget = overBudgetStr;
  4363. decimal auditFee = 0.00M; //已审核金额 人名币
  4364. decimal auditedFeeOriginal = 0.00M; ////已审核金额 原始
  4365. decimal unAuditFeeCNY = 0.00M; //未审核款项 原始
  4366. decimal unAuditFeeOriginal = 0.00M; //未审核款项 人名币
  4367. if (entity.IsAuditGM == 1 || entity.IsAuditGM == 3)
  4368. {
  4369. auditedFeeOriginal = entity.PayMoney;
  4370. auditFee = CurrPayStr;
  4371. }
  4372. else if (entity.IsAuditGM == 0)
  4373. {
  4374. unAuditFeeCNY = CurrPayStr;
  4375. unAuditFeeOriginal = OriginalCurrPay;
  4376. OriginalCurrPay = 0.00M;
  4377. }
  4378. /*
  4379. * 费用总计
  4380. */
  4381. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  4382. {
  4383. CurrencyId = entity.PaymentCurrency,
  4384. CurrencyName = PaymentCurrency_WaitPay,
  4385. AmountPayable = entity.PayMoney,
  4386. ThisPayment = OriginalCurrPay,
  4387. BalancePayment = BalanceStr,
  4388. AuditedFunds = auditFee,
  4389. AuditedFundsOriginal = auditedFeeOriginal,
  4390. UnAuditFundsCNY = unAuditFeeCNY,
  4391. UnAuditFundsOriginal = unAuditFeeOriginal
  4392. });
  4393. _detail.IsAuditGM = entity.IsAuditGM;
  4394. detailList.Add(_detail);
  4395. }
  4396. #endregion
  4397. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  4398. /*
  4399. * 下方描述处理
  4400. */
  4401. var nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  4402. var ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  4403. if (ccpCurrencyPrice != null)
  4404. {
  4405. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  4406. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  4407. }
  4408. else
  4409. {
  4410. nonDuplicat = nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  4411. }
  4412. string amountPayableStr = string.Format(@"应付款总金额: ");
  4413. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  4414. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  4415. string auditedFundsStr = string.Format(@"已审费用总额: ");
  4416. string unAuditedFundsStr = string.Format(@"未审费用总额: ");
  4417. foreach (var item in nonDuplicat)
  4418. {
  4419. var currencyName = item.CurrencyName;
  4420. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  4421. if (strs.Count > 0)
  4422. {
  4423. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  4424. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  4425. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  4426. amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), currencyName);
  4427. //单独处理此次付款金额
  4428. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  4429. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), currencyName);
  4430. //单独处理已审核费用
  4431. //if (item.CurrencyId == 836) //人民币
  4432. //{
  4433. // decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  4434. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), currencyName);
  4435. //}
  4436. //else
  4437. //{
  4438. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.AmountPayable), currencyName);
  4439. //}
  4440. if (currencyName.Equals("CNY"))
  4441. {
  4442. //已审核费用
  4443. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  4444. //未审核费用
  4445. unAuditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.UnAuditFundsOriginal).ToString("#0.00"), currencyName);
  4446. }
  4447. else
  4448. {
  4449. //已审核费用
  4450. 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"));
  4451. //未审核费用
  4452. 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"));
  4453. }
  4454. }
  4455. }
  4456. _view.TotalStr1 = amountPayableStr[..^1];
  4457. _view.TotalStr2 = thisPaymentStr[..^1];
  4458. _view.TotalStr3 = balancePaymentStr[..^1];
  4459. _view.TotalStr4 = $"{auditedFundsStr[..^1]}<br/>{unAuditedFundsStr[..^1]}";
  4460. //_view.TotalStr5 = unAuditedFundsStr.Substring(0, unAuditedFundsStr.Length - 1);
  4461. var _view1 = new
  4462. {
  4463. PageFuncAuth = pageFunAuthView,
  4464. Data = _view
  4465. };
  4466. return Ok(JsonView(_view1));
  4467. }
  4468. catch (Exception ex)
  4469. {
  4470. return Ok(JsonView(false, ex.Message));
  4471. }
  4472. }
  4473. /// <summary>
  4474. /// 费用审核
  4475. /// 修改团组费用审核状态
  4476. /// </summary>
  4477. /// <param name="_dto">参数Json字符串</param>
  4478. /// <returns></returns>
  4479. [HttpPost]
  4480. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4481. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  4482. {
  4483. #region 参数验证
  4484. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  4485. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  4486. #endregion
  4487. #region 页面操作权限验证
  4488. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  4489. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  4490. #endregion
  4491. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  4492. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  4493. DateTime dtNow = DateTime.Now;
  4494. _groupRepository.BeginTran();
  4495. int rst = 0;
  4496. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  4497. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  4498. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  4499. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  4500. var msgDatas = new List<dynamic>();
  4501. var dic_ccp_user = new Dictionary<int, int>() { };
  4502. foreach (var item in idList)
  4503. {
  4504. int CreditId = int.Parse(item);
  4505. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  4506. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  4507. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  4508. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  4509. .Where(s => s.Id == CreditId)
  4510. .ExecuteCommandAsync();
  4511. if (result < 1)
  4512. {
  4513. rst = -1;
  4514. _groupRepository.RollbackTran();
  4515. return Ok(JsonView(false, "操作失败并回滚!"));
  4516. }
  4517. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  4518. if (creditData != null)
  4519. {
  4520. #region 应用通知配置
  4521. try
  4522. {
  4523. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  4524. }
  4525. catch (Exception ex)
  4526. {
  4527. }
  4528. #endregion
  4529. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  4530. string groupNameStr = string.Empty;
  4531. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  4532. if (groupData != null) groupNameStr = groupData.TeamName;
  4533. string creditTypeStr = string.Empty;
  4534. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  4535. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  4536. string creditCurrency = string.Empty;
  4537. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  4538. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  4539. if (creditCurrency.Equals("CNY"))
  4540. {
  4541. creditData.DayRate = 1.0000M;
  4542. }
  4543. if (creditData.PayPercentage == 0.00M)
  4544. {
  4545. creditData.PayPercentage = 100M;
  4546. }
  4547. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  4548. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  4549. string msgContent = "";
  4550. if (creditCurrency.Equals("CNY"))
  4551. {
  4552. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice:0.00} CNY) {auditStr}!";
  4553. }
  4554. else
  4555. {
  4556. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice:0.00} CNY({creditData.PayMoney:0.00} {creditCurrency})) {auditStr}!";
  4557. }
  4558. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  4559. }
  4560. }
  4561. if (rst == 0)
  4562. {
  4563. _groupRepository.CommitTran();
  4564. foreach (var item in msgDatas)
  4565. {
  4566. //发送消息
  4567. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  4568. }
  4569. #region 应用推送
  4570. try
  4571. {
  4572. foreach (var ccpId in dic_ccp_user.Keys)
  4573. {
  4574. var templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  4575. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  4576. }
  4577. }
  4578. catch (Exception)
  4579. {
  4580. }
  4581. #endregion
  4582. return Ok(JsonView(true, "操作成功!"));
  4583. }
  4584. return Ok(JsonView(false, "操作失败!"));
  4585. }
  4586. /// <summary>
  4587. /// 费用审核
  4588. /// 其他款项 文件下载
  4589. /// </summary>
  4590. /// <param name="id">其他款项 主键编号</param>
  4591. /// <returns></returns>
  4592. [HttpGet("{id}")]
  4593. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4594. public async Task<IActionResult> FeeAuditOtherFileDownlaod([Range(1, int.MaxValue, ErrorMessage = "请传入有效的ID")] int id)
  4595. {
  4596. //网站域名
  4597. 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/";
  4598. var otherInfo = await _decreasePaymentsRep._sqlSugar
  4599. .Queryable<Grp_DecreasePayments>()
  4600. .InnerJoin<Grp_CreditCardPayment>((x, y) => x.Id == y.CId && y.Id == id)
  4601. .Where(((x, y) => x.IsDel == 0 && y.IsDel == 0))
  4602. .Select((x, y) => new
  4603. {
  4604. x.Id,
  4605. x.FilePath
  4606. })
  4607. .FirstAsync();
  4608. if (otherInfo != null && !string.IsNullOrEmpty(otherInfo.FilePath.Trim()))
  4609. {
  4610. var url = $"{baseUrl}{otherInfo.FilePath}";
  4611. return Ok(JsonView(true, "操作成功!", url));
  4612. }
  4613. return Ok(JsonView(false, "暂无附件"));
  4614. }
  4615. #endregion
  4616. #region 机票费用录入
  4617. /// <summary>
  4618. /// 机票录入当前登录人可操作团组
  4619. /// </summary>
  4620. /// <param name="dto"></param>
  4621. /// <returns></returns>
  4622. [HttpPost]
  4623. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4624. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  4625. {
  4626. try
  4627. {
  4628. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  4629. if (groupData.Code != 0)
  4630. {
  4631. return Ok(JsonView(false, groupData.Msg));
  4632. }
  4633. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4634. }
  4635. catch (Exception ex)
  4636. {
  4637. return Ok(JsonView(false, ex.Message));
  4638. }
  4639. }
  4640. /// <summary>
  4641. /// 机票费用录入列表
  4642. /// </summary>
  4643. /// <param name="dto"></param>
  4644. /// <returns></returns>
  4645. [HttpPost]
  4646. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4647. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  4648. {
  4649. try
  4650. {
  4651. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  4652. if (groupData.Code != 0)
  4653. {
  4654. return Ok(JsonView(false, groupData.Msg));
  4655. }
  4656. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4657. }
  4658. catch (Exception ex)
  4659. {
  4660. return Ok(JsonView(false, ex.Message));
  4661. throw;
  4662. }
  4663. }
  4664. /// <summary>
  4665. /// 根据id查询费用录入信息
  4666. /// </summary>
  4667. /// <param name="dto"></param>
  4668. /// <returns></returns>
  4669. [HttpPost]
  4670. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4671. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  4672. {
  4673. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  4674. if (groupData.Code != 0)
  4675. {
  4676. return Ok(JsonView(false, groupData.Msg));
  4677. }
  4678. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4679. }
  4680. /// <summary>
  4681. /// 机票费用录入操作(Status:1.新增,2.修改)
  4682. /// </summary>
  4683. /// <param name="dto"></param>
  4684. /// <returns></returns>
  4685. [HttpPost]
  4686. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4687. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  4688. {
  4689. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  4690. if (groupData.Code != 0)
  4691. {
  4692. return Ok(JsonView(false, groupData.Msg));
  4693. }
  4694. #region 应用推送
  4695. try
  4696. {
  4697. var diId = dto.AirTicketResOpData.DiId;
  4698. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  4699. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  4700. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  4701. //自动审核
  4702. //var autoAdit1 = await _feeAuditRep.FeeAutomaticAudit(5, diId, dataId); //机票费用合计方式
  4703. (bool status, string auditMsg) = await AirTicketResAutoAudit(diId, dataId); //KIMI-AI识别INIT方式
  4704. _logger.LogInformation("【机票费用自动审核(KIMI-AI识别INIT)】请求参数:{RequstData} 返回结果:是否执行:{IsExecute}; 结果消息:{ResponseMsg};",
  4705. $"GroupId:{diId};airId:{dataId};",
  4706. status,
  4707. auditMsg);
  4708. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  4709. //2024-10-21 新增LZ UID
  4710. var userIds = new List<int>() { 21 };
  4711. string title = $"系统通知";
  4712. string content = "";
  4713. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  4714. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  4715. if (dto.Status == 1) content = $"[新增-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4716. else if (dto.Status == 2) content = $"[更新-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4717. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  4718. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "85" };
  4719. await APNsTools.iOS_PushNotifications1("051", $"机票费用审核", "", content, true, "ExpenseAuditWebView", h5);
  4720. }
  4721. catch (Exception ex)
  4722. {
  4723. }
  4724. #endregion
  4725. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4726. }
  4727. /// <summary>
  4728. /// 机票费用自动审核 AI识别方式
  4729. /// </summary>
  4730. /// <returns></returns>
  4731. private async Task<(bool, string)> AirTicketResAutoAudit(int diId, int dataId)
  4732. {
  4733. var ecoTypeIds = new List<int>() {
  4734. 459, //超经舱
  4735. 460, //经济舱
  4736. 1430, //公务舱(实际经济舱)
  4737. 1432, //头等舱(实际经济舱)
  4738. };
  4739. var bizTypeIds = new List<int>() {
  4740. 457, //头等舱
  4741. 458, //公务舱
  4742. 1431, //头等舱(实际公务舱)
  4743. };
  4744. var auditFeeTypeIds = new List<int>() { };
  4745. auditFeeTypeIds.AddRange(ecoTypeIds);
  4746. auditFeeTypeIds.AddRange(bizTypeIds);
  4747. int currModule = 85;
  4748. var airInfo = await _sqlSugar.Queryable<Grp_AirTicketReservations>()
  4749. .InnerJoin<Grp_CreditCardPayment>((x, y) => x.Id == y.CId && y.CTable == currModule && y.IsDel == 0)
  4750. .Where((x, y) => x.Id == dataId && x.IsDel == 0 && auditFeeTypeIds.Contains(x.CType))
  4751. .Select((x, y) => new
  4752. {
  4753. x.Id,
  4754. CcpId = y.Id,
  4755. x.FlightsDate,
  4756. x.PrePrice,
  4757. x.CType,
  4758. x.ClientNum,
  4759. x.DIId
  4760. })
  4761. .FirstAsync();
  4762. if (airInfo == null) return (false, "机票信息为空或费用类型不在自动审核范围内,不可自动审核!");
  4763. var groupDetails = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.IsDel == 0 && x.Id == diId);
  4764. if (groupDetails == null) return (false, "团组信息为空,不可自动审核!");
  4765. var groupCostInfo = await _sqlSugar.Queryable<Grp_GroupCostParameter>().FirstAsync(x => x.IsDel == 0 && x.DiId == diId);
  4766. if (groupCostInfo == null) return (false, "团组成本信息未填写!");
  4767. var groupCostContents = await _sqlSugar
  4768. .SqlQueryable<GroupCostAuditView>($"Select * From Grp_GroupCost")
  4769. .Where(x => x.IsDel == 0 && x.Diid == diId)
  4770. .ToListAsync();
  4771. if (groupCostContents.Count < 1) return (false, "团组成本信息未填写!");
  4772. //处理 成本详细信息日期为空 填装费用信息
  4773. var airFeeLabel = new StringBuilder();
  4774. airFeeLabel.AppendLine("费用成本:");
  4775. for (int i = 0; i < groupCostContents.Count; i++)
  4776. {
  4777. if (string.IsNullOrEmpty(groupCostContents[i].Date))
  4778. {
  4779. int index = i - 1;
  4780. if (index >= 0)
  4781. {
  4782. groupCostContents[i].Date = groupCostContents[index].Date;
  4783. var dtBool = DateTime.TryParse(groupCostContents[i].Date, out DateTime _dateTime);
  4784. if (dtBool) groupCostContents[i].CurrTime = _dateTime;
  4785. }
  4786. }
  4787. else
  4788. {
  4789. var dtBool = DateTime.TryParse(groupCostContents[i].Date, out DateTime _dateTime);
  4790. if (dtBool) groupCostContents[i].CurrTime = _dateTime;
  4791. }
  4792. var item = groupCostContents[i];
  4793. airFeeLabel.AppendLine($"{item.Date}");
  4794. airFeeLabel.AppendLine($"{item.ITIN.Replace("\n", " ")}");
  4795. }
  4796. airFeeLabel.AppendLine($"注:费用:位置:航班号或者航班时间后面; 组成:经济舱/公务舱;");
  4797. airFeeLabel.AppendLine($"取出“{airInfo.FlightsDate}”费用金额,按照经济舱/公务舱格式返回,如果不存在的话则返回0.00/0.00,只返回金额格式文本;不需要其他文字描述;");
  4798. //访问Kimi AI 返回价格结果
  4799. var msgs = new List<SeedMessages>()
  4800. {
  4801. new ()
  4802. {
  4803. Role = KimiRole.user,
  4804. Content = airFeeLabel.ToString()
  4805. }
  4806. };
  4807. var client = new KiMiApiClient();
  4808. var kimiApiResult = await client.SeedMessage(msgs);
  4809. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  4810. string clients = kimiApiResult_JObject["content"].ToString();
  4811. decimal ecoPri_kimiAI = 0.00M,
  4812. bizPri_kimiAI = 0.00M;
  4813. //单个价格: 经济舱价格
  4814. if (decimal.TryParse(clients, out ecoPri_kimiAI)) { }
  4815. //价格文本包含/:/前经济舱价格 /后公务舱价格
  4816. if (clients.Contains('/'))
  4817. {
  4818. var priArray = clients.Split('/');
  4819. decimal.TryParse(priArray[0], out ecoPri_kimiAI); //
  4820. decimal.TryParse(priArray[1], out bizPri_kimiAI); //经济舱价格
  4821. }
  4822. else return (false, "价格文本不存在价格或KIMI-AI未识别出价格,不可自动审核!");
  4823. var isAutoAudit = false;
  4824. //价格验证处理
  4825. //经济舱
  4826. if (ecoTypeIds.Contains(airInfo.CType))
  4827. {
  4828. if (airInfo.PrePrice <= ecoPri_kimiAI) isAutoAudit = true;
  4829. }
  4830. //公务舱
  4831. else if (bizTypeIds.Contains(airInfo.CType))
  4832. {
  4833. if (airInfo.PrePrice <= bizPri_kimiAI) isAutoAudit = true;
  4834. }
  4835. else return (false, "该舱位类型不在自动审核范围内,不可自动审核!");
  4836. //是否执行自动审核
  4837. if (isAutoAudit)
  4838. {
  4839. var auditStatus = await _sqlSugar.Updateable<Grp_CreditCardPayment>()
  4840. .SetColumns(x => x.IsAuditGM == 3)
  4841. .SetColumns(x => x.AuditGMOperate == 4)
  4842. .SetColumns(x => x.AuditGMDate == DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
  4843. .Where(x => x.Id == airInfo.CcpId)
  4844. .ExecuteCommandAsync();
  4845. if (auditStatus > 0) return (true, "机票自动审核(KIMI-AI识别方式)执行成功!");
  4846. }
  4847. return (false, "当前费用超过成本费用,不可自动审核!");
  4848. }
  4849. /// <summary>
  4850. /// 机票费用录入
  4851. /// 自动审核测试 - AI 识别
  4852. /// </summary>
  4853. /// <param name="groupId"></param>
  4854. /// <param name="Id"></param>
  4855. /// <returns></returns>
  4856. [HttpPost]
  4857. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4858. public async Task<IActionResult> AirTicketResAutoAuditTest(int groupId, int Id)
  4859. {
  4860. (bool status, string msg) = await AirTicketResAutoAudit(groupId, Id);
  4861. return Ok(JsonView(status, msg));
  4862. }
  4863. /// <summary>
  4864. /// 根据舱位类型查询接团客户名单信息
  4865. /// </summary>
  4866. /// <param name="dto"></param>
  4867. /// <returns></returns>
  4868. [HttpPost]
  4869. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4870. public async Task<IActionResult> TankType(AirTicketResByIdDto dto)
  4871. {
  4872. try
  4873. {
  4874. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  4875. if (crm_Groups.Count != 0)
  4876. {
  4877. var Customer = new List<dynamic>();
  4878. foreach (var item in crm_Groups)
  4879. {
  4880. var data = new
  4881. {
  4882. item.Id,
  4883. item.Pinyin,
  4884. Name = item.LastName + item.FirstName
  4885. };
  4886. Customer.Add(data);
  4887. }
  4888. return Ok(JsonView(true, "查询成功!", Customer));
  4889. }
  4890. return Ok(JsonView(true, "暂无数据", crm_Groups));
  4891. }
  4892. catch (Exception ex)
  4893. {
  4894. return Ok(JsonView(false, "程序错误!"));
  4895. throw;
  4896. }
  4897. }
  4898. /// <summary>
  4899. /// 根据团号获取客户信息
  4900. /// </summary>
  4901. /// <param name="dto"></param>
  4902. /// <returns></returns>
  4903. [HttpPost]
  4904. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4905. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  4906. {
  4907. var jw = JsonView(false);
  4908. if (dto.DIID < 1)
  4909. {
  4910. jw.Msg += "请输入正确的diid";
  4911. return Ok(jw);
  4912. }
  4913. var arr = GetSimplClientList(dto.DIID);
  4914. jw = JsonView(true, "获取成功!", arr);
  4915. return Ok(jw);
  4916. }
  4917. private List<SimplClientInfo> GetSimplClientList(int diId)
  4918. {
  4919. 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);
  4920. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  4921. foreach (var item in arr)
  4922. {
  4923. EncryptionProcessor.DecryptProperties(item);
  4924. }
  4925. return arr;
  4926. }
  4927. private static string GetClientNameStr(List<SimplClientInfo> list, string origin)
  4928. {
  4929. string result = origin;
  4930. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  4931. {
  4932. string[] temparr = origin.Split(',');
  4933. string fistrStr = temparr[0];
  4934. int count = temparr.Length;
  4935. bool success = int.TryParse(fistrStr, out int tempId);
  4936. if (success)
  4937. {
  4938. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  4939. if (tempInfo != null)
  4940. {
  4941. if (count > 1)
  4942. {
  4943. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  4944. }
  4945. else
  4946. {
  4947. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  4948. }
  4949. }
  4950. }
  4951. }
  4952. return result;
  4953. }
  4954. private static string GetClientNameStr1(List<SimplClientInfo> list, string origin)
  4955. {
  4956. string result = origin;
  4957. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  4958. {
  4959. string[] temparr = origin.Split(',');
  4960. result = "";
  4961. foreach (var item in temparr)
  4962. {
  4963. bool success = int.TryParse(item, out int tempId);
  4964. if (success)
  4965. {
  4966. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  4967. if (tempInfo != null)
  4968. {
  4969. result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
  4970. }
  4971. }
  4972. }
  4973. }
  4974. if (result.Length > 0) result = result.Substring(0, result.Length - 1);
  4975. return result;
  4976. }
  4977. /// <summary>
  4978. /// 机票费用录入,删除
  4979. /// </summary>
  4980. /// <param name="dto"></param>
  4981. /// <returns></returns>
  4982. [HttpPost]
  4983. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4984. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  4985. {
  4986. try
  4987. {
  4988. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  4989. if (res)
  4990. {
  4991. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  4992. {
  4993. IsDel = 1,
  4994. DeleteUserId = dto.DeleteUserId,
  4995. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4996. }).ExecuteCommandAsync();
  4997. return Ok(JsonView(true, "删除成功!"));
  4998. }
  4999. return Ok(JsonView(false, "删除失败!"));
  5000. }
  5001. catch (Exception ex)
  5002. {
  5003. return Ok(JsonView(false, "程序错误!"));
  5004. throw;
  5005. }
  5006. }
  5007. /// <summary>
  5008. /// 导出机票录入报表
  5009. /// </summary>
  5010. /// <param name="dto"></param>
  5011. /// <returns></returns>
  5012. [HttpPost]
  5013. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5014. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  5015. {
  5016. try
  5017. {
  5018. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  5019. if (groupData.Code != 0)
  5020. {
  5021. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  5022. }
  5023. else
  5024. {
  5025. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  5026. if (AirTicketReservations.Count != 0)
  5027. {
  5028. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  5029. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  5030. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  5031. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  5032. var designer = new WorkbookDesigner
  5033. {
  5034. Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx")
  5035. };
  5036. decimal countCost = 0;
  5037. foreach (var item in AirTicketReservations)
  5038. {
  5039. #region 处理客人姓名
  5040. string clientNames = _tourClientListRep.ResolveCustomerName(item.ClientName);
  5041. item.ClientName = clientNames;
  5042. #endregion
  5043. if (item.BankType == "其他")
  5044. {
  5045. item.BankNo = "--";
  5046. }
  5047. else
  5048. {
  5049. if (!string.IsNullOrEmpty(item.BankType))
  5050. {
  5051. item.BankNo = $"{item.BankType}:{item.BankNo?[..3]}";
  5052. }
  5053. }
  5054. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  5055. item.Price = System.Decimal.Round(item.Price, 2);
  5056. countCost += Convert.ToDecimal(item.Price);
  5057. }
  5058. designer.SetDataSource("Export", AirTicketReservations);
  5059. designer.SetDataSource("ExportDiCode", diCode);
  5060. designer.SetDataSource("ExportDiName", diName);
  5061. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  5062. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  5063. designer.Process();
  5064. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  5065. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  5066. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  5067. return Ok(JsonView(true, "成功", url = rst));
  5068. }
  5069. else
  5070. {
  5071. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  5072. }
  5073. }
  5074. }
  5075. catch (Exception ex)
  5076. {
  5077. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  5078. throw;
  5079. }
  5080. }
  5081. private Dictionary<string, string> transDic = new Dictionary<string, string>();
  5082. /// <summary>
  5083. /// 行程单导出
  5084. /// </summary>
  5085. /// <param name="dto"></param>
  5086. /// <returns></returns>
  5087. [HttpPost]
  5088. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5089. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  5090. {
  5091. try
  5092. {
  5093. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  5094. if (groupData.Code != 0)
  5095. {
  5096. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  5097. }
  5098. else
  5099. {
  5100. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  5101. if (dto.Language == "CN")
  5102. {
  5103. var doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  5104. var builder = new DocumentBuilder(doc);
  5105. int tableIndex = 0;//表格索引
  5106. //得到文档中的第一个表格
  5107. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  5108. foreach (var item in _AirTicketReservations)
  5109. {
  5110. #region 处理固定数据
  5111. string[] FlightsCode = item.FlightsCode.Split('/');
  5112. if (FlightsCode.Length != 0)
  5113. {
  5114. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  5115. if (_AirCompany != null)
  5116. {
  5117. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  5118. }
  5119. else
  5120. {
  5121. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  5122. }
  5123. }
  5124. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  5125. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  5126. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  5127. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  5128. string name = "";
  5129. foreach (string clientName in nameArray)
  5130. {
  5131. if (!name.Contains(clientName))
  5132. {
  5133. name += clientName + ",";
  5134. }
  5135. }
  5136. if (!string.IsNullOrWhiteSpace(name))
  5137. {
  5138. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  5139. }
  5140. else
  5141. {
  5142. table.Range.Bookmarks["ClientName"].Text = "--";
  5143. }
  5144. table.Range.Bookmarks["TicketNumber"].Text = "--";
  5145. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  5146. table.Range.Bookmarks["JointTicket"].Text = "--";
  5147. table.Range.Bookmarks["TimeIssue"].Text = "--";
  5148. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  5149. table.Range.Bookmarks["NavigationCode"].Text = "--";
  5150. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  5151. table.Range.Bookmarks["AgentPhone"].Text = "--";
  5152. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  5153. #endregion
  5154. #region 循环数据处理
  5155. var airs = new List<AirInfo>();
  5156. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  5157. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  5158. for (int i = 0; i < FlightsCode.Length; i++)
  5159. {
  5160. var air = new AirInfo();
  5161. string[] tempstr = DayArray[i]
  5162. .Replace("\r\n", string.Empty)
  5163. .Replace("\\r\\n", string.Empty)
  5164. .TrimStart().TrimEnd()
  5165. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  5166. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  5167. string starCity = "";
  5168. if (star_Three != null)
  5169. {
  5170. starCity = star_Three.AirPort;
  5171. }
  5172. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  5173. string EndCity = "";
  5174. if (End_Three != null)
  5175. {
  5176. EndCity = End_Three.AirPort;
  5177. }
  5178. air.Destination = starCity + "/" + EndCity;
  5179. air.Flight = FlightsCode[i];
  5180. air.SeatingClass = item.CTypeName;
  5181. string dateTime = tempstr[2];
  5182. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  5183. air.FlightDate = DateTemp;
  5184. air.DepartureTime = tempstr[5];
  5185. air.LandingTime = tempstr[6];
  5186. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  5187. air.TicketStatus = "--";
  5188. air.Luggage = "--";
  5189. air.DepartureTerminal = "--";
  5190. air.LandingTerminal = "--";
  5191. airs.Add(air);
  5192. }
  5193. int row = 13;
  5194. for (int i = 0; i < airs.Count; i++)
  5195. {
  5196. if (airs.Count > 2)
  5197. {
  5198. for (int j = 0; j < airs.Count - 2; j++)
  5199. {
  5200. var CopyRow = table.Rows[12].Clone(true);
  5201. table.Rows.Add(CopyRow);
  5202. }
  5203. }
  5204. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  5205. int index = 0;
  5206. foreach (PropertyInfo property in properties)
  5207. {
  5208. string value = property.GetValue(airs[i]).ToString();
  5209. Cell ishcel0 = table.Rows[row].Cells[index];
  5210. var p = new Paragraph(doc);
  5211. string s = value;
  5212. p.AppendChild(new Run(doc, s));
  5213. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  5214. ishcel0.AppendChild(p);
  5215. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  5216. index++;
  5217. }
  5218. row++;
  5219. }
  5220. #endregion
  5221. var lastParagraph = new Paragraph(doc);
  5222. //第一个表格末尾加段落
  5223. table.ParentNode.InsertAfter(lastParagraph, table);
  5224. //复制第一个表格
  5225. Table cloneTable = (Table)table.Clone(true);
  5226. //在文档末尾段落后面加入复制的表格
  5227. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  5228. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  5229. {
  5230. int rownewsIndex = 13;
  5231. for (int i = 0; i < 2; i++)
  5232. {
  5233. var CopyRow = table.Rows[12].Clone(true);
  5234. table.Rows.RemoveAt(13);
  5235. table.Rows.Add(CopyRow);
  5236. rownewsIndex++;
  5237. }
  5238. }
  5239. else
  5240. {
  5241. table.Rows.RemoveAt(12);
  5242. }
  5243. cloneTable.Rows.RemoveAt(12);
  5244. }
  5245. if (_AirTicketReservations.Count != 0)
  5246. {
  5247. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  5248. if (FlightsCode.Length != 0)
  5249. {
  5250. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  5251. if (_AirCompany != null)
  5252. {
  5253. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  5254. }
  5255. else
  5256. {
  5257. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  5258. }
  5259. }
  5260. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  5261. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  5262. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  5263. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  5264. string name = "";
  5265. foreach (string clientName in nameArray)
  5266. {
  5267. if (!name.Contains(clientName))
  5268. {
  5269. name += clientName + ",";
  5270. }
  5271. }
  5272. if (!string.IsNullOrWhiteSpace(name))
  5273. {
  5274. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  5275. }
  5276. else
  5277. {
  5278. table.Range.Bookmarks["ClientName"].Text = "--";
  5279. }
  5280. table.Range.Bookmarks["TicketNumber"].Text = "--";
  5281. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  5282. table.Range.Bookmarks["JointTicket"].Text = "--";
  5283. table.Range.Bookmarks["TimeIssue"].Text = "--";
  5284. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  5285. table.Range.Bookmarks["NavigationCode"].Text = "--";
  5286. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  5287. table.Range.Bookmarks["AgentPhone"].Text = "--";
  5288. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  5289. }
  5290. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  5291. //保存合并后的文档
  5292. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  5293. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  5294. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  5295. return Ok(JsonView(true, "成功!", rst));
  5296. }
  5297. else
  5298. {
  5299. var doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  5300. var builder = new DocumentBuilder(doc);
  5301. int tableIndex = 0;//表格索引
  5302. //得到文档中的第一个表格
  5303. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  5304. var texts = new List<string>();
  5305. foreach (var item in _AirTicketReservations)
  5306. {
  5307. string[] FlightsCode = item.FlightsCode.Split('/');
  5308. if (FlightsCode.Length != 0)
  5309. {
  5310. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  5311. if (_AirCompany != null)
  5312. {
  5313. if (!transDic.ContainsKey(_AirCompany.CnName))
  5314. {
  5315. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  5316. }
  5317. }
  5318. else
  5319. {
  5320. if (!transDic.ContainsKey("--"))
  5321. {
  5322. transDic.Add("--", "--");
  5323. }
  5324. }
  5325. }
  5326. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  5327. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  5328. string name = "";
  5329. foreach (string clientName in nameArray)
  5330. {
  5331. name += clientName + ",";
  5332. }
  5333. if (!texts.Contains(name))
  5334. {
  5335. texts.Add(name);
  5336. }
  5337. var airs = new List<AirInfo>();
  5338. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  5339. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  5340. for (int i = 0; i < FlightsCode.Length; i++)
  5341. {
  5342. var air = new AirInfo();
  5343. string[] tempstr = DayArray[i]
  5344. .Replace("\r\n", string.Empty)
  5345. .Replace("\\r\\n", string.Empty)
  5346. .TrimStart().TrimEnd()
  5347. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  5348. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  5349. if (star_Three != null)
  5350. {
  5351. if (!transDic.ContainsKey(star_Three.AirPort))
  5352. {
  5353. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  5354. }
  5355. }
  5356. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  5357. if (End_Three != null)
  5358. {
  5359. if (!transDic.ContainsKey(End_Three.AirPort))
  5360. {
  5361. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  5362. }
  5363. }
  5364. if (!texts.Contains(item.CTypeName))
  5365. {
  5366. texts.Add(item.CTypeName);
  5367. }
  5368. }
  5369. }
  5370. List<TranslateResult> transData = await _airTicketResRep.ReTransBatch(texts, "en");
  5371. if (transData.Count > 0)
  5372. {
  5373. foreach (TranslateResult item in transData)
  5374. {
  5375. if (!transDic.ContainsKey(item.Query))
  5376. {
  5377. transDic.Add(item.Query, item.Translation);
  5378. }
  5379. }
  5380. }
  5381. foreach (var item in _AirTicketReservations)
  5382. {
  5383. #region 处理固定数据
  5384. string[] FlightsCode = item.FlightsCode.Split('/');
  5385. if (FlightsCode.Length != 0)
  5386. {
  5387. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  5388. if (_AirCompany != null)
  5389. {
  5390. string str = "--";
  5391. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  5392. if (!string.IsNullOrEmpty(translateResult))
  5393. {
  5394. str = translateResult;
  5395. str = _airTicketResRep.Processing(str);
  5396. }
  5397. table.Range.Bookmarks["AirlineCompany"].Text = str;
  5398. }
  5399. else
  5400. {
  5401. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  5402. }
  5403. }
  5404. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  5405. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  5406. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  5407. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  5408. string names = "";
  5409. foreach (string clientName in nameArray)
  5410. {
  5411. names += clientName + ",";
  5412. }
  5413. if (!string.IsNullOrWhiteSpace(names))
  5414. {
  5415. string str = "--";
  5416. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  5417. if (!string.IsNullOrEmpty(translateResult))
  5418. {
  5419. str = translateResult;
  5420. str = _airTicketResRep.Processing(str);
  5421. }
  5422. table.Range.Bookmarks["ClientName"].Text = str;
  5423. }
  5424. else
  5425. {
  5426. table.Range.Bookmarks["ClientName"].Text = "--";
  5427. }
  5428. table.Range.Bookmarks["TicketNumber"].Text = "--";
  5429. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  5430. table.Range.Bookmarks["JointTicket"].Text = "--";
  5431. table.Range.Bookmarks["TimeIssue"].Text = "--";
  5432. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  5433. table.Range.Bookmarks["NavigationCode"].Text = "--";
  5434. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  5435. table.Range.Bookmarks["AgentPhone"].Text = "--";
  5436. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  5437. #endregion
  5438. #region 循环数据处理
  5439. var airs = new List<AirInfo>();
  5440. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  5441. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  5442. for (int i = 0; i < FlightsCode.Length; i++)
  5443. {
  5444. var air = new AirInfo();
  5445. string[] tempstr = DayArray[i]
  5446. .Replace("\r\n", string.Empty)
  5447. .Replace("\\r\\n", string.Empty)
  5448. .TrimStart().TrimEnd()
  5449. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  5450. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  5451. string starCity = "";
  5452. if (star_Three != null)
  5453. {
  5454. string str2 = "--";
  5455. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  5456. if (!string.IsNullOrEmpty(translateResult2))
  5457. {
  5458. str2 = translateResult2;
  5459. str2 = _airTicketResRep.Processing(str2);
  5460. }
  5461. starCity = str2;
  5462. }
  5463. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  5464. string EndCity = "";
  5465. if (End_Three != null)
  5466. {
  5467. string str1 = "--";
  5468. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  5469. if (!string.IsNullOrEmpty(translateResult1))
  5470. {
  5471. str1 = translateResult1;
  5472. str1 = _airTicketResRep.Processing(str1);
  5473. }
  5474. EndCity = str1;
  5475. }
  5476. air.Destination = starCity + "/" + EndCity;
  5477. air.Flight = FlightsCode[i];
  5478. string str = "--";
  5479. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  5480. if (!string.IsNullOrEmpty(translateResult))
  5481. {
  5482. str = translateResult;
  5483. str = _airTicketResRep.Processing(str);
  5484. }
  5485. air.SeatingClass = str;
  5486. string dateTime = tempstr[2];
  5487. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  5488. air.FlightDate = DateTemp;
  5489. air.DepartureTime = tempstr[5];
  5490. air.LandingTime = tempstr[6];
  5491. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  5492. air.TicketStatus = "--";
  5493. air.Luggage = "--";
  5494. air.DepartureTerminal = "--";
  5495. air.LandingTerminal = "--";
  5496. airs.Add(air);
  5497. }
  5498. int row = 13;
  5499. for (int i = 0; i < airs.Count; i++)
  5500. {
  5501. if (airs.Count > 2)
  5502. {
  5503. for (int j = 0; j < airs.Count - 2; j++)
  5504. {
  5505. var CopyRow = table.Rows[12].Clone(true);
  5506. table.Rows.Add(CopyRow);
  5507. }
  5508. }
  5509. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  5510. int index = 0;
  5511. foreach (PropertyInfo property in properties)
  5512. {
  5513. string value = property.GetValue(airs[i]).ToString();
  5514. Cell ishcel0 = table.Rows[row].Cells[index];
  5515. var p = new Paragraph(doc);
  5516. string s = value;
  5517. p.AppendChild(new Run(doc, s));
  5518. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  5519. ishcel0.AppendChild(p);
  5520. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  5521. //ishcel0.CellFormat.VerticalAlignment=
  5522. index++;
  5523. }
  5524. row++;
  5525. }
  5526. #endregion
  5527. var lastParagraph = new Paragraph(doc);
  5528. //第一个表格末尾加段落
  5529. table.ParentNode.InsertAfter(lastParagraph, table);
  5530. //复制第一个表格
  5531. Table cloneTable = (Table)table.Clone(true);
  5532. //在文档末尾段落后面加入复制的表格
  5533. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  5534. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  5535. {
  5536. int rownewsIndex = 13;
  5537. for (int i = 0; i < 2; i++)
  5538. {
  5539. var CopyRow = table.Rows[12].Clone(true);
  5540. table.Rows.RemoveAt(13);
  5541. table.Rows.Add(CopyRow);
  5542. rownewsIndex++;
  5543. }
  5544. }
  5545. else
  5546. {
  5547. table.Rows.RemoveAt(12);
  5548. }
  5549. cloneTable.Rows.RemoveAt(12);
  5550. }
  5551. if (_AirTicketReservations.Count != 0)
  5552. {
  5553. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  5554. if (FlightsCode.Length != 0)
  5555. {
  5556. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  5557. if (_AirCompany != null)
  5558. {
  5559. string str = "--";
  5560. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  5561. if (!string.IsNullOrEmpty(translateResult))
  5562. {
  5563. str = translateResult;
  5564. str = _airTicketResRep.Processing(str);
  5565. }
  5566. table.Range.Bookmarks["AirlineCompany"].Text = str;
  5567. }
  5568. else
  5569. {
  5570. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  5571. }
  5572. }
  5573. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  5574. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  5575. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  5576. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  5577. string names = "";
  5578. foreach (string clientName in nameArray)
  5579. {
  5580. names += clientName + ",";
  5581. }
  5582. if (!string.IsNullOrWhiteSpace(names))
  5583. {
  5584. string str = "--";
  5585. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  5586. if (!string.IsNullOrEmpty(translateResult))
  5587. {
  5588. str = translateResult;
  5589. str = _airTicketResRep.Processing(str);
  5590. }
  5591. table.Range.Bookmarks["ClientName"].Text = str;
  5592. }
  5593. else
  5594. {
  5595. table.Range.Bookmarks["ClientName"].Text = "--";
  5596. }
  5597. table.Range.Bookmarks["TicketNumber"].Text = "--";
  5598. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  5599. table.Range.Bookmarks["JointTicket"].Text = "--";
  5600. table.Range.Bookmarks["TimeIssue"].Text = "--";
  5601. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  5602. table.Range.Bookmarks["NavigationCode"].Text = "--";
  5603. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  5604. table.Range.Bookmarks["AgentPhone"].Text = "--";
  5605. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  5606. }
  5607. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  5608. //保存合并后的文档
  5609. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  5610. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  5611. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  5612. return Ok(JsonView(true, "成功!", rst));
  5613. }
  5614. }
  5615. }
  5616. catch (Exception ex)
  5617. {
  5618. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  5619. throw;
  5620. }
  5621. }
  5622. #endregion
  5623. #region 团组增减款项 --> 其他款项
  5624. /// <summary>
  5625. /// 团组增减款项下拉框绑定
  5626. /// </summary>
  5627. /// <param name="dto"></param>
  5628. /// <returns></returns>
  5629. [HttpPost]
  5630. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5631. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  5632. {
  5633. #region 参数验证
  5634. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  5635. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  5636. #endregion
  5637. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  5638. }
  5639. /// <summary>
  5640. /// 根据团组Id查询团组增减款项
  5641. /// </summary>
  5642. /// <param name="dto"></param>
  5643. /// <returns></returns>
  5644. [HttpPost]
  5645. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5646. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  5647. {
  5648. #region 参数验证
  5649. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  5650. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  5651. #endregion
  5652. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  5653. }
  5654. /// <summary>
  5655. /// 团组增减款项操作(Status:1.新增,2.修改)
  5656. /// </summary>
  5657. /// <param name="dto"></param>
  5658. /// <returns></returns>
  5659. [HttpPost]
  5660. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5661. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  5662. {
  5663. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  5664. if (groupData.Code != 200)
  5665. {
  5666. return Ok(JsonView(false, groupData.Msg));
  5667. }
  5668. #region 应用推送
  5669. //int otherId = (int)groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  5670. //int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  5671. //int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  5672. int otherId = Convert.ToInt32(groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null) ?? 0);
  5673. int ccpId = Convert.ToInt32(groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null) ?? 0);
  5674. int sign = Convert.ToInt32(groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null) ?? 0);
  5675. bool recheck = Convert.ToBoolean(groupData.Data.GetType().GetProperty("recheck").GetValue(groupData.Data, null) ?? "True");
  5676. if (recheck)
  5677. {
  5678. //自动审核
  5679. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(3, dto.DiId, otherId);
  5680. }
  5681. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  5682. //2024-10-21 新增LZ UID
  5683. var userIds = new List<int>() { 21 };
  5684. string title = $"系统通知";
  5685. string content = "";
  5686. var diId = dto.DiId;
  5687. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  5688. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  5689. if (dto.Status == 1) content = $"[新增-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  5690. else if (dto.Status == 2) content = $"[更新-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  5691. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  5692. //await APNsTools.iOS_PushNotifications1("051", $"其他款项费用审核", "", content);
  5693. #endregion
  5694. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5695. }
  5696. /// <summary>
  5697. /// 团组增减款项操作 删除
  5698. /// </summary>
  5699. /// <param name="dto"></param>
  5700. /// <returns></returns>
  5701. [HttpPost]
  5702. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5703. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  5704. {
  5705. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  5706. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  5707. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  5708. if (res.Code == 0) return Ok(JsonView(true, "删除成功!"));
  5709. return Ok(JsonView(false, res?.Msg ?? "删除失败!"));
  5710. }
  5711. /// <summary>
  5712. /// 根据团组增减款项Id查询
  5713. /// </summary>
  5714. /// <param name="dto"></param>
  5715. /// <returns></returns>
  5716. [HttpPost]
  5717. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5718. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  5719. {
  5720. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  5721. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  5722. }
  5723. /// <summary>
  5724. /// 查询供应商名称
  5725. /// </summary>
  5726. /// <param name="dto"></param>
  5727. /// <returns></returns>
  5728. [HttpPost]
  5729. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  5730. {
  5731. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  5732. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  5733. ?? new List<Grp_DecreasePayments>();
  5734. dbResult = dbResult.Distinct(new
  5735. ProductComparer()).ToList();
  5736. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  5737. {
  5738. x.Id,
  5739. x.SupplierAddress,
  5740. x.SupplierArea,
  5741. x.SupplierContact,
  5742. x.SupplierContactNumber,
  5743. x.SupplierEmail,
  5744. x.SupplierName,
  5745. x.SupplierSocialAccount,
  5746. x.SupplierTypeId,
  5747. }).ToList());
  5748. return Ok(jw);
  5749. }
  5750. /// <summary>
  5751. /// 团组增减款项 OTA匹配
  5752. /// </summary>
  5753. /// <param name="file"></param>
  5754. /// <returns></returns>
  5755. [HttpPost]
  5756. public async Task<IActionResult> DecreasePaymentsOTAMate(IFormFile file)
  5757. {
  5758. if (file.Length < 1) return Ok(JsonView(false, "请上传文件!"));
  5759. string fileName = file.FileName;
  5760. if (!fileName.EndsWith(".xlsx") && !fileName.EndsWith(".xls"))
  5761. {
  5762. return Ok(JsonView(false, "请上传Excel文件!"));
  5763. }
  5764. //D:\FTP\File\OA2023\Office\GrpFile\团组增减款项相关文件\团组其他款项(OTA)
  5765. var path = @$"{AppSettingsHelper.Get("GrpFileBasePath")}团组增减款项相关文件/团组其他款项(OTA)";
  5766. if (!Directory.Exists(path))
  5767. {
  5768. Directory.CreateDirectory(path);
  5769. }
  5770. var filePath = @$"{path}/{fileName}";
  5771. //保存文件
  5772. using (FileStream fs = System.IO.File.Create(filePath))
  5773. {
  5774. file.CopyTo(fs);
  5775. fs.Flush();
  5776. }
  5777. if (!System.IO.File.Exists(filePath)) return Ok(JsonView(false, "文件不存在!"));
  5778. //读取ExcelFile
  5779. DataTable dt = ConvertExcelToDataTable(filePath);
  5780. if (dt == null) return Ok(JsonView(false, $"您上传的Excel工作表没有内容,请检查!!!"));
  5781. dt.TableName = "TB";
  5782. //修改table列名
  5783. dt.Columns[0].ColumnName = "OrderNo"; // 订单号
  5784. dt.Columns[1].ColumnName = "OTAOrderNo"; // OTA订单号
  5785. dt.Columns[2].ColumnName = "PackageName"; // 套餐名
  5786. dt.Columns[3].ColumnName = "IsPay"; // 是否支付
  5787. dt.Columns[4].ColumnName = "IsShipments"; // 是否发货
  5788. dt.Columns[5].ColumnName = "IsSendBack"; // 是否寄回
  5789. dt.Columns[6].ColumnName = "OpUser"; // 使用人信息
  5790. dt.Columns[7].ColumnName = "OrderTime"; // 下单时间
  5791. dt.Columns[8].ColumnName = "UseTime"; // 使用时间
  5792. dt.Columns[9].ColumnName = "Quantity"; // 台数
  5793. dt.Columns[10].ColumnName = "Days"; // 租赁天数
  5794. dt.Columns[11].ColumnName = "QuantityShipped";// 发货数量
  5795. dt.Columns[12].ColumnName = "TotalPrice"; // 总金额
  5796. dt.Columns[13].ColumnName = "GroupName"; // 团组名称
  5797. dt.Columns[14].ColumnName = "OATotalPrice"; // OA金额
  5798. var otaOrderNos = new List<string>();
  5799. foreach (DataRow item in dt.Rows)
  5800. {
  5801. otaOrderNos.Add(item["OTAOrderNo"].ToString());
  5802. }
  5803. var oaDatas = await _sqlSugar.Queryable<Grp_DecreasePayments>()
  5804. .LeftJoin<Grp_DelegationInfo>((dp, di) => dp.DiId == di.Id)
  5805. .Where((dp, di) => dp.IsDel == 0 && dp.PriceName.Contains("wifi") || otaOrderNos.Contains(dp.OTAOrderNo))
  5806. .Select((dp, di) => new
  5807. {
  5808. dp.PriceName,
  5809. dp.OTAOrderNo,
  5810. dp.FeeTotal,
  5811. di.TeamName,
  5812. })
  5813. .ToListAsync();
  5814. foreach (DataRow item in dt.Rows)
  5815. {
  5816. var otaOrderNo = item["OTAOrderNo"].ToString();
  5817. var oaData = oaDatas.Find(x => !string.IsNullOrEmpty(x.OTAOrderNo) && x.OTAOrderNo.Contains(otaOrderNo));
  5818. if (oaData == null) continue;
  5819. item["GroupName"] = oaData.TeamName;
  5820. item["OATotalPrice"] = oaData.FeeTotal.ToString("#0.00");
  5821. }
  5822. string fileName1 = $"OTA_WIFI费用{DateTime.Now:yyyyMMddHHmmss}.xls";
  5823. var pairs = new Dictionary<string, object>();
  5824. var datas = new List<DataTable>
  5825. {
  5826. dt
  5827. };
  5828. url = AsposeHelper.ExpertExcelToModel("WIFI费用清单-模板.xlsx", $"GrpFile/团组增减款项相关文件/团组其他款项(OTA)", fileName1, pairs, datas);
  5829. return Ok(JsonView(true, "操作成功", new { url }));
  5830. }
  5831. #region
  5832. private static DataTable ConvertExcelToDataTable(string excelFilePath)
  5833. {
  5834. // 创建Workbook对象
  5835. var workbook = new Workbook(excelFilePath);
  5836. // 获取第一个工作表
  5837. var worksheet = workbook.Worksheets[0];
  5838. // 将工作表转换为DataTable
  5839. DataTable dataTable = worksheet.Cells.ExportDataTable(1, 0, worksheet.Cells.MaxDataRow + 1, worksheet.Cells.MaxDataColumn + 1);
  5840. return dataTable;
  5841. }
  5842. #endregion
  5843. /// <summary>
  5844. /// 世运会数据
  5845. /// </summary>
  5846. /// <returns></returns>
  5847. [HttpGet]
  5848. public IActionResult WorldGamesData()
  5849. {
  5850. var setData = _sqlSugar.Queryable<Grp_GamesBudgetMaster>().Where(x => x.IsDel == 0).ToList();
  5851. var groupMenu = setData.GroupBy(x => x.T0);
  5852. var resultArr = new List<DecreasePaymentsWorldGamesDataView>();
  5853. foreach (var item in groupMenu)
  5854. {
  5855. resultArr.Add(new DecreasePaymentsWorldGamesDataView
  5856. {
  5857. Data = new SetDataView
  5858. {
  5859. Name = item.Key
  5860. },
  5861. Child = item.Select(x => x.CalculationContent).ToList() ?? new List<string>()
  5862. });
  5863. }
  5864. return Ok(JsonView(true, "success", resultArr));
  5865. }
  5866. #endregion
  5867. #region 文件上传、删除
  5868. /// <summary>
  5869. /// region 文件上传 可以带参数
  5870. /// </summary>
  5871. /// <param name="file"></param>
  5872. /// <returns></returns>
  5873. [HttpPost]
  5874. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5875. public async Task<IActionResult> UploadProject(IFormFile file)
  5876. {
  5877. //var TypeName = Request.Headers["TypeName"].ToString();
  5878. //if (file == null) return Ok(JsonView(false, "文件不存在!"));
  5879. //var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  5880. ////文件名称
  5881. //string projectFileName = file.FileName;
  5882. ////上传的文件的路径
  5883. //string filePath = $"{fileDir}/{projectFileName}";
  5884. //if (TypeName == "A")//A代表团组增减款项
  5885. //{
  5886. // filePath = fileDir + $@"\团组增减款项相关文件";
  5887. // if (!Directory.Exists(filePath))
  5888. // {
  5889. // Directory.CreateDirectory(filePath);
  5890. // }
  5891. // //上传的文件的路径
  5892. // filePath += $@"\{projectFileName}";
  5893. //}
  5894. //else if (TypeName == "B")//B代表商邀相关文件
  5895. //{
  5896. // //上传的文件的路径
  5897. // filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  5898. // if (!Directory.Exists(filePath))
  5899. // {
  5900. // Directory.CreateDirectory(filePath);
  5901. // }
  5902. // //上传的文件的路径
  5903. // filePath = $@"\{projectFileName}";
  5904. //}
  5905. //try
  5906. //{
  5907. // using (FileStream fs = System.IO.File.Create(filePath))
  5908. // {
  5909. // file.CopyTo(fs);
  5910. // fs.Flush();
  5911. // }
  5912. //}
  5913. //catch (Exception ex)
  5914. //{
  5915. // return Ok(JsonView(false, $"文件上传失败! Error:{ex.Message}"));
  5916. //}
  5917. //return Ok(JsonView(true, "上传成功!", projectFileName));
  5918. try
  5919. {
  5920. var TypeName = Request.Headers["TypeName"].ToString();
  5921. if (file != null)
  5922. {
  5923. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  5924. //文件名称
  5925. string projectFileName = file.FileName;
  5926. //上传的文件的路径
  5927. string filePath = $"{fileDir}/{projectFileName}";
  5928. if (TypeName == "A")//A代表团组增减款项
  5929. {
  5930. if (!Directory.Exists(fileDir))
  5931. {
  5932. Directory.CreateDirectory(fileDir);
  5933. }
  5934. //上传的文件的路径
  5935. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  5936. }
  5937. else if (TypeName == "B")//B代表商邀相关文件
  5938. {
  5939. if (!Directory.Exists(fileDir))
  5940. {
  5941. Directory.CreateDirectory(fileDir);
  5942. }
  5943. //上传的文件的路径
  5944. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  5945. }
  5946. using (FileStream fs = System.IO.File.Create(filePath))
  5947. {
  5948. file.CopyTo(fs);
  5949. fs.Flush();
  5950. }
  5951. return Ok(JsonView(true, "上传成功!", projectFileName));
  5952. }
  5953. else
  5954. {
  5955. return Ok(JsonView(false, "上传失败!"));
  5956. }
  5957. }
  5958. catch (Exception ex)
  5959. {
  5960. return Ok(JsonView(false, ex.Message));
  5961. }
  5962. }
  5963. /// <summary>
  5964. /// 删除指定文件
  5965. /// </summary>
  5966. /// <param name="dto"></param>
  5967. /// <returns></returns>
  5968. [HttpPost]
  5969. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5970. public async Task<IActionResult> DelFile(DelFileDto dto)
  5971. {
  5972. try
  5973. {
  5974. var TypeName = Request.Headers["TypeName"].ToString();
  5975. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  5976. string filePath = "";
  5977. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  5978. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  5979. int id = 0;
  5980. if (TypeName == "A")
  5981. {
  5982. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  5983. // 删除该文件
  5984. System.IO.File.Delete(filePath);
  5985. id = await _sqlSugar.Updateable<Grp_DecreasePayments>()
  5986. .Where(a => a.Id == dto.Id)
  5987. .SetColumns(a => new Grp_DecreasePayments { FilePath = "" })
  5988. .ExecuteCommandAsync();
  5989. }
  5990. else if (TypeName == "B")
  5991. {
  5992. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  5993. // 删除该文件
  5994. System.IO.File.Delete(filePath);
  5995. var info = await _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.Id == dto.Id && x.IsDel == 0).FirstAsync();
  5996. if (info != null)
  5997. {
  5998. string[] files = Array.Empty<string>();
  5999. if (!string.IsNullOrEmpty(info.Attachment))
  6000. {
  6001. try
  6002. {
  6003. files = JsonConvert.DeserializeObject<string[]>(info.Attachment);
  6004. }
  6005. catch (Exception)
  6006. {
  6007. files = new List<string>() { info.Attachment }.ToArray();
  6008. }
  6009. }
  6010. if (files.Length > 0)
  6011. {
  6012. var files1 = files.Where(x => !x.Equals(dto.fileName)).ToArray();
  6013. string filePath2 = string.Empty;
  6014. if (files1.Length > 0)
  6015. {
  6016. filePath2 = JsonConvert.SerializeObject(files1);
  6017. }
  6018. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  6019. .Where(a => a.Id == dto.Id)
  6020. .SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = filePath2 })
  6021. .ExecuteCommandAsync();
  6022. }
  6023. }
  6024. }
  6025. if (id != 0)
  6026. {
  6027. return Ok(JsonView(true, "成功!"));
  6028. }
  6029. else
  6030. {
  6031. return Ok(JsonView(false, "失败!"));
  6032. }
  6033. }
  6034. catch (Exception ex)
  6035. {
  6036. return Ok(JsonView(false, "程序错误!"));
  6037. throw;
  6038. }
  6039. }
  6040. /// <summary>
  6041. /// 文件上传多个文件 可以带参数
  6042. /// </summary>
  6043. /// <param name="files"></param>
  6044. /// <returns></returns>
  6045. [HttpPost]
  6046. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6047. public async Task<IActionResult> UploadProjects(IFormFile[] files)
  6048. {
  6049. try
  6050. {
  6051. var TypeName = Request.Headers["TypeName"].ToString();
  6052. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  6053. if (files.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  6054. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  6055. var filePahts = new List<string>();
  6056. foreach (var file in files)
  6057. {
  6058. //文件名称
  6059. string projectFileName = file.FileName;
  6060. //上传的文件的路径
  6061. string filePath = $"{fileDir}/{projectFileName}";
  6062. if (TypeName == "A")//A代表团组增减款项
  6063. {
  6064. if (!Directory.Exists(fileDir))
  6065. {
  6066. Directory.CreateDirectory(fileDir);
  6067. }
  6068. //上传的文件的路径
  6069. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  6070. }
  6071. else if (TypeName == "B")//B代表商邀相关文件
  6072. {
  6073. if (!Directory.Exists(fileDir))
  6074. {
  6075. Directory.CreateDirectory(fileDir);
  6076. }
  6077. //上传的文件的路径
  6078. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  6079. }
  6080. using (FileStream fs = System.IO.File.Create(filePath))
  6081. {
  6082. file.CopyTo(fs);
  6083. fs.Flush();
  6084. }
  6085. filePahts.Add(projectFileName);
  6086. }
  6087. return Ok(JsonView(true, "上传成功!", filePahts));
  6088. }
  6089. catch (Exception ex)
  6090. {
  6091. return Ok(JsonView(false, ex.Message));
  6092. }
  6093. }
  6094. #endregion
  6095. #region 商邀费用录入
  6096. /// <summary>
  6097. /// 根据团组Id查询商邀费用列表
  6098. /// </summary>
  6099. /// <param name="dto"></param>
  6100. /// <returns></returns>
  6101. [HttpPost]
  6102. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6103. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  6104. {
  6105. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  6106. if (groupData.Code != 0)
  6107. {
  6108. return Ok(JsonView(false, groupData.Msg));
  6109. }
  6110. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6111. }
  6112. /// <summary>
  6113. /// 商邀费用列表
  6114. /// 下载文件
  6115. /// </summary>
  6116. /// <param name="id"></param>
  6117. /// <returns></returns>
  6118. [HttpGet("{id}")]
  6119. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6120. public async Task<IActionResult> InvitationOfficialActivitiesListDownFile(int id)
  6121. {
  6122. if (id < 1) return Ok(JsonView(false, "请传入有效的Id!"));
  6123. var info = await _InvitationOfficialActivitiesRep.Query(x => x.Id == id).FirstAsync();
  6124. if (info == null) return Ok(JsonView(false, "数据不存在!"));
  6125. if (string.IsNullOrEmpty(info.Attachment)) return Ok(JsonView(false, "文件不存在!"));
  6126. var filePaths = new List<string>();
  6127. var filePathBase = @$"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/";
  6128. try
  6129. {
  6130. filePaths = JsonConvert.DeserializeObject<List<string>>(info.Attachment);
  6131. }
  6132. catch (Exception ex)
  6133. {
  6134. filePaths.Add(info.Attachment);
  6135. }
  6136. if (filePaths != null && filePaths.Count < 1) return Ok(JsonView(false, "文件不存在!"));
  6137. for (int i = 0; i < filePaths.Count; i++)
  6138. {
  6139. filePaths[i] = $"{filePathBase}{filePaths[i]}";
  6140. }
  6141. var zipFilePathGuid = $"{Guid.NewGuid()}.zip";
  6142. var zipFilePath = $"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{zipFilePathGuid}";
  6143. using (var zipFileStream = new FileStream(zipFilePath, FileMode.Create))
  6144. {
  6145. using (var zipArchive = new ZipArchive(zipFileStream, ZipArchiveMode.Create))
  6146. {
  6147. foreach (string filePath in filePaths)
  6148. {
  6149. if (System.IO.File.Exists(filePath))
  6150. {
  6151. // 获取文件名
  6152. string fileName = Path.GetFileName(filePath);
  6153. // 将文件添加到ZIP归档中
  6154. zipArchive.CreateEntryFromFile(filePath, fileName);
  6155. }
  6156. }
  6157. }
  6158. }
  6159. return Ok(JsonView(new { url = @$"{AppSettingsHelper.Get("OfficeBaseUrl")}{AppSettingsHelper.Get("GrpFileFtpPath")}/商邀相关文件/{zipFilePathGuid}" }));
  6160. }
  6161. /// <summary>
  6162. /// 商邀费用 Info Page 基础数据源
  6163. /// </summary>
  6164. /// <returns></returns>
  6165. [HttpPost]
  6166. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6167. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  6168. {
  6169. try
  6170. {
  6171. Result groupData = await _InvitationOfficialActivitiesRep.InitBasicData();
  6172. if (groupData.Code != 0)
  6173. {
  6174. return Ok(JsonView(false, groupData.Msg));
  6175. }
  6176. return Ok(JsonView(true, "操作成功", groupData.Data));
  6177. }
  6178. catch (Exception ex)
  6179. {
  6180. return Ok(JsonView(false, ex.Message));
  6181. throw;
  6182. }
  6183. }
  6184. /// <summary>
  6185. /// 根据商邀费用ID查询C表和商邀费用数据
  6186. /// </summary>
  6187. /// <param name="dto"></param>
  6188. /// <returns></returns>
  6189. [HttpPost]
  6190. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6191. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  6192. {
  6193. try
  6194. {
  6195. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  6196. if (groupData.Code != 0)
  6197. {
  6198. return Ok(JsonView(false, groupData.Msg));
  6199. }
  6200. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6201. }
  6202. catch (Exception ex)
  6203. {
  6204. return Ok(JsonView(false, ex.Message));
  6205. throw;
  6206. }
  6207. }
  6208. /// <summary>
  6209. /// 商邀费用录入操作(Status:1.新增,2.修改)
  6210. /// </summary>
  6211. /// <param name="dto"></param>
  6212. /// <returns></returns>
  6213. [HttpPost]
  6214. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6215. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  6216. {
  6217. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  6218. if (groupData.Code != 0)
  6219. {
  6220. return Ok(JsonView(false, groupData.Msg));
  6221. }
  6222. #region 应用推送
  6223. try
  6224. {
  6225. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  6226. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  6227. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  6228. //2024-10-21 新增LZ UID
  6229. var userIds = new List<int>() { 21 };
  6230. string title = $"系统通知";
  6231. string content = "";
  6232. var diId = dto.DiId;
  6233. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  6234. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  6235. if (dto.Status == 1) content = $"[新增-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  6236. else if (dto.Status == 2) content = $"[更新-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  6237. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  6238. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "81" };
  6239. await APNsTools.iOS_PushNotifications1("051", $"商邀费用审核", "", content, true, "ExpenseAuditWebView", h5);
  6240. }
  6241. catch (Exception ex)
  6242. {
  6243. }
  6244. #endregion
  6245. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6246. }
  6247. /// <summary>
  6248. /// 商邀删除
  6249. /// </summary>
  6250. /// <param name="dto"></param>
  6251. /// <returns></returns>
  6252. [HttpPost]
  6253. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6254. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  6255. {
  6256. try
  6257. {
  6258. _sqlSugar.BeginTran();
  6259. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  6260. .SetColumns(it => new Grp_InvitationOfficialActivities()
  6261. {
  6262. IsDel = 1,
  6263. DeleteUserId = dto.DeleteUserId,
  6264. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6265. })
  6266. .Where(it => it.Id == dto.Id)
  6267. .ExecuteCommand();
  6268. if (res1 > 0)
  6269. {
  6270. int _diId = 0;
  6271. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  6272. if (_ioaInfo != null)
  6273. {
  6274. _diId = _ioaInfo.DiId;
  6275. }
  6276. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  6277. .SetColumns(a => new Grp_CreditCardPayment()
  6278. {
  6279. IsDel = 1,
  6280. DeleteUserId = dto.DeleteUserId,
  6281. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6282. })
  6283. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  6284. .ExecuteCommand();
  6285. if (res2 > 0)
  6286. {
  6287. _sqlSugar.CommitTran();
  6288. return Ok(JsonView(true, "删除成功!"));
  6289. }
  6290. }
  6291. _sqlSugar.RollbackTran();
  6292. return Ok(JsonView(false, "删除失败"));
  6293. }
  6294. catch (Exception ex)
  6295. {
  6296. _sqlSugar.RollbackTran();
  6297. return Ok(JsonView(false, ex.Message));
  6298. }
  6299. }
  6300. #endregion
  6301. #region 票据上传
  6302. /// <summary>
  6303. /// 团组模块文件上传
  6304. /// </summary>
  6305. /// <param name="dto"></param>
  6306. /// <returns></returns>
  6307. [HttpPost]
  6308. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  6309. {
  6310. var jw = JsonView(false);
  6311. long M = 1024 * 1024;
  6312. if (dto.Files == null || dto.Files.Count == 0)
  6313. {
  6314. jw.Msg = "无文件信息!";
  6315. return Ok(jw);
  6316. }
  6317. if (dto.Files.Sum(x => x.Length) > 20 * M)
  6318. {
  6319. jw.Msg = "文件大小超过20M!";
  6320. return Ok(jw);
  6321. }
  6322. //var nameSp = dto.File.FileName.Split(".");
  6323. //if (nameSp.Length < 2)
  6324. //{
  6325. // jw.Msg = "拓展名称有误!";
  6326. // return Ok(jw);
  6327. //}
  6328. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  6329. //if (!existsName.Contains(nameSp[1].ToUpper()))
  6330. //{
  6331. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  6332. // return Ok(jw);
  6333. //}
  6334. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  6335. if (Ctable == null)
  6336. {
  6337. jw.Msg = "Ctable指向有误!";
  6338. return Ok(jw);
  6339. }
  6340. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  6341. if (groupInfo == null)
  6342. {
  6343. jw.Msg = "团组信息不存在!";
  6344. return Ok(jw);
  6345. }
  6346. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  6347. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  6348. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  6349. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  6350. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  6351. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  6352. try
  6353. {
  6354. if (!Directory.Exists(fileBase))
  6355. {
  6356. Directory.CreateDirectory(fileBase);
  6357. }
  6358. var saveArr = new List<Grp_GroupModelFile>();
  6359. foreach (var fileStream in dto.Files)
  6360. {
  6361. var saveFilePath = fileBase + "\\" + fileStream.FileName;
  6362. var file = new Grp_GroupModelFile()
  6363. {
  6364. Cid = dto.Cid,
  6365. CreateTime = DateTime.Now,
  6366. CreateUserId = dto.Userid,
  6367. Ctable = dto.Ctable,
  6368. Diid = dto.Diid,
  6369. IsDel = 0,
  6370. FilePath = saveFilePath,
  6371. FileName = fileStream.FileName
  6372. };
  6373. using (FileStream fs = System.IO.File.Create(saveFilePath))
  6374. {
  6375. fileStream.CopyTo(fs);
  6376. fs.Flush();
  6377. }
  6378. saveArr.Add(file);
  6379. }
  6380. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  6381. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  6382. jw = JsonView(true, "保存成功!", new
  6383. {
  6384. count = addResult,
  6385. filesName = saveArr.Select(x => x.FileName)
  6386. });
  6387. }
  6388. catch (Exception ex)
  6389. {
  6390. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  6391. {
  6392. count = 0,
  6393. filesName = Array.Empty<string>(),
  6394. });
  6395. }
  6396. return Ok(jw);
  6397. }
  6398. /// <summary>
  6399. /// 查询各模块已保存文件
  6400. /// </summary>
  6401. /// <param name="dto"></param>
  6402. /// <returns></returns>
  6403. [HttpPost]
  6404. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  6405. {
  6406. var expression = Expressionable.Create<Grp_GroupModelFile>()
  6407. .AndIF(dto.UserId != -1, x => x.CreateUserId == dto.UserId);
  6408. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x => x.Id).ToList();
  6409. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  6410. {
  6411. expression = Expressionable.Create<Grp_GroupModelFile>()
  6412. .And(x => visaIds.Contains(x.CreateUserId));
  6413. }
  6414. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  6415. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  6416. .Where(expression.ToExpression())
  6417. .ToList();
  6418. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  6419. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  6420. {
  6421. x.FileName,
  6422. x.Id,
  6423. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  6424. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  6425. })));
  6426. }
  6427. /// <summary>
  6428. /// 下载该团组下的所有文件
  6429. /// </summary>
  6430. /// <param name="dto"></param>
  6431. /// <returns></returns>
  6432. [HttpPost]
  6433. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  6434. {
  6435. var jw = JsonView(false);
  6436. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  6437. if (groupInfo == null)
  6438. {
  6439. jw.Msg = "团组信息不存在!";
  6440. return Ok(jw);
  6441. }
  6442. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  6443. var isModule = Convert.ToBoolean(dto.isModule);
  6444. var Zips = new Dictionary<string, Stream>();
  6445. var io = new IOOperatorHelper();
  6446. if (isModule)
  6447. {
  6448. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  6449. foreach (var moduleArr in moduleGroup)
  6450. {
  6451. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  6452. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  6453. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  6454. var chiZips = new Dictionary<string, Stream>();
  6455. foreach (var item in moduleArr)
  6456. {
  6457. if (System.IO.File.Exists(item.FilePath))
  6458. {
  6459. using (var fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  6460. {
  6461. byte[] bytes = new byte[fileStream.Length];
  6462. fileStream.Read(bytes, 0, bytes.Length);
  6463. fileStream.Close();
  6464. Stream stream = new MemoryStream(bytes);
  6465. chiZips.Add(item.FileName, stream);
  6466. }
  6467. }
  6468. }
  6469. if (chiZips.Count > 0)
  6470. {
  6471. var byts = io.ConvertZipStream(chiZips);
  6472. Stream stream = new MemoryStream(byts);
  6473. Zips.Add(key.Name + "_.zip", stream);
  6474. }
  6475. }
  6476. }
  6477. else
  6478. {
  6479. foreach (var item in dbQuery)
  6480. {
  6481. using (var fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  6482. {
  6483. byte[] bytes = new byte[fileStream.Length];
  6484. fileStream.Read(bytes, 0, bytes.Length);
  6485. fileStream.Close();
  6486. var stream = new MemoryStream(bytes);
  6487. while (Zips.ContainsKey(item.FileName))
  6488. {
  6489. item.FileName = new Random().Next(100) + "_" + item.FileName;
  6490. }
  6491. Zips.Add(item.FileName, stream);
  6492. }
  6493. }
  6494. }
  6495. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  6496. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  6497. if (Zips.Count > 0)
  6498. {
  6499. var byts = io.ConvertZipStream(Zips);
  6500. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  6501. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  6502. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  6503. }
  6504. else
  6505. {
  6506. jw.Msg = "暂无生成文件!";
  6507. }
  6508. return Ok(jw);
  6509. }
  6510. /// <summary>
  6511. /// 下载该团组下此模块的所有文件
  6512. /// </summary>
  6513. /// <param name="dto"></param>
  6514. /// <returns></returns>
  6515. [HttpPost]
  6516. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  6517. {
  6518. var jw = JsonView(false);
  6519. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  6520. if (groupInfo == null)
  6521. {
  6522. jw.Msg = "团组信息不存在!";
  6523. return Ok(jw);
  6524. }
  6525. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  6526. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  6527. && x.IsDel == 0);
  6528. if (key == null)
  6529. {
  6530. jw.Msg = "Ctable指向错误!";
  6531. return Ok(jw);
  6532. }
  6533. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  6534. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  6535. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  6536. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  6537. var io = new IOOperatorHelper();
  6538. var Zips = new Dictionary<string, Stream>();
  6539. foreach (var item in dbQuery)
  6540. {
  6541. if (System.IO.File.Exists(item.FilePath))
  6542. {
  6543. using (var fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  6544. {
  6545. byte[] bytes = new byte[fileStream.Length];
  6546. fileStream.Read(bytes, 0, bytes.Length);
  6547. fileStream.Close();
  6548. var stream = new MemoryStream(bytes);
  6549. while (Zips.ContainsKey(item.FileName))
  6550. {
  6551. item.FileName = new Random().Next(100) + "_" + item.FileName;
  6552. }
  6553. Zips.Add(item.FileName, stream);
  6554. }
  6555. }
  6556. }
  6557. if (Zips.Count > 0)
  6558. {
  6559. var byts = io.ConvertZipStream(Zips);
  6560. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  6561. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  6562. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  6563. }
  6564. else
  6565. {
  6566. jw.Msg = "暂无生成文件!";
  6567. }
  6568. return Ok(jw);
  6569. }
  6570. /// <summary>
  6571. /// 删除该团组下的指定文件
  6572. /// </summary>
  6573. /// <param name="dto"></param>
  6574. /// <returns></returns>
  6575. [HttpPost]
  6576. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  6577. {
  6578. var jw = JsonView(false);
  6579. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  6580. if (sing == null)
  6581. {
  6582. jw.Msg = "暂无";
  6583. return Ok(jw);
  6584. }
  6585. if (System.IO.File.Exists(sing.FilePath))
  6586. {
  6587. try
  6588. {
  6589. System.IO.File.Delete(sing.FilePath);
  6590. }
  6591. catch (Exception ex)
  6592. {
  6593. jw.Msg = "删除失败!" + ex.Message;
  6594. return Ok(jw);
  6595. }
  6596. }
  6597. sing.IsDel = 1;
  6598. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  6599. sing.DeleteUserId = dto.UserId;
  6600. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  6601. jw = JsonView(true, "删除成功!");
  6602. return Ok(jw);
  6603. }
  6604. #endregion
  6605. #region 共享文件上传
  6606. /// <summary>
  6607. /// 共享文件数据初始化
  6608. /// </summary>
  6609. /// <returns></returns>
  6610. [HttpGet]
  6611. public async Task<IActionResult> SharedFileInit(int userid, int portType)
  6612. {
  6613. var marketingDepartmentIds = new List<int> { 6, 26, 27, 28 };
  6614. var isMarketingDepartment = _sqlSugar.Queryable<Sys_Users>()
  6615. .Where(x => x.IsDel == 0 && marketingDepartmentIds.Contains(x.DepId))
  6616. .Select(x => x.Id)
  6617. .ToList()
  6618. .Contains(userid);
  6619. var dropDownType = _sqlSugar.Queryable<Sys_SetData>()
  6620. .Where(x => x.STid == 111 && x.IsDel == 0)
  6621. .Select(x => new
  6622. {
  6623. x.Name,
  6624. x.Id,
  6625. }).ToList();
  6626. if (isMarketingDepartment)
  6627. {
  6628. dropDownType = dropDownType.Where(x => x.Id == 1412).ToList();
  6629. }
  6630. if (portType == 1)
  6631. {
  6632. var provCityDatas = await _groupRepository.ProvinceCityBasicSource();
  6633. var dropDownGroupList = _sqlSugar.Queryable<Grp_DelegationInfo>()
  6634. .Where(x => x.IsDel == 0)
  6635. .OrderByDescending(x => x.VisitDate)
  6636. .Select(x => new
  6637. {
  6638. x.TeamName,
  6639. x.Id,
  6640. x.CityId,
  6641. })
  6642. .ToList()
  6643. .Select(x =>
  6644. {
  6645. var provinceId = x.CityId;
  6646. var isDefualtVal = true;
  6647. if (provinceId > 0)
  6648. {
  6649. var parentId = _groupRepository.FindParentIdByChildId(provCityDatas, provinceId);
  6650. if (parentId != null)
  6651. {
  6652. isDefualtVal = false;
  6653. provinceId = (int)parentId;
  6654. }
  6655. }
  6656. if (isDefualtVal)
  6657. {
  6658. provinceId = 122; //默认四川
  6659. }
  6660. return new
  6661. {
  6662. x.TeamName,
  6663. x.Id,
  6664. provinceId,
  6665. };
  6666. })
  6667. .ToList();
  6668. return Ok(JsonView(true, "SUCCESS!", new
  6669. {
  6670. dropDownType,
  6671. dropDownGroupList,
  6672. isMarketingDepartment
  6673. }));
  6674. }
  6675. else if (portType == 2 || portType == 3)
  6676. {
  6677. return Ok(JsonView(true, "SUCCESS!", new
  6678. {
  6679. dropDownType,
  6680. isMarketingDepartment
  6681. }));
  6682. }
  6683. else
  6684. {
  6685. return Ok(JsonView(false, "portType有误!"));
  6686. }
  6687. }
  6688. /// <summary>
  6689. /// 共享文件上传
  6690. /// </summary>
  6691. /// <param name="dto"></param>
  6692. /// <returns></returns>
  6693. [HttpPost]
  6694. public IActionResult SharedFileUpload([FromForm] SharedFileUploadDto dto)
  6695. {
  6696. var isGroup = new List<int> { 1412 };
  6697. if (isGroup.Contains(dto.FileType) && dto.Diid < 1)
  6698. {
  6699. return Ok(JsonView(false, "该文件需要关联团组!"));
  6700. }
  6701. if (dto.Files == null || dto.Files.Count == 0)
  6702. {
  6703. return Ok(JsonView(false, "无文件信息!"));
  6704. }
  6705. if (dto.Files.Sum(x => x.Length) > 20 * 1024 * 1024)
  6706. {
  6707. return Ok(JsonView(false, "文件大小超过20M!"));
  6708. }
  6709. if (dto.Userid < 1)
  6710. {
  6711. return Ok(JsonView(false, "请传入有效的Userid!"));
  6712. }
  6713. var jobInfo = _sqlSugar.Queryable<Sys_Users, Sys_JobPost>((u, j) => u.JobPostId == j.Id && j.IsDel == 0)
  6714. .Where(u => u.IsDel == 0 && u.Id == dto.Userid)
  6715. .Select((u, j) => new
  6716. {
  6717. u.CnName,
  6718. UserId = u.Id,
  6719. j.JobName,
  6720. })
  6721. .First();
  6722. if (jobInfo == null)
  6723. {
  6724. return Ok(JsonView(false, "请传入有效的Userid!"));
  6725. }
  6726. var commonFileExtensions = new List<string>
  6727. {
  6728. // 文本文件
  6729. ".txt", ".doc", ".docx", ".odt", ".pdf", ".rtf", ".md", ".log",
  6730. // 图片文件
  6731. ".jpg", ".jpeg", ".png", ".gif", ".bmp", ".tiff", ".svg",
  6732. // 视频文件
  6733. ".mp4", ".avi", ".mov", ".mkv", ".wmv", ".flv", ".mpg", ".mpeg",
  6734. // 音频文件
  6735. ".mp3", ".wav", ".ogg", ".aac", ".flac",
  6736. // 压缩文件
  6737. ".zip", ".rar", ".7z", ".tar", ".gz", ".bz2",
  6738. // 数据文件
  6739. ".csv", ".xls", ".xlsx", ".json", ".xml", ".yaml", ".ini",
  6740. };
  6741. try
  6742. {
  6743. var setting = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1416);
  6744. var settingExtend = JsonConvert.DeserializeObject<List<string>>(setting.Remark);
  6745. commonFileExtensions.AddRange(settingExtend);
  6746. }
  6747. catch (Exception)
  6748. { }
  6749. var setdata = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.FileType);
  6750. if (setdata == null)
  6751. {
  6752. return Ok(JsonView(false, "请传入有效的FileType!"));
  6753. }
  6754. var insertList = new List<Grp_GroupShareFile>();
  6755. string winPath = AppSettingsHelper.Get("ShareFileBasePath") + $"{setdata.Name}/";
  6756. if (!Directory.Exists(winPath))
  6757. {
  6758. Directory.CreateDirectory(winPath);
  6759. }
  6760. foreach (var item in dto.Files)
  6761. {
  6762. var houzui = Path.GetExtension(item.FileName);
  6763. if (!commonFileExtensions.Contains(houzui))
  6764. {
  6765. return Ok(JsonView(false, "未知后缀名称!"));
  6766. }
  6767. var fileName = $"{jobInfo.JobName}-{jobInfo.CnName}-{item.FileName}";
  6768. var saveFilePath = winPath + fileName;
  6769. using (FileStream fs = System.IO.File.Create(saveFilePath))
  6770. {
  6771. item.CopyTo(fs);
  6772. fs.Flush();
  6773. }
  6774. var fileDetail = new Grp_GroupShareFile()
  6775. {
  6776. CreateUserId = dto.Userid,
  6777. CreateTime = DateTime.Now,
  6778. UploadJob = jobInfo.JobName,
  6779. FileName = fileName,
  6780. FileType = dto.FileType,
  6781. Diid = dto.Diid,
  6782. FilePath = winPath + fileName,
  6783. };
  6784. insertList.Add(fileDetail);
  6785. }
  6786. _sqlSugar.Insertable<Grp_GroupShareFile>(insertList).ExecuteCommand();
  6787. return Ok(JsonView(true, "保存成功!"));
  6788. }
  6789. /// <summary>
  6790. /// 查询共享文件列表
  6791. /// </summary>
  6792. /// <param name="dto"></param>
  6793. /// <returns></returns>
  6794. [HttpPost]
  6795. public IActionResult QuerySharedFile(QuerySharedFileDto dto)
  6796. {
  6797. var isGroup = new List<int> { 1412 };
  6798. if (!isGroup.Contains(dto.FileType)) dto.Diid = 0;
  6799. var queryExpression = Expressionable.Create<Grp_GroupShareFile>()
  6800. .And(x => x.Diid == dto.Diid)
  6801. .And(x => x.FileType == dto.FileType)
  6802. .And(x => x.IsDel == 0)
  6803. .AndIF(!dto.FileName.IsNullOrWhiteSpace(), x => x.FileName.Contains(dto.FileName))
  6804. .AndIF(DateTime.TryParse(dto.StartTime, out DateTime Start), x => x.CreateTime >= Start)
  6805. .AndIF(DateTime.TryParse(dto.EndTime, out DateTime End), x => x.CreateTime <= End);
  6806. int totalCount = 0;
  6807. var dbQuery = _sqlSugar.Queryable<Grp_GroupShareFile>()
  6808. .Where(queryExpression.ToExpression())
  6809. .OrderBy(x => x.UploadJob)
  6810. .Select(x => new
  6811. {
  6812. x.Id,
  6813. FilePath = AppSettingsHelper.Get("ShareFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("ShareFileBasePath"), AppSettingsHelper.Get("ShareFileFtpPath")),
  6814. x.FileName,
  6815. x.FileType,
  6816. x.CreateTime,
  6817. })
  6818. .ToPageList(dto.PageIndex, dto.PageSize, ref totalCount);
  6819. return Ok(JsonView(true, "SUCCESS!", new
  6820. {
  6821. FileList = dbQuery,
  6822. dto.PageSize,
  6823. dto.PageIndex,
  6824. totalCount
  6825. }));
  6826. }
  6827. /// <summary>
  6828. /// 删除共享文件模块下的指定文件
  6829. /// </summary>
  6830. /// <param name="dto"></param>
  6831. /// <returns></returns>
  6832. [HttpPost]
  6833. public IActionResult DeleteSharedFile(DeleteGroupFileDto dto)
  6834. {
  6835. var jw = JsonView(false);
  6836. var sing = _sqlSugar.Queryable<Grp_GroupShareFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  6837. if (sing == null)
  6838. {
  6839. jw.Msg = "暂无文件信息!";
  6840. return Ok(jw);
  6841. }
  6842. if (sing.CreateUserId != dto.UserId)
  6843. {
  6844. jw.Msg = "只能删除自己上传的文件!";
  6845. return Ok(jw);
  6846. }
  6847. if (System.IO.File.Exists(sing.FilePath))
  6848. {
  6849. try
  6850. {
  6851. System.IO.File.Delete(sing.FilePath);
  6852. }
  6853. catch (Exception ex)
  6854. {
  6855. jw.Msg = "删除失败!" + ex.Message;
  6856. return Ok(jw);
  6857. }
  6858. }
  6859. sing.IsDel = 1;
  6860. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  6861. sing.DeleteUserId = dto.UserId;
  6862. _sqlSugar.Updateable<Grp_GroupShareFile>(sing).ExecuteCommand();
  6863. jw = JsonView(true, "删除成功!");
  6864. return Ok(jw);
  6865. }
  6866. #endregion
  6867. #region 团组英文资料
  6868. /// <summary>
  6869. /// 查询团组英文所有资料
  6870. /// </summary>
  6871. /// <param name="dto"></param>
  6872. /// <returns></returns>
  6873. [HttpPost]
  6874. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6875. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  6876. {
  6877. try
  6878. {
  6879. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  6880. if (groupData.Code != 0)
  6881. {
  6882. return Ok(JsonView(false, groupData.Msg));
  6883. }
  6884. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6885. }
  6886. catch (Exception ex)
  6887. {
  6888. return Ok(JsonView(false, ex.Message));
  6889. throw;
  6890. }
  6891. }
  6892. /// <summary>
  6893. /// 团组英文资料操作(Status:1.新增,2.修改)
  6894. /// </summary>
  6895. /// <param name="dto"></param>
  6896. /// <returns></returns>
  6897. [HttpPost]
  6898. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6899. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  6900. {
  6901. try
  6902. {
  6903. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  6904. if (groupData.Code != 0)
  6905. {
  6906. return Ok(JsonView(false, groupData.Msg));
  6907. }
  6908. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6909. }
  6910. catch (Exception ex)
  6911. {
  6912. return Ok(JsonView(false, ex.Message));
  6913. throw;
  6914. }
  6915. }
  6916. /// <summary>
  6917. /// 团组英文资料Id查询数据
  6918. /// </summary>
  6919. /// <param name="dto"></param>
  6920. /// <returns></returns>
  6921. [HttpPost]
  6922. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6923. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  6924. {
  6925. try
  6926. {
  6927. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  6928. if (_DelegationEnData != null)
  6929. {
  6930. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  6931. }
  6932. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  6933. }
  6934. catch (Exception ex)
  6935. {
  6936. return Ok(JsonView(false, "程序错误!"));
  6937. throw;
  6938. }
  6939. }
  6940. /// <summary>
  6941. /// 团组英文资料删除
  6942. /// </summary>
  6943. /// <param name="dto"></param>
  6944. /// <returns></returns>
  6945. [HttpPost]
  6946. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6947. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  6948. {
  6949. try
  6950. {
  6951. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  6952. if (!res)
  6953. {
  6954. return Ok(JsonView(false, "删除失败"));
  6955. }
  6956. return Ok(JsonView(true, "删除成功!"));
  6957. }
  6958. catch (Exception ex)
  6959. {
  6960. return Ok(JsonView(false, ex.Message));
  6961. throw;
  6962. }
  6963. }
  6964. #endregion
  6965. #region 导出邀请函
  6966. /// <summary>
  6967. /// 导出邀请函页面初始化
  6968. /// </summary>
  6969. /// <param name="dto"></param>
  6970. /// <returns></returns>
  6971. [HttpPost]
  6972. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6973. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  6974. {
  6975. try
  6976. {
  6977. var grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.VisitStartDate, OrderByType.Desc).ToList();
  6978. var crm_Deles = new List<Crm_DeleClient>();
  6979. if (dto.DiId == 0)
  6980. {
  6981. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  6982. }
  6983. else
  6984. {
  6985. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  6986. }
  6987. return Ok(JsonView(true, "查询成功!", new
  6988. {
  6989. deleClient = crm_Deles,
  6990. delegations = grp_Delegations
  6991. }));
  6992. }
  6993. catch (Exception ex)
  6994. {
  6995. return Ok(JsonView(false, "程序错误!"));
  6996. throw;
  6997. }
  6998. }
  6999. /// <summary>
  7000. /// 导出邀请函
  7001. /// </summary>
  7002. /// <param name="dto"></param>
  7003. /// <returns></returns>
  7004. [HttpPost]
  7005. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7006. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  7007. {
  7008. #region 参数验证
  7009. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  7010. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  7011. #endregion
  7012. try
  7013. {
  7014. var transDic = new Dictionary<string, string>();
  7015. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  7016. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  7017. From Grp_TourClientList tcl
  7018. Left Join
  7019. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  7020. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  7021. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  7022. From Crm_DeleClient dc
  7023. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  7024. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  7025. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  7026. Where dc.IsDel = 0) temp
  7027. On temp.DcId =tcl.ClientId
  7028. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  7029. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  7030. var texts = new List<string>();
  7031. if (datas.Count != 0)
  7032. {
  7033. foreach (TourClientListDetailsView item in datas)
  7034. {
  7035. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  7036. {
  7037. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  7038. }
  7039. else
  7040. {
  7041. string name = item.LastName + item.FirstName;
  7042. texts.Add(name);
  7043. }
  7044. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  7045. {
  7046. if (!transDic.ContainsKey(item.Job))
  7047. {
  7048. texts.Add(item.Job);
  7049. }
  7050. }
  7051. if (!string.IsNullOrEmpty(item.CompanyFullName))
  7052. {
  7053. texts.Add(item.CompanyFullName);
  7054. }
  7055. }
  7056. var transData = await _airTicketResRep.ReTransBatch(texts, "en");
  7057. if (transData.Count > 0)
  7058. {
  7059. foreach (TranslateResult item in transData)
  7060. {
  7061. if (!transDic.ContainsKey(item.Query))
  7062. {
  7063. transDic.Add(item.Query, item.Translation);
  7064. }
  7065. }
  7066. }
  7067. var list = new List<GuestList>();
  7068. foreach (var dele in datas)
  7069. {
  7070. var guestList = new GuestList();
  7071. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  7072. {
  7073. guestList.Name = dele.Pinyin;
  7074. }
  7075. else
  7076. {
  7077. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  7078. guestList.Name = Name;
  7079. }
  7080. if (dele.Sex == 0)
  7081. {
  7082. guestList.Sex = "Male";
  7083. }
  7084. else if (dele.Sex == 1)
  7085. {
  7086. guestList.Sex = "Female";
  7087. }
  7088. guestList.DOB = dele.BirthDay.Replace('-', '.');
  7089. if (!string.IsNullOrEmpty(dele.Job))
  7090. {
  7091. guestList.Job = dele.Job;
  7092. }
  7093. list.Add(guestList);
  7094. }
  7095. //载入模板
  7096. var doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  7097. var builder = new DocumentBuilder(doc);
  7098. //获取word里所有表格
  7099. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7100. //获取所填表格的序数
  7101. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  7102. var rowStart = tableOne.Rows[0]; //获取第1行
  7103. //循环赋值
  7104. for (int i = 0; i < list.Count; i++)
  7105. {
  7106. builder.MoveToCell(0, i + 1, 0, 0);
  7107. builder.Write(list[i].Name.ToString());
  7108. builder.MoveToCell(0, i + 1, 1, 0);
  7109. builder.Write(list[i].Sex.ToString());
  7110. builder.MoveToCell(0, i + 1, 2, 0);
  7111. builder.Write(list[i].DOB.ToString());
  7112. builder.MoveToCell(0, i + 1, 3, 0);
  7113. builder.Write(list[i].Job.ToString());
  7114. }
  7115. //删除多余行
  7116. while (tableOne.Rows.Count > list.Count + 1)
  7117. {
  7118. tableOne.Rows.RemoveAt(list.Count + 1);
  7119. }
  7120. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  7121. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  7122. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  7123. doc.Save(filePath);
  7124. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  7125. return Ok(JsonView(true, "操作成功!", Url));
  7126. }
  7127. else
  7128. {
  7129. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  7130. }
  7131. }
  7132. catch (Exception ex)
  7133. {
  7134. return Ok(JsonView(false, ex.Message));
  7135. throw;
  7136. }
  7137. }
  7138. #endregion
  7139. #region 团组经理模块 出入境费用
  7140. /// <summary>
  7141. /// 团组模块 - 出入境费用 - 省份基础数据源
  7142. /// </summary>
  7143. /// <returns></returns>
  7144. [HttpGet]
  7145. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7146. public async Task<IActionResult> GetEnterExitProvBelongCostDataSource()
  7147. {
  7148. return Ok(JsonView(await _groupRepository.ProvinceBasicSource()));
  7149. }
  7150. /// <summary>
  7151. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  7152. /// </summary>
  7153. /// <param name="dto"></param>
  7154. /// <returns></returns>
  7155. [HttpPost]
  7156. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7157. public async Task<IActionResult> GetEnterExitCostDataSource(EnterExitCostDataSourceDto dto)
  7158. {
  7159. var groupNameData = await _groupRepository.EnterExitCostGroupNameAsync();
  7160. var groupNamFirst = groupNameData.FirstOrDefault();
  7161. //SetDataInfoView
  7162. var dataSource = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  7163. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  7164. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  7165. //验证城市归属并给默认值
  7166. int provinceId = 122;
  7167. if (groupNamFirst != null) provinceId = groupNamFirst.ProvinceId;
  7168. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostRep.FileOwner(provinceId);
  7169. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  7170. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  7171. return Ok(JsonView(true, "查询成功!", new
  7172. {
  7173. GroupNameData = groupNameData,
  7174. CurrencyData = _CurrencyData,
  7175. WordTypeData = wordTypeData,
  7176. ExcelTypeData = excelTypeData,
  7177. CurrencyInit = _currencyInfos,
  7178. ViewPermissionData = viewPermissionData
  7179. }));
  7180. }
  7181. /// <summary>
  7182. /// 团组模块 - 出入境费用 - 文件类型list 跟据省份Id获取
  7183. /// </summary>
  7184. /// <returns></returns>
  7185. [HttpGet("{provinceId}")]
  7186. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7187. public async Task<IActionResult> EnterExitCostFileOwner([FromRoute] int provinceId = 122)
  7188. {
  7189. //验证城市归属并给默认值
  7190. if (provinceId < 1) provinceId = 122;
  7191. /*
  7192. * 122 四川
  7193. * 108 贵州
  7194. * 103 重庆
  7195. * 132 云南
  7196. */
  7197. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostDraftRep.FileOwner(provinceId);
  7198. return Ok(JsonView(true, "查询成功!", new
  7199. {
  7200. WordTypeData = wordTypeData,
  7201. ExcelTypeData = excelTypeData,
  7202. }));
  7203. }
  7204. /// <summary>
  7205. /// 团组模块 - 出入境费用
  7206. /// 实时汇率 tips
  7207. /// 签证费用 tips
  7208. /// 机票费用 tips
  7209. /// </summary>
  7210. /// <returns></returns>
  7211. [HttpPost]
  7212. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7213. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  7214. {
  7215. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  7216. //默认币种显示
  7217. var reteInfos = await GeneralMethod.EnterExitCostLiveRate();
  7218. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.DiId);
  7219. var airData = await GeneralMethod.EntryAndExitTips(dto.DiId);
  7220. return Ok(JsonView(true, "查询成功!", new
  7221. {
  7222. //GroupNameData = groupNameData.Data,
  7223. visaData = visaData.Data,
  7224. airData,
  7225. reteInfos
  7226. }));
  7227. }
  7228. /// <summary>
  7229. /// 团组模块 - 出入境费用 - Info
  7230. /// </summary>
  7231. /// <param name="dto"></param>
  7232. /// <returns></returns>
  7233. [HttpPost]
  7234. //[ApiLog("Grp_EnterExitCost", OperationEnum.Details)]
  7235. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7236. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  7237. {
  7238. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7239. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7240. return Ok(await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto));
  7241. }
  7242. /// <summary>
  7243. /// 团组模块 - 出入境费用 - 设置view权限
  7244. /// </summary>
  7245. /// <returns></returns>
  7246. [HttpPost]
  7247. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7248. public async Task<IActionResult> EnterExitCostSetViewPermissiion(EnterExitCostSetViewPermissiionDto dto)
  7249. {
  7250. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7251. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7252. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  7253. var permissions = new List<Grp_EnterExitCostPermission>();
  7254. foreach (var userId in dto.UserIds)
  7255. {
  7256. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.GroupId, UserId = userId, CreateUserId = dto.CurrUserId });
  7257. }
  7258. if (permissions.Any())
  7259. {
  7260. _sqlSugar.BeginTran();
  7261. try
  7262. {
  7263. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.GroupId).ExecuteCommandAsync();
  7264. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  7265. if (result < 1)
  7266. {
  7267. _sqlSugar.RollbackTran();
  7268. return Ok(JsonView(false));
  7269. }
  7270. }
  7271. catch (Exception ex)
  7272. {
  7273. _sqlSugar.RollbackTran();
  7274. return Ok(JsonView(false, ex.Message));
  7275. }
  7276. _sqlSugar.CommitTran();
  7277. return Ok(JsonView(true));
  7278. }
  7279. return Ok(JsonView(false));
  7280. }
  7281. /// <summary>
  7282. /// 团组模块 - 出入境费用 - Add And Update
  7283. /// </summary>
  7284. /// <returns></returns>
  7285. [HttpPost]
  7286. [ApiLog("Grp_EnterExitCost", OperationEnum.Add)]
  7287. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7288. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  7289. {
  7290. try
  7291. {
  7292. var rateRecords = new List<RateRecordInfo>();
  7293. #region 汇率保存前存储
  7294. var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(x => x.IsDel == 0 && x.DiId == dto.DiId);
  7295. if (info != null)
  7296. {
  7297. var cacheRateInfos = CommonFun.GetCurrencyChinaToList(info.CurrencyRemark);
  7298. if (cacheRateInfos != null && cacheRateInfos.Count > 0)
  7299. {
  7300. rateRecords = cacheRateInfos.Select(x => new RateRecordInfo()
  7301. {
  7302. CurrencyCode = x.CurrencyCode,
  7303. CurrencyName = x.CurrencyName,
  7304. UpdatePreRate = x.Rate,
  7305. UpdateBreRate = dto.Currencys.Where(x1 => x1.CurrencyName.Equals(x.CurrencyName)).FirstOrDefault()?.Rate ?? 0.00M
  7306. }).ToList();
  7307. }
  7308. else
  7309. {
  7310. rateRecords = dto.Currencys.Select(x => new RateRecordInfo()
  7311. {
  7312. CurrencyCode = x.CurrencyCode,
  7313. CurrencyName = x.CurrencyName,
  7314. UpdatePreRate = 0.00M,
  7315. UpdateBreRate = x.Rate
  7316. }).ToList();
  7317. }
  7318. }
  7319. else
  7320. {
  7321. rateRecords = dto.Currencys.Select(x => new RateRecordInfo()
  7322. {
  7323. CurrencyCode = x.CurrencyCode,
  7324. CurrencyName = x.CurrencyName,
  7325. UpdatePreRate = 0.00M,
  7326. UpdateBreRate = x.Rate
  7327. }).ToList();
  7328. }
  7329. #endregion
  7330. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  7331. if (dto.DayOtherPriceData.Any())
  7332. {
  7333. var inserList = dto.DayOtherPriceData
  7334. .Where(x => x.Id == 0)
  7335. .Select(x => new Grp_DayOtherPrice
  7336. {
  7337. Cost = x.Cost,
  7338. Id = x.Id,
  7339. CreateTime = DateTime.Now,
  7340. CreateUserId = dto.UserId,
  7341. Currency = x.Currency,
  7342. Diid = x.DiId,
  7343. Index = x.Index,
  7344. IsDel = 0,
  7345. SetDataId = x.SetDataId,
  7346. SubTotal = x.SubTotal,
  7347. Remark = x.Remark
  7348. })
  7349. .ToList();
  7350. var updateList = dto.DayOtherPriceData
  7351. .Where(x => x.Id != 0)
  7352. .Select(x => new Grp_DayOtherPrice
  7353. {
  7354. Cost = x.Cost,
  7355. Id = x.Id,
  7356. CreateTime = DateTime.Now,
  7357. CreateUserId = dto.UserId,
  7358. Currency = x.Currency,
  7359. Diid = x.DiId,
  7360. Index = x.Index,
  7361. IsDel = 0,
  7362. SetDataId = x.SetDataId,
  7363. SubTotal = x.SubTotal,
  7364. Remark = x.Remark
  7365. })
  7366. .ToList();
  7367. //添加
  7368. _sqlSugar.BeginTran();
  7369. if (inserList.Any())
  7370. {
  7371. var rowCount = _sqlSugar.Insertable<Grp_DayOtherPrice>(inserList).ExecuteCommand();
  7372. }
  7373. if (updateList.Any())
  7374. {
  7375. var rowCount = _sqlSugar.Updateable<Grp_DayOtherPrice>(updateList).ExecuteCommand();
  7376. }
  7377. _sqlSugar.CommitTran();
  7378. }
  7379. if (data.Code != 0)
  7380. {
  7381. return Ok(JsonView(false, data.Msg));
  7382. }
  7383. //生成默认文件pdf并且通知人员
  7384. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  7385. {
  7386. DiId = dto.DiId,
  7387. ExportType = 1,
  7388. SubTypeId = 1005
  7389. }, "pdf");
  7390. //发送通知
  7391. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  7392. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  7393. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  7394. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign, fileUrl);
  7395. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  7396. //汇率信息记录
  7397. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  7398. var checkCurrencys = await _enterExitCostRep.GetCheckCurrencies(dto.DiId);
  7399. //汇率验证、反推
  7400. (bool isSendMsg, string msgContent, List<CurrencyInfo> liveRates) = await GeneralMethod.EnterExitCostCheckRate(dto.DiId, checkCurrencys);
  7401. if (isSendMsg)
  7402. {
  7403. //消息推送
  7404. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFin(dto.DiId, dto.UserId, msgContent);
  7405. }
  7406. #region //日志汇率记录
  7407. //按照已使用币种记录
  7408. if (checkCurrencys != null && checkCurrencys.Count > 0)
  7409. {
  7410. rateRecords = rateRecords.Where(x => checkCurrencys.Select(x1 => x1.CurrencyName).ToList().Contains(x.CurrencyName)).ToList();
  7411. //汇率记录中加入实时汇率
  7412. if (liveRates != null && liveRates.Count > 0)
  7413. {
  7414. foreach (var item in rateRecords)
  7415. {
  7416. item.CurrLiveRate = liveRates.Where(x => x.CurrencyName.Equals(item.CurrencyName)).FirstOrDefault()?.Rate ?? 0.00M;
  7417. }
  7418. }
  7419. var teamName = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.Id == dto.DiId && x.IsDel == 0).Select(x => x.TeamName).FirstAsync();
  7420. var operationName = await _sqlSugar.Queryable<Sys_Users>().Where(x => x.Id == dto.UserId && x.IsDel == 0).Select(x => x.CnName).FirstAsync();
  7421. var logContent = new StringBuilder();
  7422. foreach (var item in rateRecords)
  7423. {
  7424. var blRate = (item.CurrLiveRate * 1.0350M).TruncDecimals(4);
  7425. string msg = $">- {item.CurrencyName}汇率:(页面保存前){item.UpdatePreRate:#0.0000}/(页面保存){item.UpdateBreRate:#0.0000}/实时汇率(已上浮1.0350):{blRate:#0.0000}【注:原接口输出汇率为:{item.CurrLiveRate:#0.0000}】";
  7426. logContent.AppendLine(msg);
  7427. }
  7428. _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());
  7429. }
  7430. #endregion
  7431. return Ok(JsonView(true, data.Msg, data.Data));
  7432. }
  7433. catch (Exception ex)
  7434. {
  7435. return Ok(JsonView(false, ex.Message));
  7436. }
  7437. }
  7438. /// <summary>
  7439. /// 团组模块 - 出入境费用 - Confirm 费用
  7440. /// </summary>
  7441. /// <returns></returns>
  7442. [HttpPost]
  7443. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7444. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  7445. {
  7446. //TODO:测试完毕需把对应的用户ID更改
  7447. //1、数据表添加字段
  7448. //2、更改字段接口()
  7449. var _view = await _enterExitCostRep.ConfirmCost(dto);
  7450. //3、确认成功 给财务发送消息
  7451. if (_view.Code == 200)
  7452. {
  7453. if (dto.Type == 1)
  7454. {
  7455. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  7456. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  7457. }
  7458. }
  7459. return Ok(_view);
  7460. }
  7461. /// <summary>
  7462. /// 团组模块 - 出入境费用 - File download
  7463. /// </summary>
  7464. /// <param name="dto"></param>
  7465. /// <returns></returns>
  7466. [HttpPost]
  7467. //[ApiLog("Grp_EnterExitCost", OperationEnum.Download)]
  7468. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7469. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  7470. {
  7471. try
  7472. {
  7473. if (dto.DiId < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  7474. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  7475. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  7476. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  7477. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  7478. 3 团组成员名单 1 团组成员名单", ""));
  7479. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).OrderByDescending(x => x.CreateTime).First();
  7480. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  7481. if (_EnterExitCosts == null) return Ok(JsonView(400, "该团组未填写出入境费用;", ""));
  7482. var currencyInit = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToList();
  7483. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  7484. //数据源
  7485. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  7486. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  7487. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  7488. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  7489. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  7490. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  7491. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  7492. .Where((x, a, b) => x.IsDel == 0 && x.Diid == dto.DiId)
  7493. .Select((x, a, b) => new
  7494. {
  7495. x.Index,
  7496. itemName = a.Name,
  7497. CurrencyStr = b.Name,
  7498. x.Cost,
  7499. x.SubTotal,
  7500. x.Remark
  7501. })
  7502. .OrderBy((x) => x.Index)
  7503. .ToList(); //其他款项费用
  7504. var peiceItemCurrencys = new List<string>();
  7505. if (_DayAndCosts.Any())
  7506. {
  7507. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  7508. if (currencyIds.Any()) peiceItemCurrencys.AddRange(currencyInit.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  7509. }
  7510. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  7511. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  7512. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  7513. {
  7514. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  7515. }
  7516. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  7517. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  7518. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  7519. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  7520. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  7521. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  7522. .Select((tcl, dc, cc) => new ClientInfo
  7523. {
  7524. LastName = dc.LastName,
  7525. FirstName = dc.FirstName,
  7526. Sex = dc.Sex,
  7527. Birthday = dc.BirthDay,
  7528. Company = cc.CompanyFullName,
  7529. Job = dc.Job
  7530. })
  7531. .ToList();
  7532. foreach (var item in DeleClientList)
  7533. {
  7534. EncryptionProcessor.DecryptProperties(item);
  7535. }
  7536. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  7537. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  7538. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  7539. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  7540. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  7541. if (dto.ExportType == 1) //明细表
  7542. {
  7543. if (dto.SubTypeId == 1005) //1005(默认明细表)
  7544. {
  7545. //获取模板
  7546. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  7547. //载入模板
  7548. var doc = new Document(tempPath);
  7549. var builder = new DocumentBuilder(doc);
  7550. var dic = new Dictionary<string, string>();
  7551. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  7552. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  7553. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  7554. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  7555. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  7556. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  7557. //境内费用(其他费用)
  7558. if (_EnterExitCosts.ChoiceOne == 1)
  7559. {
  7560. string row1_1 = "";
  7561. if (_EnterExitCosts.Visa > 0)
  7562. {
  7563. //insidePayTotal += _EnterExitCosts.Visa;
  7564. row1_1 = $"签证费:{_EnterExitCosts.Visa:#0.00} 元/人";
  7565. //if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  7566. //{
  7567. // row1_1 += $"\t签证费用描述: {_EnterExitCosts.VisaRemark} 人民币/人";
  7568. //}
  7569. }
  7570. string row1_2 = "";
  7571. if (_EnterExitCosts.YiMiao > 0)
  7572. {
  7573. //insidePayTotal += _EnterExitCosts.YiMiao;
  7574. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00} 元/人";
  7575. }
  7576. if (_EnterExitCosts.HeSuan > 0)
  7577. {
  7578. //insidePayTotal += _EnterExitCosts.HeSuan;
  7579. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan:#0.00} 元/人";
  7580. }
  7581. if (_EnterExitCosts.Service > 0)
  7582. {
  7583. //insidePayTotal += _EnterExitCosts.Service;
  7584. row1_2 += $"服务费:{_EnterExitCosts.Service:#0.00} 元/人";
  7585. }
  7586. string row1_3 = "";
  7587. if (_EnterExitCosts.Safe > 0)
  7588. {
  7589. //insidePayTotal += _EnterExitCosts.Safe;
  7590. row1_3 += $"保险费:{_EnterExitCosts.Safe:#0.00} 元/人";
  7591. }
  7592. if (_EnterExitCosts.Ticket > 0)
  7593. {
  7594. //insidePayTotal += _EnterExitCosts.Ticket;
  7595. row1_3 += $"参展门票:{_EnterExitCosts.Ticket:#0.00} 元/人";
  7596. }
  7597. string row1 = "";
  7598. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  7599. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  7600. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  7601. row1 += $"备注:{_EnterExitCosts.Remark}";
  7602. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  7603. dic.Add("Row1Str", row1);
  7604. }
  7605. string airTotalStr = string.Empty,
  7606. airPriceStr = string.Empty;
  7607. //经济舱
  7608. if (_EnterExitCosts.SumJJC == 1)
  7609. {
  7610. airTotalStr += $"{_EnterExitCosts.OutsideJJPay:#0.00}元/人(经济舱)";
  7611. airPriceStr += $"{_EnterExitCosts.AirJJ:#0.00}元/人(经济舱)";
  7612. }
  7613. //公务舱
  7614. if (_EnterExitCosts.SumGWC == 1)
  7615. {
  7616. airTotalStr += $" {_EnterExitCosts.OutsideGWPay:#0.00} 元/人(公务舱)";
  7617. airPriceStr += $" {_EnterExitCosts.AirGW:#0.00} 元/人(公务舱)";
  7618. }
  7619. //头等舱
  7620. if (_EnterExitCosts.SumTDC == 1)
  7621. {
  7622. airTotalStr += $" {_EnterExitCosts.OutsideTDPay:#0.00} 元/人(头等舱)";
  7623. airPriceStr += $" {_EnterExitCosts.AirTD:#0.00} 元/人(头等舱)";
  7624. }
  7625. //汇率描述
  7626. string rateStr = "";
  7627. if (peiceItemCurrencyInfos.Any())
  7628. {
  7629. rateStr = "\r\n汇率描述:";
  7630. foreach (var item in peiceItemCurrencyInfos)
  7631. {
  7632. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate:#0.0000} ";
  7633. }
  7634. }
  7635. string twoItemRemark = "备注:";
  7636. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  7637. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  7638. dic.Add("AirTotalStr", airTotalStr);
  7639. dic.Add("AirPriceStr", airPriceStr);
  7640. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  7641. dic.Add("TwoItemRemark", twoItemRemark);
  7642. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7643. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7644. int table1Row = 0,
  7645. table2Row = 0,
  7646. table3Row = 0,
  7647. table4Row = 0,
  7648. table5Row = 0;
  7649. //住宿费
  7650. if (_EnterExitCosts.ChoiceThree == 1)
  7651. {
  7652. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  7653. table1Row = dac1.Count;
  7654. #region 填充word表格内容
  7655. for (int i = 0; i < dac1.Count; i++)
  7656. {
  7657. Grp_DayAndCost dac = dac1[i];
  7658. if (dac == null) continue;
  7659. builder.MoveToCell(0, i, 0, 0);
  7660. builder.Write("第" + dac.Days.ToString() + "晚:");
  7661. builder.MoveToCell(0, i, 1, 0);
  7662. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  7663. //builder.Write(dac.Place == null ? "" : dac.Place);
  7664. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7665. builder.MoveToCell(0, i, 2, 0);
  7666. builder.Write("费用标准:");
  7667. string curr = "";
  7668. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  7669. if (currData != null)
  7670. {
  7671. curr = currData.Name;
  7672. }
  7673. builder.MoveToCell(0, i, 3, 0);
  7674. builder.Write(dac.Cost.ToString("#0.00") + curr);
  7675. builder.MoveToCell(0, i, 4, 0);
  7676. builder.Write("费用小计:");
  7677. builder.MoveToCell(0, i, 5, 0);
  7678. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7679. }
  7680. #endregion
  7681. }
  7682. else dic.Add("SubZS", "0.00");
  7683. //删除多余行
  7684. while (table1.Rows.Count > table1Row)
  7685. {
  7686. table1.Rows.RemoveAt(table1Row);
  7687. }
  7688. //伙食费
  7689. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  7690. if (_EnterExitCosts.ChoiceFour == 1)
  7691. {
  7692. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  7693. table2Row = dac2.Count;
  7694. #region 填充word表格内容
  7695. for (int i = 0; i < dac2.Count; i++)
  7696. {
  7697. Grp_DayAndCost dac = dac2[i];
  7698. if (dac == null) continue;
  7699. builder.MoveToCell(1, i, 0, 0);
  7700. builder.Write("第" + dac.Days.ToString() + "天:");
  7701. builder.MoveToCell(1, i, 1, 0);
  7702. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7703. builder.MoveToCell(1, i, 2, 0);
  7704. builder.Write("费用标准:");
  7705. string curr = "";
  7706. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  7707. if (currData != null)
  7708. {
  7709. curr = currData.Name;
  7710. }
  7711. builder.MoveToCell(1, i, 3, 0);
  7712. builder.Write(dac.Cost.ToString("#0.00") + curr);
  7713. builder.MoveToCell(1, i, 4, 0);
  7714. builder.Write("费用小计:");
  7715. builder.MoveToCell(1, i, 5, 0);
  7716. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7717. }
  7718. #endregion
  7719. }
  7720. else dic.Add("SubHS", "0.00");
  7721. //删除多余行
  7722. while (table2.Rows.Count > table2Row)
  7723. {
  7724. table2.Rows.RemoveAt(table2Row);
  7725. }
  7726. //公杂费
  7727. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  7728. if (_EnterExitCosts.ChoiceFive == 1)
  7729. {
  7730. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  7731. table3Row = dac3.Count;
  7732. #region 填充word表格内容
  7733. for (int i = 0; i < dac3.Count; i++)
  7734. {
  7735. Grp_DayAndCost dac = dac3[i];
  7736. if (dac == null) continue;
  7737. builder.MoveToCell(2, i, 0, 0);
  7738. builder.Write("第" + dac.Days.ToString() + "天:");
  7739. builder.MoveToCell(2, i, 1, 0);
  7740. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7741. builder.MoveToCell(2, i, 2, 0);
  7742. builder.Write("费用标准:");
  7743. string curr = "";
  7744. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  7745. if (currData != null)
  7746. {
  7747. curr = currData.Name;
  7748. }
  7749. builder.MoveToCell(2, i, 3, 0);
  7750. builder.Write(dac.Cost.ToString("#0.00") + curr);
  7751. builder.MoveToCell(2, i, 4, 0);
  7752. builder.Write("费用小计:");
  7753. builder.MoveToCell(2, i, 5, 0);
  7754. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7755. }
  7756. //删除多余行
  7757. while (table3.Rows.Count > table3Row)
  7758. {
  7759. table3.Rows.RemoveAt(table3Row);
  7760. }
  7761. #endregion
  7762. }
  7763. else dic.Add("SubGZF", "0.00");
  7764. //删除多余行
  7765. while (table3.Rows.Count > table3Row)
  7766. {
  7767. table3.Rows.RemoveAt(table3Row);
  7768. }
  7769. //培训费
  7770. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  7771. if (_EnterExitCosts.ChoiceSix == 1)
  7772. {
  7773. string pxStr = $"六、培训费合计: {tainFeeTotal:#0.00} 元/人";
  7774. dic.Add("SubPX", pxStr);
  7775. table4Row = dac4.Count;
  7776. #region 填充word表格内容
  7777. for (int i = 0; i < dac4.Count; i++)
  7778. {
  7779. Grp_DayAndCost dac = dac4[i];
  7780. if (dac == null) continue;
  7781. builder.MoveToCell(3, i, 0, 0);
  7782. builder.Write("第" + dac.Days.ToString() + "天:");
  7783. builder.MoveToCell(3, i, 1, 0);
  7784. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7785. builder.MoveToCell(3, i, 2, 0);
  7786. builder.Write("费用标准:");
  7787. string curr = "";
  7788. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  7789. if (currData != null)
  7790. {
  7791. curr = currData.Name;
  7792. }
  7793. builder.MoveToCell(3, i, 3, 0);
  7794. builder.Write(dac.Cost.ToString("#0.00") + curr);
  7795. builder.MoveToCell(3, i, 4, 0);
  7796. builder.Write("费用小计:");
  7797. builder.MoveToCell(3, i, 5, 0);
  7798. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7799. }
  7800. #endregion
  7801. }
  7802. //else dic.Add("SubPX", $"六、培训费合计: 0.00 元/人");
  7803. //删除多余行
  7804. while (table4.Rows.Count > table4Row)
  7805. {
  7806. table4.Rows.RemoveAt(table4Row);
  7807. }
  7808. //其他费用
  7809. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  7810. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  7811. {
  7812. string qtStr = $"七、其他费用合计: {otherPriceTotal:#0.00} 元/人";
  7813. dic.Add("titleQi", qtStr);
  7814. table5Row = dac5.Count;
  7815. #region 填充word表格内容
  7816. for (int i = 0; i < dac5.Count; i++)
  7817. {
  7818. var dac = dac5[i];
  7819. if (dac == null) continue;
  7820. builder.MoveToCell(4, i, 0, 0);
  7821. builder.Write("第" + dac.Index.ToString() + "项:");
  7822. builder.MoveToCell(4, i, 1, 0);
  7823. builder.Write(dac.itemName);
  7824. builder.MoveToCell(4, i, 2, 0);
  7825. builder.Write("费用标准:");
  7826. builder.MoveToCell(4, i, 3, 0);
  7827. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  7828. builder.MoveToCell(4, i, 4, 0);
  7829. builder.Write("费用小计:");
  7830. builder.MoveToCell(4, i, 5, 0);
  7831. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7832. builder.MoveToCell(4, i, 6, 0);
  7833. builder.Write("备注:");
  7834. builder.MoveToCell(4, i, 7, 0);
  7835. builder.Write(dac.Remark);
  7836. }
  7837. #endregion
  7838. }
  7839. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  7840. //删除多余行
  7841. while (table5.Rows.Count > table5Row)
  7842. {
  7843. table5.Rows.RemoveAt(table5Row);
  7844. }
  7845. //加上其他费用
  7846. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  7847. decimal subJJC = 0.00M,
  7848. subGWC = 0.00M,
  7849. subTDC = 0.00M;
  7850. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  7851. string totalLabel = string.Format("全部费用总计:");
  7852. //经济舱
  7853. if (_EnterExitCosts.SumJJC == 1)
  7854. {
  7855. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  7856. totalLabel += $"{subJJC:#0.00} 元/人(经济舱)";
  7857. }
  7858. //公务舱
  7859. if (_EnterExitCosts.SumGWC == 1)
  7860. {
  7861. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  7862. totalLabel += $"{subGWC:#0.00} 元/人(公务舱)";
  7863. }
  7864. //头等舱
  7865. if (_EnterExitCosts.SumTDC == 1)
  7866. {
  7867. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  7868. totalLabel += $"{subTDC:#0.00} 元/人(头等舱)";
  7869. }
  7870. //TotalLabel
  7871. dic.Add("TotalLabel", totalLabel);
  7872. //dic.Add("SubJJC", subJJC.ToString("#0.00"));
  7873. //dic.Add("SubGWC", subGWC.ToString("#0.00"));
  7874. //dic.Add("SubTDC", subTDC.ToString("#0.00"));
  7875. #region 填充word模板书签内容
  7876. foreach (var key in dic.Keys)
  7877. {
  7878. Bookmark bookmark = doc.Range.Bookmarks[key];
  7879. if (bookmark != null)
  7880. {
  7881. builder.MoveToBookmark(key);
  7882. builder.Write(dic[key]);
  7883. }
  7884. }
  7885. #endregion
  7886. #region 设置页眉
  7887. string userLabel = string.Empty;
  7888. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  7889. if (currUserInfo != null)
  7890. {
  7891. var userInfo = await _usersRep.GetUserBriefInfo(currUserInfo.UserId);
  7892. if (userInfo != null)
  7893. {
  7894. string ext = string.IsNullOrEmpty(userInfo.ExtensionNumber) ? "-" : userInfo.ExtensionNumber;
  7895. //userLabel = $"联系人:{userInfo.Name} 职位:{userInfo.Job}\r\n座机/分机号:{ext} 手机号:{userInfo.Tel} 公司邮箱:{userInfo.Email}";
  7896. userLabel = $"联系人:{userInfo.Name} 职 位:{userInfo.Job} 手机号:{userInfo.Tel}\r\n公司邮箱:{userInfo.Email}";
  7897. }
  7898. }
  7899. //设置页脚
  7900. //GeneralMethod.AsposeWordSetFooter(builder, userLabel, "华文仿宋", 10);
  7901. #endregion
  7902. var guid = CommonFun.GUID.Substring(0,8);
  7903. //文件名
  7904. string strFileName = CommonFun.ValidFileName($"{_DelegationInfo.TeamName}出入境费用{guid}.docx");
  7905. AsposeHelper.removewatermark_v2180();
  7906. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7907. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7908. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7909. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7910. }
  7911. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  7912. {
  7913. //获取模板
  7914. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  7915. //载入模板
  7916. var doc = new Document(tempPath);
  7917. var builder = new DocumentBuilder(doc);
  7918. var dic = new Dictionary<string, string>();
  7919. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  7920. {
  7921. var list = new List<string>();
  7922. try
  7923. {
  7924. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  7925. foreach (var item in spilitArr)
  7926. {
  7927. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  7928. var depCode = spDotandEmpty[2].Substring(0, 3);
  7929. var arrCode = spDotandEmpty[2].Substring(3, 3);
  7930. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  7931. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  7932. list.Add(depName);
  7933. list.Add(arrName);
  7934. }
  7935. list = list.Distinct().ToList();
  7936. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  7937. }
  7938. catch (Exception)
  7939. {
  7940. dic.Add("ReturnCode", "行程录入不正确!");
  7941. }
  7942. }
  7943. else
  7944. {
  7945. dic.Add("ReturnCode", "未录入行程!");
  7946. }
  7947. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  7948. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  7949. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  7950. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  7951. {
  7952. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  7953. dic.Add("Day", sp.Days.ToString());
  7954. }
  7955. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7956. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  7957. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  7958. //dic.Add("Names", Names);
  7959. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7960. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7961. decimal dac1totalPrice = 0.00M;
  7962. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  7963. foreach (var dac in dac1)
  7964. {
  7965. if (dac.SubTotal == 0.00M)
  7966. {
  7967. continue;
  7968. }
  7969. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  7970. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  7971. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7972. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7973. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  7974. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  7975. builder.Write(currency);//币种
  7976. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  7977. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7978. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  7979. builder.Write("");//人数
  7980. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  7981. builder.Write("");//天数
  7982. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  7983. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7984. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  7985. decimal rate = 0.00M;
  7986. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  7987. builder.Write(rate.ToString("#0.0000"));//汇率
  7988. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7989. decimal rbmPrice = dac.SubTotal;
  7990. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7991. accommodationStartIndex++;
  7992. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  7993. }
  7994. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7995. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  7996. {
  7997. table1.Rows.RemoveAt(i - 1);
  7998. foodandotherStartIndex--;
  7999. }
  8000. if (dac2.Count == dac3.Count)//国家 币种 金额
  8001. {
  8002. for (int i = 0; i < dac2.Count; i++)
  8003. {
  8004. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  8005. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  8006. }
  8007. }
  8008. decimal dac2totalPrice = 0.00M;
  8009. foreach (var dac in dac2)
  8010. {
  8011. if (dac.SubTotal == 0)
  8012. {
  8013. continue;
  8014. }
  8015. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  8016. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  8017. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  8018. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  8019. builder.Write(currency);//币种
  8020. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  8021. builder.Write(dac.Cost.ToString("#0.00"));//标准
  8022. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  8023. builder.Write("");//人数
  8024. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  8025. builder.Write("");//天数
  8026. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  8027. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  8028. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  8029. decimal rate = 0.00M;
  8030. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  8031. builder.Write(rate.ToString("#0.0000"));//汇率
  8032. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  8033. decimal rbmPrice = dac.SubTotal;
  8034. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  8035. foodandotherStartIndex++;
  8036. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  8037. }
  8038. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  8039. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  8040. {
  8041. table1.Rows.RemoveAt(i - 1);
  8042. }
  8043. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  8044. string otherFeeStr = "";
  8045. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa:#0.00} 元,";
  8046. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe:#0.00} 元,";
  8047. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00} 元,";
  8048. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  8049. foreach (var otherInfo in dac5)
  8050. {
  8051. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  8052. }
  8053. #endregion
  8054. if (otherFeeStr.Length > 0)
  8055. {
  8056. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  8057. otherFeeStr = $"({otherFeeStr})";
  8058. dic.Add("OtherFeeStr", otherFeeStr);
  8059. }
  8060. //总计
  8061. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  8062. //国际旅费
  8063. string outsideAir = string.Empty;
  8064. string allPriceAir = string.Empty;
  8065. if (_EnterExitCosts.SumJJC == 1)
  8066. {
  8067. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  8068. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  8069. }
  8070. if (_EnterExitCosts.SumGWC == 1)
  8071. {
  8072. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  8073. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  8074. }
  8075. if (_EnterExitCosts.SumTDC == 1)
  8076. {
  8077. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  8078. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  8079. }
  8080. dic.Add("InTravelPrice", $"({outsideAir})");
  8081. dic.Add("FinalSumPrice", $"({allPriceAir})");
  8082. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  8083. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  8084. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  8085. foreach (var key in dic.Keys)
  8086. {
  8087. builder.MoveToBookmark(key);
  8088. builder.Write(dic[key]);
  8089. }
  8090. //模板文件名
  8091. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  8092. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8093. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8094. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8095. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8096. }
  8097. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  8098. {
  8099. //获取模板
  8100. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  8101. //载入模板
  8102. var designer = new WorkbookDesigner
  8103. {
  8104. Workbook = new Workbook(tempPath)
  8105. };
  8106. var dic = new Dictionary<string, string>();
  8107. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  8108. {
  8109. var list = new List<string>();
  8110. try
  8111. {
  8112. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  8113. foreach (var item in spilitArr)
  8114. {
  8115. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  8116. var depCode = spDotandEmpty[2].Substring(0, 3);
  8117. var arrCode = spDotandEmpty[2].Substring(3, 3);
  8118. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  8119. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  8120. list.Add(depName);
  8121. list.Add(arrName);
  8122. }
  8123. list = list.Distinct().ToList();
  8124. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  8125. }
  8126. catch (Exception)
  8127. {
  8128. dic.Add("ReturnCode", "行程录入不正确!");
  8129. }
  8130. }
  8131. else
  8132. {
  8133. dic.Add("ReturnCode", "未录入行程!");
  8134. }
  8135. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  8136. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  8137. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  8138. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  8139. {
  8140. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  8141. dic.Add("Day", sp.Days.ToString());
  8142. }
  8143. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  8144. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  8145. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  8146. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  8147. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  8148. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  8149. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  8150. designer.SetDataSource("Name", Names);
  8151. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  8152. designer.SetDataSource("Day", dic["Day"] + "天");
  8153. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  8154. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  8155. int startIndex = 10;
  8156. const int startIndexcopy = 10;
  8157. if (dac2.Count == dac3.Count)//国家 币种 金额
  8158. {
  8159. for (int i = 0; i < dac2.Count; i++)
  8160. {
  8161. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  8162. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  8163. }
  8164. }
  8165. var dtdac1 = new DataTable();
  8166. var place = new List<string>();
  8167. dtdac1.Columns.AddRange(new DataColumn[] {
  8168. new(){ ColumnName = "city"},
  8169. new(){ ColumnName = "curr"},
  8170. new(){ ColumnName = "criterion"},
  8171. new(){ ColumnName = "number",DataType = typeof(int)},
  8172. new(){ ColumnName = "day",DataType = typeof(int)},
  8173. new(){ ColumnName = "cost", DataType = typeof(decimal)},
  8174. new(){ ColumnName = "rate", DataType = typeof(decimal) },
  8175. new(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  8176. });
  8177. var dtdac2 = new DataTable();
  8178. dtdac2.Columns.AddRange(new DataColumn[] {
  8179. new(){ ColumnName = "city"},
  8180. new(){ ColumnName = "curr"},
  8181. new(){ ColumnName = "criterion"},
  8182. new(){ ColumnName = "number",DataType = typeof(int)},
  8183. new(){ ColumnName = "day",DataType = typeof(int)},
  8184. new(){ ColumnName = "cost", DataType = typeof(decimal)},
  8185. new(){ ColumnName = "rate", DataType = typeof(decimal) },
  8186. new(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  8187. });
  8188. dtdac1.TableName = "tb1";
  8189. dtdac2.TableName = "tb2";
  8190. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  8191. foreach (var item in dac1)
  8192. {
  8193. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  8194. if (place.Contains(item.Place))
  8195. {
  8196. continue;
  8197. }
  8198. DataRow row = dtdac1.NewRow();
  8199. row["city"] = item.Place;
  8200. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  8201. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  8202. row["curr"] = currency;
  8203. row["rate"] = rate.ToString("#0.0000");
  8204. row["criterion"] = item.Cost.ToString("#0.00");
  8205. row["number"] = 1;
  8206. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  8207. //row["costRMB"] = rbmPrice;
  8208. dtdac1.Rows.Add(row);
  8209. place.Add(item.Place);
  8210. }
  8211. place = new List<string>();
  8212. foreach (var item in dac2)
  8213. {
  8214. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  8215. if (place.Contains(item.Place))
  8216. {
  8217. continue;
  8218. }
  8219. DataRow row = dtdac2.NewRow();
  8220. row["city"] = item.Place;
  8221. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  8222. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  8223. row["curr"] = currency;
  8224. row["rate"] = rate.ToString("#0.0000");
  8225. row["criterion"] = item.Cost.ToString("#0.00");
  8226. row["number"] = 1;
  8227. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  8228. //row["cost"] = item.SubTotal;
  8229. //row["costRMB"] = rbmPrice;
  8230. dtdac2.Rows.Add(row);
  8231. place.Add(item.Place);
  8232. //dac2totalPrice += rbmPrice;
  8233. }
  8234. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  8235. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  8236. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  8237. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  8238. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic:#0.00} 元");
  8239. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic:#0.00} ");
  8240. string cell4Str1 = string.Empty;
  8241. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ:#0.00} 元/人;";
  8242. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW:#0.00} 元/人;";
  8243. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD:#0.00} 元/人;";
  8244. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  8245. string cellStr = $" 5.其他费用(";
  8246. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  8247. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  8248. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  8249. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  8250. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  8251. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  8252. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  8253. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  8254. foreach (var otherInfo in dac5)
  8255. {
  8256. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  8257. }
  8258. #endregion
  8259. if (cellStr.Length > 8)
  8260. {
  8261. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  8262. }
  8263. cellStr += ")";
  8264. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  8265. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  8266. decimal pxFee = dac4.Sum(it => it.Cost);
  8267. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  8268. string celllastStr1 = "";
  8269. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice:#0.00} 元";
  8270. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice:#0.00} 元";
  8271. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee:#0.00} 元";
  8272. celllastStr1 += $",国际旅费 元";
  8273. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee:#0.00} 元";
  8274. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  8275. designer.SetDataSource("cell4Str", cell4Str);
  8276. designer.SetDataSource("cellStr", cellStr);
  8277. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  8278. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  8279. designer.SetDataSource("celllastStr", celllastStr);
  8280. Workbook wb = designer.Workbook;
  8281. var sheet = wb.Worksheets[0];
  8282. //绑定datatable数据集
  8283. designer.SetDataSource(dtdac1);
  8284. designer.SetDataSource(dtdac2);
  8285. designer.Process();
  8286. var rowStart = dtdac1.Rows.Count;
  8287. while (rowStart > 0)
  8288. {
  8289. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  8290. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  8291. startIndex++;
  8292. rowStart--;
  8293. }
  8294. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  8295. startIndex += 1; //总计行
  8296. rowStart = dtdac2.Rows.Count;
  8297. while (rowStart > 0)
  8298. {
  8299. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  8300. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  8301. startIndex++;
  8302. rowStart--;
  8303. }
  8304. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  8305. wb.CalculateFormula(true);
  8306. //模板文件名
  8307. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  8308. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8309. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8310. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8311. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8312. }
  8313. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  8314. {
  8315. //获取模板
  8316. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  8317. //载入模板
  8318. var doc = new Document(tempPath);
  8319. var builder = new DocumentBuilder(doc);
  8320. var dic = new Dictionary<string, string>
  8321. {
  8322. { "GroupName", _DelegationInfo.TeamName },
  8323. { "ClientUnit", _DelegationInfo.ClientUnit }
  8324. };
  8325. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  8326. string missionLeaderJob = "";//负责人job
  8327. //int groupNumber = 0; //团人数
  8328. if (DeleClientList.Count > 0)
  8329. {
  8330. missionLeader = DeleClientList[0]?.Name ?? "";
  8331. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  8332. }
  8333. dic.Add("MissionLeader", missionLeader); //团负责人
  8334. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  8335. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  8336. #region MyRegion
  8337. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  8338. //{
  8339. // List<string> list = new List<string>();
  8340. // try
  8341. // {
  8342. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  8343. // foreach (var item in spilitArr)
  8344. // {
  8345. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  8346. // var depCode = spDotandEmpty[2].Substring(0, 3);
  8347. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  8348. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  8349. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  8350. // list.Add(depName);
  8351. // list.Add(arrName);
  8352. // }
  8353. // list = list.Distinct().ToList();
  8354. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  8355. // }
  8356. // catch (Exception)
  8357. // {
  8358. // dic.Add("ReturnCode", "行程录入不正确!");
  8359. // }
  8360. //}
  8361. //else
  8362. //{
  8363. // dic.Add("ReturnCode", "未录入行程!");
  8364. //}
  8365. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  8366. dic.Add("ReturnCode", string.Join("、", countrys));
  8367. #endregion
  8368. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  8369. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  8370. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  8371. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  8372. //{
  8373. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  8374. // dic.Add("Day", sp.Days.ToString());
  8375. //}
  8376. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  8377. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  8378. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  8379. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8380. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  8381. //培训人员名单
  8382. int cultivateRowIndex = 7;
  8383. foreach (var item in DeleClientList)
  8384. {
  8385. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  8386. builder.Write(item.Name);
  8387. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  8388. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  8389. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  8390. string birthDay = "";
  8391. if (item.Birthday != null)
  8392. {
  8393. DateTime dt = Convert.ToDateTime(item.Birthday);
  8394. birthDay = $"{dt.Year}.{dt.Month}";
  8395. }
  8396. builder.Write(birthDay);
  8397. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  8398. builder.Write(item.Company);
  8399. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  8400. builder.Write(item.Job);
  8401. cultivateRowIndex++;
  8402. }
  8403. //删除多余行
  8404. //cultivateRowIndex -= 2;
  8405. int delRows = 10 + 7 - cultivateRowIndex;
  8406. if (delRows > 0)
  8407. {
  8408. for (int i = 0; i < delRows; i++)
  8409. {
  8410. table1.Rows.RemoveAt(cultivateRowIndex);
  8411. //cultivateRowIndex++;
  8412. }
  8413. }
  8414. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  8415. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  8416. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  8417. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  8418. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  8419. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  8420. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  8421. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  8422. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  8423. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  8424. //其他费用
  8425. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  8426. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  8427. //其他费用合计
  8428. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  8429. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  8430. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  8431. //公务舱合计
  8432. //国际旅费
  8433. //string outsideJJ = "";
  8434. //string allPriceJJ = "";
  8435. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  8436. {
  8437. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  8438. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  8439. }
  8440. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  8441. {
  8442. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  8443. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  8444. }
  8445. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  8446. {
  8447. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ:#0.00} 公务舱:{_EnterExitCosts.AirGW:#0.00}");
  8448. dic.Add("AirFeeTotal", airFeeTotalStr);
  8449. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal:#0.00} 公务舱:{_gwcFeeToatal:#0.00}");
  8450. dic.Add("FeeTotal", feeTotalStr);
  8451. }
  8452. foreach (var key in dic.Keys)
  8453. {
  8454. builder.MoveToBookmark(key);
  8455. builder.Write(dic[key]);
  8456. }
  8457. //模板文件名
  8458. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  8459. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8460. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8461. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8462. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8463. }
  8464. }
  8465. else if (dto.ExportType == 2) //表格
  8466. {
  8467. //利用键值对存放数据
  8468. Dictionary<string, string> dic = new Dictionary<string, string>();
  8469. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  8470. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  8471. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  8472. dic.Add("Day", sp.Days.ToString());
  8473. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  8474. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  8475. {
  8476. //获取模板
  8477. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  8478. //载入模板
  8479. var doc = new Document(tempPath);
  8480. var builder = new DocumentBuilder(doc);
  8481. dic.Add("TeamName", _DelegationInfo.TeamName);
  8482. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  8483. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  8484. string missionLeaderName = "",
  8485. missionLeaderJob = "";
  8486. if (DeleClientList.Count > 0)
  8487. {
  8488. missionLeaderName = DeleClientList[0].Name;
  8489. missionLeaderJob = DeleClientList[0].Job;
  8490. }
  8491. dic.Add("MissionLeaderName", missionLeaderName);
  8492. dic.Add("MissionLeaderJob", missionLeaderJob);
  8493. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  8494. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  8495. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8496. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  8497. int rowCount = 10;//总人数行
  8498. int startRowIndex = 7; //起始行
  8499. for (int i = 0; i < DeleClientList.Count; i++)
  8500. {
  8501. builder.MoveToCell(0, startRowIndex, 0, 0);
  8502. builder.Write(DeleClientList[i].Name); //出国人员姓名
  8503. builder.MoveToCell(0, startRowIndex, 1, 0);
  8504. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  8505. builder.Write(sex);//性别
  8506. builder.MoveToCell(0, startRowIndex, 2, 0);
  8507. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  8508. builder.MoveToCell(0, startRowIndex, 3, 0);
  8509. builder.Write(DeleClientList[i].Company);//工作单位
  8510. builder.MoveToCell(0, startRowIndex, 4, 0);
  8511. builder.Write(DeleClientList[i].Job);//职务及级别
  8512. builder.MoveToCell(0, startRowIndex, 5, 0);
  8513. builder.Write("");//人员属性
  8514. builder.MoveToCell(0, startRowIndex, 6, 0);
  8515. builder.Write("");//上次出国时间
  8516. startRowIndex++;
  8517. }
  8518. int nullRow = rowCount - DeleClientList.Count;//空行
  8519. for (int i = 0; i < nullRow; i++)
  8520. {
  8521. table1.Rows.Remove(table1.Rows[startRowIndex]);
  8522. }
  8523. foreach (var key in dic.Keys)
  8524. {
  8525. builder.MoveToBookmark(key);
  8526. builder.Write(dic[key]);
  8527. }
  8528. //模板文件名
  8529. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  8530. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8531. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8532. if (dto.PortType == 1) return Ok(JsonView(true, "成功", new { Url = url }));
  8533. else if (dto.PortType == 2 || dto.PortType == 3) return Ok(JsonView(true, "成功", url));
  8534. }
  8535. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  8536. {
  8537. //获取模板
  8538. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  8539. //载入模板
  8540. var doc = new Document(tempPath);
  8541. var builder = new DocumentBuilder(doc);
  8542. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  8543. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  8544. dic.Add("Names", Names);
  8545. int accommodationRows = 12;
  8546. //int foodandotherRows = 12;
  8547. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  8548. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  8549. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8550. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  8551. int accommodationStartIndex = 6;
  8552. decimal dac1totalPrice = 0.00M;
  8553. foreach (var dac in dac1)
  8554. {
  8555. if (dac.SubTotal == 0)
  8556. {
  8557. continue;
  8558. }
  8559. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  8560. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  8561. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  8562. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  8563. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  8564. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  8565. builder.Write(currency);//币种
  8566. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  8567. builder.Write(dac.Cost.ToString("#0.00"));//标准
  8568. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  8569. builder.Write("");//人数
  8570. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  8571. builder.Write("");//天数
  8572. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  8573. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  8574. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  8575. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  8576. builder.Write(rate.ToString("#0.0000"));//汇率
  8577. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  8578. decimal rbmPrice = rate * dac.SubTotal;
  8579. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  8580. accommodationStartIndex++;
  8581. dac1totalPrice += rbmPrice;
  8582. }
  8583. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  8584. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  8585. builder.Write("小计");
  8586. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  8587. builder.Write(dac1totalPrice.ToString("#0.00"));
  8588. accommodationStartIndex++;
  8589. int nullRow = accommodationRows - dac1.Count;
  8590. //删除空行
  8591. //if (nullRow > 0)
  8592. //{
  8593. // int rowIndex = accommodationStartIndex;
  8594. // for (int i = 0; i < nullRow; i++)
  8595. // {
  8596. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  8597. // row.Remove();
  8598. // rowIndex++;
  8599. // }
  8600. //}
  8601. if (dac2.Count == dac3.Count)//国家 币种 金额
  8602. {
  8603. for (int i = 0; i < dac2.Count; i++)
  8604. {
  8605. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  8606. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  8607. }
  8608. }
  8609. int foodandotherStartIndex = 19;//
  8610. decimal dac2totalPrice = 0.00M;
  8611. foreach (var dac in dac2)
  8612. {
  8613. if (dac.SubTotal == 0)
  8614. {
  8615. continue;
  8616. }
  8617. //foodandotherStartIndex = 12;
  8618. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  8619. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  8620. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  8621. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  8622. builder.Write(currency);//币种
  8623. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  8624. builder.Write(dac.Cost.ToString("#0.00"));//标准
  8625. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  8626. builder.Write("");//人数
  8627. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  8628. builder.Write("");//天数
  8629. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  8630. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  8631. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  8632. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  8633. builder.Write(rate.ToString("#0.0000"));//汇率
  8634. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  8635. decimal rbmPrice = rate * dac.SubTotal;
  8636. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  8637. foodandotherStartIndex++;
  8638. dac2totalPrice += rbmPrice;
  8639. }
  8640. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  8641. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  8642. //删除空行
  8643. //if (dac2.Count < foodandotherRows)
  8644. //{
  8645. // while (table2.Rows.Count > dac2.Count)
  8646. // {
  8647. // table2.Rows.RemoveAt(dac2.Count);
  8648. // }
  8649. //}
  8650. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  8651. string otherFeeStr = "";
  8652. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  8653. if (_EnterExitCosts.YiMiao > 0) otherFeeStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  8654. if (_EnterExitCosts.HeSuan > 0) otherFeeStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  8655. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  8656. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  8657. if (_EnterExitCosts.Service > 0) otherFeeStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  8658. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  8659. foreach (var otherInfo in dac5)
  8660. {
  8661. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal:#0.00} 元,";
  8662. }
  8663. #endregion
  8664. if (otherFeeStr.Length > 0)
  8665. {
  8666. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  8667. otherFeeStr = $"({otherFeeStr})";
  8668. dic.Add("OtherFeeStr", otherFeeStr);
  8669. }
  8670. foreach (var key in dic.Keys)
  8671. {
  8672. builder.MoveToBookmark(key);
  8673. builder.Write(dic[key]);
  8674. }
  8675. //模板文件名
  8676. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  8677. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8678. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8679. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8680. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8681. }
  8682. }
  8683. else if (dto.ExportType == 3)
  8684. {
  8685. if (dto.SubTypeId == 1) //团组成员名单
  8686. {
  8687. if (!DeleClientList.Any()) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成员暂未录入!!!", ""));
  8688. //获取模板
  8689. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  8690. //载入模板
  8691. var doc = new Document(tempPath);
  8692. var builder = new DocumentBuilder(doc);
  8693. //获取word里所有表格
  8694. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8695. //获取所填表格的序数
  8696. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  8697. var rowStart = tableOne.Rows[0]; //获取第1行
  8698. //循环赋值
  8699. for (int i = 0; i < DeleClientList.Count; i++)
  8700. {
  8701. builder.MoveToCell(0, i + 1, 0, 0);
  8702. builder.Write(DeleClientList[i].Name);
  8703. builder.MoveToCell(0, i + 1, 1, 0);
  8704. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  8705. builder.Write(sex);
  8706. builder.MoveToCell(0, i + 1, 2, 0);
  8707. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  8708. builder.MoveToCell(0, i + 1, 3, 0);
  8709. builder.Write(DeleClientList[i].Company);
  8710. builder.MoveToCell(0, i + 1, 4, 0);
  8711. builder.Write(DeleClientList[i].Job);
  8712. }
  8713. //删除多余行
  8714. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  8715. {
  8716. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  8717. }
  8718. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  8719. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  8720. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  8721. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8722. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8723. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8724. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8725. }
  8726. }
  8727. return Ok(JsonView(400, "操作失败!", ""));
  8728. }
  8729. catch (Exception ex)
  8730. {
  8731. return Ok(JsonView(400, ex.Message, ""));
  8732. }
  8733. }
  8734. /// <summary>
  8735. /// 获取三公费用标准city
  8736. /// </summary>
  8737. /// <param name="placeData"></param>
  8738. /// <param name="nationalTravelFeeId"></param>
  8739. /// <returns></returns>
  8740. private static string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  8741. {
  8742. string _city = string.Empty;
  8743. if (placeData.Count < 1) return _city;
  8744. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  8745. if (data == null) return _city;
  8746. string country = data.Country;
  8747. string city = data.City;
  8748. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  8749. else _city = city;
  8750. return _city;
  8751. }
  8752. ///// <summary>
  8753. ///// 团组模块 - 出入境费用 - 明细表导出
  8754. ///// </summary>
  8755. ///// <returns></returns>
  8756. //[HttpPost]
  8757. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8758. //public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  8759. //{
  8760. // var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  8761. // if (data.Code != 0)
  8762. // {
  8763. // return Ok(JsonView(false, data.Msg));
  8764. // }
  8765. // return Ok(JsonView(true, data.Msg, data.Data));
  8766. //}
  8767. /// <summary>
  8768. /// 团组模块 - 出入境费用 - 一键清空
  8769. /// </summary>
  8770. /// <returns></returns>
  8771. [HttpPost]
  8772. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  8773. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8774. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  8775. {
  8776. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  8777. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  8778. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  8779. var _view = await _enterExitCostRep.OneClickClear(dto.Id, dto.DiId, dto.UserId);
  8780. await _sqlSugar.Updateable<Grp_DayOtherPrice>()
  8781. .Where(x => x.Diid == dto.DiId && x.IsDel == 0)
  8782. .SetColumns(x => new Grp_DayOtherPrice
  8783. {
  8784. IsDel = 1,
  8785. DeleteUserId = dto.UserId,
  8786. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  8787. })
  8788. .ExecuteCommandAsync();
  8789. if (_view.Code == 0)
  8790. {
  8791. return Ok(JsonView(true, "操作成功"));
  8792. }
  8793. return Ok(JsonView(false, "操作失败"));
  8794. }
  8795. /// <summary>
  8796. /// 团组模块 - 出入境费用 - 子项删除
  8797. /// </summary>
  8798. /// <returns></returns>
  8799. [HttpPost]
  8800. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  8801. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8802. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  8803. {
  8804. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  8805. if (data.Code != 0)
  8806. {
  8807. return Ok(JsonView(false, data.Msg));
  8808. }
  8809. return Ok(JsonView(true, "操作成功!", data.Data));
  8810. }
  8811. /// <summary>
  8812. /// 删除三公其他费用
  8813. /// </summary>
  8814. /// <param name="dto"></param>
  8815. /// <returns></returns>
  8816. [HttpPost]
  8817. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  8818. public IActionResult DeleteOtherExpenses(EnterExitCostSubItemDelDto dto)
  8819. {
  8820. var jw = JsonView(false, "删除失败!");
  8821. var data = new Grp_DayOtherPrice()
  8822. {
  8823. Id = dto.Id,
  8824. IsDel = 1,
  8825. DeleteUserId = dto.DeleteUserId,
  8826. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  8827. };
  8828. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  8829. if (del > 0)
  8830. {
  8831. jw.Code = 200;
  8832. jw.Msg = "删除成功!";
  8833. }
  8834. return Ok(jw);
  8835. }
  8836. /// <summary>
  8837. /// 团组模块 - 出入境国家费用标准 List
  8838. /// </summary>
  8839. /// <returns></returns>
  8840. [HttpPost]
  8841. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8842. public async Task<IActionResult> GetNationalTravelFeeData(NationalTravelFeeDataDto dto)
  8843. {
  8844. int provinceId = dto.ProvinceId;
  8845. if (provinceId < 1) provinceId = 122; //默认四川省数据
  8846. var nftData = await _sqlSugar
  8847. .Queryable<Grp_NationalTravelFee, Sys_SetData, Sys_Users, Sys_Cities>((ntf, sd1, u, c) => new JoinQueryInfos(
  8848. JoinType.Left, ntf.Currency == sd1.Id,
  8849. JoinType.Left, ntf.LastUpdateUserId == u.Id,
  8850. JoinType.Left, ntf.ProvinceId == c.Id
  8851. ))
  8852. .Where((ntf, sd1, u, c) => ntf.IsDel == 0 && ntf.ProvinceId == provinceId)
  8853. .Select((ntf, sd1, u, c) => new NationalTravelFeeInfoView
  8854. {
  8855. Id = ntf.Id,
  8856. ProvinceId = ntf.ProvinceId,
  8857. ProvinceName = c.Name_CN,
  8858. Continent = ntf.Continent,
  8859. Country = ntf.Country,
  8860. City = ntf.City,
  8861. Currency = ntf.Currency,
  8862. CurrencyCode = sd1.Name,
  8863. CurrencyName = sd1.Remark,
  8864. RoomCost = ntf.RoomCost,
  8865. FoodCost = ntf.FoodCost,
  8866. PublicCost = ntf.PublicCost,
  8867. LastUpdateUserId = ntf.LastUpdateUserId,
  8868. LastUpdateUserName = u.CnName,
  8869. LastUpdateTime = ntf.LastUpdateTime
  8870. })
  8871. .ToListAsync();
  8872. return Ok(JsonView(true, "查询成功!", nftData));
  8873. }
  8874. /// <summary>
  8875. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  8876. /// </summary>
  8877. /// <returns></returns>
  8878. [HttpPost]
  8879. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8880. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  8881. {
  8882. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  8883. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  8884. List<string> countryData = new List<string>();
  8885. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country!).ToList());
  8886. countryData = countryData.Distinct().ToList();
  8887. List<dynamic> dataSource = new List<dynamic>();
  8888. foreach (var item in countryData)
  8889. {
  8890. var cityData1 = new List<string>();
  8891. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City ?? "").ToList();
  8892. var countryData2 = new
  8893. {
  8894. CountryName = item,
  8895. CityData = cityData1
  8896. };
  8897. if (!dataSource.Contains(countryData2))
  8898. {
  8899. dataSource.Add(countryData2);
  8900. }
  8901. }
  8902. return Ok(JsonView(true, "查询成功!", dataSource));
  8903. }
  8904. /// <summary>
  8905. /// 团组模块 - 出入境国家费用标准 Page List
  8906. /// </summary>
  8907. /// <returns></returns>
  8908. [HttpPost]
  8909. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8910. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  8911. {
  8912. int portId = dto.PortType,
  8913. pageIndex = dto.PageIndex,
  8914. pageSize = dto.PageSize;
  8915. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  8916. if (pageIndex == 0) pageIndex = 1;
  8917. if (pageSize == 0) pageSize = 10;
  8918. RefAsync<int> total = 0;
  8919. var nationalTravelFeeData = await _sqlSugar
  8920. .Queryable<Grp_NationalTravelFee, Sys_SetData, Sys_Users, Sys_Cities>((ntf, sd1, u, sd2) => new JoinQueryInfos(
  8921. JoinType.Left, ntf.Currency == sd1.Id,
  8922. JoinType.Left, ntf.LastUpdateUserId == u.Id,
  8923. JoinType.Left, ntf.ProvinceId == sd2.Id
  8924. ))
  8925. .Where((ntf, sd1, u, sd2) => ntf.IsDel == 0)
  8926. .WhereIF(dto.ProvinceId > 0, (ntf, sd1, u, sd2) => ntf.ProvinceId == dto.ProvinceId)
  8927. .WhereIF(!string.IsNullOrEmpty(dto.Country), (ntf, sd1, u, sd2) => ntf.Country.Contains(dto.Country))
  8928. .WhereIF(!string.IsNullOrEmpty(dto.City), (ntf, sd1, u, sd2) => ntf.City.Contains(dto.City))
  8929. .OrderByDescending((ntf, sd1, u, sd2) => ntf.LastUpdateTime)
  8930. .Select((ntf, sd1, u, sd2) => new NationalTravelFeePageInfoView
  8931. {
  8932. RowNumber = SqlFunc.RowNumber($"{ntf.LastUpdateTime} Desc"),
  8933. Id = ntf.Id,
  8934. ProvinceId = ntf.ProvinceId,
  8935. ProvinceName = sd2.Name_CN,
  8936. Continent = ntf.Continent,
  8937. Country = ntf.Country,
  8938. City = ntf.City,
  8939. Currency = ntf.Currency,
  8940. CurrencyCode = sd1.Name,
  8941. CurrencyName = sd1.Remark,
  8942. RoomCost = ntf.RoomCost,
  8943. FoodCost = ntf.FoodCost,
  8944. PublicCost = ntf.PublicCost,
  8945. LastUpdateUserId = ntf.LastUpdateUserId,
  8946. LastUpdateUserName = u.CnName,
  8947. LastUpdateTime = ntf.LastUpdateTime,
  8948. Remark = ntf.Remark
  8949. })
  8950. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  8951. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  8952. }
  8953. /// <summary>
  8954. /// 团组模块 - 出入境国家费用标准 根据城市查询
  8955. /// </summary>
  8956. /// <returns></returns>
  8957. [HttpPost]
  8958. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8959. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  8960. {
  8961. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  8962. int portId = dto.PortType;
  8963. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  8964. string whereSql = string.Empty;
  8965. if (!string.IsNullOrEmpty(dto.Country))
  8966. {
  8967. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  8968. }
  8969. if (!string.IsNullOrEmpty(dto.City))
  8970. {
  8971. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  8972. }
  8973. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  8974. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,gntf.TrainCost,
  8975. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  8976. From Grp_NationalTravelFee gntf
  8977. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  8978. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  8979. Where gntf.Isdel = 0 {0} ", whereSql);
  8980. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  8981. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  8982. }
  8983. /// <summary>
  8984. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  8985. /// </summary>
  8986. /// <returns></returns>
  8987. [HttpPost]
  8988. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8989. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  8990. {
  8991. return Ok(await _enterExitCostRep.PostNationalTravelFeeOperate(dto));
  8992. }
  8993. /// <summary>
  8994. /// 团组模块 - 出入境国家费用标准 - Del
  8995. /// </summary>
  8996. /// <returns></returns>
  8997. [HttpPost]
  8998. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8999. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  9000. {
  9001. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  9002. {
  9003. Id = dto.Id,
  9004. DeleteUserId = dto.DeleteUserId,
  9005. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  9006. IsDel = 1
  9007. };
  9008. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  9009. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  9010. .WhereColumns(it => new { it.Id })
  9011. .ExecuteCommandAsync();
  9012. if (delStatus <= 0)
  9013. {
  9014. return Ok(JsonView(false, "删除失败!"));
  9015. }
  9016. return Ok(JsonView(true, "操作成功!"));
  9017. }
  9018. /// <summary>
  9019. /// 团组模块 - 出入境国家费用标准 - 费用导入收款账单
  9020. /// 注:Get 请求Headers 加 Token
  9021. /// </summary>
  9022. /// <param name="groupId"></param>
  9023. /// <returns></returns>
  9024. [HttpGet("{groupId}")]
  9025. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9026. public async Task<IActionResult> NationalTravelFeeImportReceivables(int groupId)
  9027. {
  9028. var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  9029. if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  9030. var data = await GeneralMethod.ReceivablesImportFeeAsync(groupId);
  9031. data.ForEach(x =>
  9032. {
  9033. x.CreateUserId = _currUserInfo.UserId;
  9034. });
  9035. if (data.Any())
  9036. {
  9037. var add = await _sqlSugar.Insertable(data).ExecuteCommandAsync();
  9038. if (add > 0)
  9039. {
  9040. return Ok(JsonView(true, "操作成功!"));
  9041. }
  9042. }
  9043. return Ok(JsonView(false, "未操作!"));
  9044. }
  9045. #endregion
  9046. #region 团组经理模块 出入境费用-草稿
  9047. /// <summary>
  9048. /// 团组模块 - 出入境费用-草稿 - 基础数据源 - 省份归属
  9049. /// </summary>
  9050. /// <returns></returns>
  9051. [HttpGet]
  9052. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9053. public async Task<IActionResult> EnterExitDraftProvBelongCostDataSource()
  9054. {
  9055. var provData = await _groupRepository.ProvinceBasicSource();
  9056. return Ok(JsonView(true, "查询成功!", provData));
  9057. }
  9058. /// <summary>
  9059. /// 团组模块 - 出入境费用-草稿 - 文件类型list 根据省份Id获取
  9060. /// </summary>
  9061. /// <returns></returns>
  9062. [HttpGet("{provinceId}")]
  9063. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9064. public async Task<IActionResult> EnterExitCostDraftFileOwner([FromRoute] int provinceId = 122)
  9065. {
  9066. //验证城市归属并给默认值
  9067. if (provinceId < 1) provinceId = 122;
  9068. /*
  9069. * 122 四川
  9070. * 108 贵州
  9071. * 103 重庆
  9072. * 132 云南
  9073. */
  9074. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostDraftRep.FileOwner(provinceId);
  9075. return Ok(JsonView(true, "查询成功!", new
  9076. {
  9077. WordTypeData = wordTypeData,
  9078. ExcelTypeData = excelTypeData,
  9079. }));
  9080. }
  9081. /// <summary>
  9082. /// 团组模块 - 出入境费用-草稿 - 基础数据源(团组名称/币种类型)
  9083. /// </summary>
  9084. /// <returns></returns>
  9085. [HttpPost]
  9086. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9087. public async Task<IActionResult> EnterExitCostDraftDataSource(EnterExitCostDraftDataSourceDto dto)
  9088. {
  9089. var draftNameDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  9090. .Where(x => x.IsDel == 0)
  9091. .OrderByDescending(x => x.CreateTime)
  9092. .Select(x => new { x.Id, x.DraftName })
  9093. .ToListAsync();
  9094. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  9095. //SetDataInfoView
  9096. var dataSource = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  9097. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  9098. var _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  9099. int provinceId = dto.ProvinceId;
  9100. if (provinceId < 1) provinceId = 122;
  9101. /*
  9102. * 122 四川
  9103. * 108 贵州
  9104. * 103 重庆
  9105. * 132 云南
  9106. */
  9107. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostRep.FileOwner(provinceId);
  9108. //默认币种显示
  9109. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  9110. var viewPermissionData = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  9111. return Ok(JsonView(true, "查询成功!", new
  9112. {
  9113. DraftNameDatas = draftNameDatas,
  9114. CurrencyData = _CurrencyData,
  9115. WordTypeData = wordTypeData,
  9116. ExcelTypeData = excelTypeData,
  9117. CurrencyInit = _currencyInfos,
  9118. ViewPermissionData = viewPermissionData
  9119. }));
  9120. }
  9121. /// <summary>
  9122. /// 团组模块 - 出入境费用-草稿
  9123. /// 实时汇率 tips
  9124. /// 机票费用 tips
  9125. /// </summary>
  9126. /// <returns></returns>
  9127. [HttpPost]
  9128. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9129. public async Task<IActionResult> EnterExitCostDraftCorrelationTips(EnterExitCostDraftCorrelationTipsDto dto)
  9130. {
  9131. //var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  9132. return Ok(JsonView(true, "查询成功!", new
  9133. {
  9134. //GroupNameData = groupNameData.Data,
  9135. //visaData = visaData.Data,
  9136. //airData = airData.Data,
  9137. reteInfos = await GeneralMethod.EnterExitCostLiveRate()
  9138. }));
  9139. }
  9140. /// <summary>
  9141. /// 团组模块 - 出入境费用-草稿
  9142. /// 签证费用 tips
  9143. /// </summary>
  9144. /// <returns></returns>
  9145. [HttpPost]
  9146. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9147. public async Task<IActionResult> EnterExitCostDraftVisaTips(EnterExitCostDraftVisaTipsDto dto)
  9148. {
  9149. //if (dto.DraftId < 1) return Ok(JsonView(false,MsgTips.Id));
  9150. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9151. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  9152. .Select(x => x.NationalTravelFeeId)
  9153. .Distinct()
  9154. .ToListAsync();
  9155. //if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  9156. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  9157. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  9158. .Select(x => x.Country)
  9159. .Distinct()
  9160. .ToArrayAsync();
  9161. //if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  9162. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  9163. return Ok(JsonView(true, "查询成功!", new
  9164. {
  9165. totalAmt,
  9166. remark
  9167. }));
  9168. }
  9169. /// <summary>
  9170. /// 团组模块 - 出入境费用-草稿 - Info
  9171. /// </summary>
  9172. /// <returns></returns>
  9173. [HttpPost]
  9174. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Details)]
  9175. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9176. public async Task<IActionResult> EnterExitCostDraftInfoById(EnterExitCostDraftInfoByIdDto dto)
  9177. {
  9178. return Ok(await _enterExitCostDraftRep.EnterExitCostDraftInfoById(dto));
  9179. }
  9180. /// <summary>
  9181. /// 团组模块 - 出入境费用-草稿 - 设置view权限
  9182. /// </summary>
  9183. /// <returns></returns>
  9184. [HttpPost]
  9185. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9186. public async Task<IActionResult> EnterExitCostDraftSetViewPermissiion(EnterExitCostDraftSetViewPermissiionDto dto)
  9187. {
  9188. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9189. if (dto.DraftId < 1) return Ok(JsonView(false, "请传入有效的DraftId;"));
  9190. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  9191. var permissions = new List<Grp_EnterExitCostDraftPermission>();
  9192. foreach (var userId in dto.UserIds)
  9193. {
  9194. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  9195. }
  9196. if (permissions.Any())
  9197. {
  9198. _sqlSugar.BeginTran();
  9199. try
  9200. {
  9201. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  9202. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  9203. if (result < 1)
  9204. {
  9205. _sqlSugar.RollbackTran();
  9206. return Ok(JsonView(false));
  9207. }
  9208. }
  9209. catch (Exception ex)
  9210. {
  9211. _sqlSugar.RollbackTran();
  9212. return Ok(JsonView(false, ex.Message));
  9213. }
  9214. _sqlSugar.CommitTran();
  9215. return Ok(JsonView(true));
  9216. }
  9217. return Ok(JsonView(false));
  9218. }
  9219. /// <summary>
  9220. /// 团组模块 - 出入境费用-草稿 - Add And Update
  9221. /// </summary>
  9222. /// <returns></returns>
  9223. [HttpPost]
  9224. [ApiLog("Grp_EnterExitCostDraft", OperationEnum.Add)]
  9225. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9226. public async Task<IActionResult> EnterExitCostDraftOp(EnterExitCostDraftOpDto dto)
  9227. {
  9228. var data = await _enterExitCostDraftRep.EnterExitCostDraftOp(dto);
  9229. if (data.Code != 0)
  9230. {
  9231. return Ok(JsonView(false, data.Msg));
  9232. }
  9233. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  9234. //汇率信息记录
  9235. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  9236. return Ok(JsonView(true, data.Msg, data.Data));
  9237. }
  9238. /// <summary>
  9239. /// 团组模块 - 出入境费用-草稿 - File downlaod
  9240. /// </summary>
  9241. /// <param name="dto"></param>
  9242. /// <returns></returns>
  9243. [HttpPost]
  9244. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Download)]
  9245. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9246. public async Task<IActionResult> EnterExitCostDraftDownload(EnterExitCostDraftDownloadDto dto)
  9247. {
  9248. try
  9249. {
  9250. var id = dto.Id;
  9251. if (id < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  9252. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  9253. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  9254. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  9255. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  9256. 3 团组成员名单 1 团组成员名单", ""));
  9257. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(it => it.IsDel == 0 && it.Id == id).OrderByDescending(x => x.CreateTime).First();
  9258. if (_EnterExitCosts == null) return Ok(JsonView(400, "未填写出入境费用-草稿;", ""));
  9259. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(it => it.IsDel == 0 && it.ParentId == id).ToList();
  9260. var countryIds = _DayAndCosts.Select(x => x.NationalTravelFeeId).ToList();
  9261. var nationalTravelFeeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0 && countryIds.Contains(it.Id)).ToList();
  9262. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  9263. //数据源
  9264. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  9265. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  9266. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  9267. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  9268. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  9269. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  9270. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  9271. .Where((x, a, b) => x.IsDel == 0 && x.ParentId == id)
  9272. .Select((x, a, b) => new
  9273. {
  9274. x.Index,
  9275. itemName = a.Name,
  9276. CurrencyStr = b.Name,
  9277. x.Cost,
  9278. x.SubTotal,
  9279. x.Remark
  9280. })
  9281. .OrderBy((x) => x.Index)
  9282. .ToList(); //其他款项费用
  9283. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  9284. var peiceItemCurrencys = new List<string>();
  9285. if (_DayAndCosts.Any())
  9286. {
  9287. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  9288. if (currencyIds.Any()) peiceItemCurrencys.AddRange(_CurrDatas.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  9289. }
  9290. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  9291. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  9292. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  9293. {
  9294. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  9295. }
  9296. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  9297. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  9298. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  9299. if (dto.ExportType == 1) //明细表
  9300. {
  9301. if (dto.SubTypeId == 1005) //1005(默认明细表)
  9302. {
  9303. //获取模板
  9304. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  9305. //载入模板
  9306. Document doc = new Document(tempPath);
  9307. DocumentBuilder builder = new DocumentBuilder(doc);
  9308. //利用键值对存放数据
  9309. Dictionary<string, string> dic = new Dictionary<string, string>();
  9310. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  9311. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  9312. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  9313. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  9314. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  9315. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  9316. //境内费用(其他费用)
  9317. if (_EnterExitCosts.ChoiceOne == 1)
  9318. {
  9319. string row1_1 = "";
  9320. if (_EnterExitCosts.Visa > 0)
  9321. {
  9322. //insidePayTotal += _EnterExitCosts.Visa;
  9323. row1_1 = $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  9324. //if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  9325. //{
  9326. // row1_1 += $"\t签证费用描述: {_EnterExitCosts.VisaRemark} 人民币/人";
  9327. //}
  9328. }
  9329. string row1_2 = "";
  9330. if (_EnterExitCosts.YiMiao > 0)
  9331. {
  9332. //insidePayTotal += _EnterExitCosts.YiMiao;
  9333. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  9334. }
  9335. if (_EnterExitCosts.HeSuan > 0)
  9336. {
  9337. //insidePayTotal += _EnterExitCosts.HeSuan;
  9338. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  9339. }
  9340. if (_EnterExitCosts.Service > 0)
  9341. {
  9342. //insidePayTotal += _EnterExitCosts.Service;
  9343. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  9344. }
  9345. string row1_3 = "";
  9346. if (_EnterExitCosts.Safe > 0)
  9347. {
  9348. //insidePayTotal += _EnterExitCosts.Safe;
  9349. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  9350. }
  9351. if (_EnterExitCosts.Ticket > 0)
  9352. {
  9353. //insidePayTotal += _EnterExitCosts.Ticket;
  9354. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  9355. }
  9356. string row1 = "";
  9357. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  9358. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  9359. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  9360. row1 += $"备注:{_EnterExitCosts.Remark}";
  9361. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  9362. dic.Add("Row1Str", row1);
  9363. }
  9364. string airTotalStr = string.Empty,
  9365. airPriceStr = string.Empty;
  9366. //经济舱
  9367. if (_EnterExitCosts.SumJJC == 1)
  9368. {
  9369. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  9370. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  9371. }
  9372. //公务舱
  9373. if (_EnterExitCosts.SumGWC == 1)
  9374. {
  9375. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  9376. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  9377. }
  9378. //头等舱
  9379. if (_EnterExitCosts.SumTDC == 1)
  9380. {
  9381. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  9382. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  9383. }
  9384. //汇率描述
  9385. string rateStr = "";
  9386. if (peiceItemCurrencyInfos.Any())
  9387. {
  9388. rateStr = "\r\n汇率描述:";
  9389. foreach (var item in peiceItemCurrencyInfos)
  9390. {
  9391. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate.ToString("#0.0000")} ";
  9392. }
  9393. }
  9394. string twoItemRemark = "备注:";
  9395. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  9396. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  9397. dic.Add("AirTotalStr", airTotalStr);
  9398. dic.Add("AirPriceStr", airPriceStr);
  9399. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  9400. dic.Add("TwoItemRemark", twoItemRemark);
  9401. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  9402. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  9403. int table1Row = 0,
  9404. table2Row = 0,
  9405. table3Row = 0,
  9406. table4Row = 0,
  9407. table5Row = 0;
  9408. //住宿费
  9409. if (_EnterExitCosts.ChoiceThree == 1)
  9410. {
  9411. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  9412. table1Row = dac1.Count;
  9413. #region 填充word表格内容
  9414. for (int i = 0; i < dac1.Count; i++)
  9415. {
  9416. var dac = dac1[i];
  9417. if (dac == null) continue;
  9418. builder.MoveToCell(0, i, 0, 0);
  9419. builder.Write("第" + dac.Days.ToString() + "晚:");
  9420. builder.MoveToCell(0, i, 1, 0);
  9421. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  9422. //builder.Write(dac.Place == null ? "" : dac.Place);
  9423. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  9424. builder.MoveToCell(0, i, 2, 0);
  9425. builder.Write("费用标准:");
  9426. string curr = "";
  9427. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  9428. if (currData != null)
  9429. {
  9430. curr = currData.Name;
  9431. }
  9432. builder.MoveToCell(0, i, 3, 0);
  9433. builder.Write(dac.Cost.ToString("#0.00") + curr);
  9434. builder.MoveToCell(0, i, 4, 0);
  9435. builder.Write("费用小计:");
  9436. builder.MoveToCell(0, i, 5, 0);
  9437. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  9438. }
  9439. #endregion
  9440. }
  9441. else dic.Add("SubZS", "0.00");
  9442. //删除多余行
  9443. while (table1.Rows.Count > table1Row)
  9444. {
  9445. table1.Rows.RemoveAt(table1Row);
  9446. }
  9447. //伙食费
  9448. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  9449. if (_EnterExitCosts.ChoiceFour == 1)
  9450. {
  9451. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  9452. table2Row = dac2.Count;
  9453. #region 填充word表格内容
  9454. for (int i = 0; i < dac2.Count; i++)
  9455. {
  9456. var dac = dac2[i];
  9457. if (dac == null) continue;
  9458. builder.MoveToCell(1, i, 0, 0);
  9459. builder.Write("第" + dac.Days.ToString() + "天:");
  9460. builder.MoveToCell(1, i, 1, 0);
  9461. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  9462. builder.MoveToCell(1, i, 2, 0);
  9463. builder.Write("费用标准:");
  9464. string curr = "";
  9465. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  9466. if (currData != null)
  9467. {
  9468. curr = currData.Name;
  9469. }
  9470. builder.MoveToCell(1, i, 3, 0);
  9471. builder.Write(dac.Cost.ToString("#0.00") + curr);
  9472. builder.MoveToCell(1, i, 4, 0);
  9473. builder.Write("费用小计:");
  9474. builder.MoveToCell(1, i, 5, 0);
  9475. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  9476. }
  9477. #endregion
  9478. }
  9479. else dic.Add("SubHS", "0.00");
  9480. //删除多余行
  9481. while (table2.Rows.Count > table2Row)
  9482. {
  9483. table2.Rows.RemoveAt(table2Row);
  9484. }
  9485. //公杂费
  9486. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  9487. if (_EnterExitCosts.ChoiceFive == 1)
  9488. {
  9489. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  9490. table3Row = dac3.Count;
  9491. #region 填充word表格内容
  9492. for (int i = 0; i < dac3.Count; i++)
  9493. {
  9494. var dac = dac3[i];
  9495. if (dac == null) continue;
  9496. builder.MoveToCell(2, i, 0, 0);
  9497. builder.Write("第" + dac.Days.ToString() + "天:");
  9498. builder.MoveToCell(2, i, 1, 0);
  9499. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  9500. builder.MoveToCell(2, i, 2, 0);
  9501. builder.Write("费用标准:");
  9502. string curr = "";
  9503. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  9504. if (currData != null)
  9505. {
  9506. curr = currData.Name;
  9507. }
  9508. builder.MoveToCell(2, i, 3, 0);
  9509. builder.Write(dac.Cost.ToString("#0.00") + curr);
  9510. builder.MoveToCell(2, i, 4, 0);
  9511. builder.Write("费用小计:");
  9512. builder.MoveToCell(2, i, 5, 0);
  9513. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  9514. }
  9515. //删除多余行
  9516. while (table3.Rows.Count > table3Row)
  9517. {
  9518. table3.Rows.RemoveAt(table3Row);
  9519. }
  9520. #endregion
  9521. }
  9522. else dic.Add("SubGZF", "0.00");
  9523. //删除多余行
  9524. while (table3.Rows.Count > table3Row)
  9525. {
  9526. table3.Rows.RemoveAt(table3Row);
  9527. }
  9528. //培训费
  9529. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  9530. if (_EnterExitCosts.ChoiceSix == 1)
  9531. {
  9532. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  9533. dic.Add("SubPX", pxStr);
  9534. table4Row = dac4.Count;
  9535. #region 填充word表格内容
  9536. for (int i = 0; i < dac4.Count; i++)
  9537. {
  9538. var dac = dac4[i];
  9539. if (dac == null) continue;
  9540. builder.MoveToCell(3, i, 0, 0);
  9541. builder.Write("第" + dac.Days.ToString() + "天:");
  9542. builder.MoveToCell(3, i, 1, 0);
  9543. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  9544. builder.MoveToCell(3, i, 2, 0);
  9545. builder.Write("费用标准:");
  9546. string curr = "";
  9547. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  9548. if (currData != null)
  9549. {
  9550. curr = currData.Name;
  9551. }
  9552. builder.MoveToCell(3, i, 3, 0);
  9553. builder.Write(dac.Cost.ToString("#0.00") + curr);
  9554. builder.MoveToCell(3, i, 4, 0);
  9555. builder.Write("费用小计:");
  9556. builder.MoveToCell(3, i, 5, 0);
  9557. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  9558. }
  9559. #endregion
  9560. }
  9561. //else dic.Add("SubPX", $"六、培训费合计: 0 元/人");
  9562. //删除多余行
  9563. while (table4.Rows.Count > table4Row)
  9564. {
  9565. table4.Rows.RemoveAt(table4Row);
  9566. }
  9567. //其他费用
  9568. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  9569. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  9570. {
  9571. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  9572. dic.Add("titleQi", qtStr);
  9573. table5Row = dac5.Count;
  9574. #region 填充word表格内容
  9575. for (int i = 0; i < dac5.Count; i++)
  9576. {
  9577. var dac = dac5[i];
  9578. if (dac == null) continue;
  9579. builder.MoveToCell(4, i, 0, 0);
  9580. builder.Write("第" + dac.Index.ToString() + "项:");
  9581. builder.MoveToCell(4, i, 1, 0);
  9582. builder.Write(dac.itemName);
  9583. builder.MoveToCell(4, i, 2, 0);
  9584. builder.Write("费用标准:");
  9585. builder.MoveToCell(4, i, 3, 0);
  9586. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  9587. builder.MoveToCell(4, i, 4, 0);
  9588. builder.Write("费用小计:");
  9589. builder.MoveToCell(4, i, 5, 0);
  9590. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  9591. builder.MoveToCell(4, i, 6, 0);
  9592. builder.Write("备注:");
  9593. builder.MoveToCell(4, i, 7, 0);
  9594. builder.Write(dac.Remark);
  9595. }
  9596. #endregion
  9597. }
  9598. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  9599. //删除多余行
  9600. while (table5.Rows.Count > table5Row)
  9601. {
  9602. table5.Rows.RemoveAt(table5Row);
  9603. }
  9604. //加上其他费用
  9605. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  9606. decimal subJJC = 0.00M,
  9607. subGWC = 0.00M,
  9608. subTDC = 0.00M;
  9609. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  9610. string totalLabel = string.Format("全部费用总计:");
  9611. //经济舱
  9612. if (_EnterExitCosts.SumJJC == 1)
  9613. {
  9614. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  9615. totalLabel += $"{subJJC.ToString("#0.00")} 元/人(经济舱)";
  9616. }
  9617. //公务舱
  9618. if (_EnterExitCosts.SumGWC == 1)
  9619. {
  9620. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  9621. totalLabel += $"{subGWC.ToString("#0.00")} 元/人(公务舱)";
  9622. }
  9623. //头等舱
  9624. if (_EnterExitCosts.SumTDC == 1)
  9625. {
  9626. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  9627. totalLabel += $"{subTDC.ToString("#0.00")} 元/人(头等舱)";
  9628. }
  9629. //TotalLabel
  9630. dic.Add("TotalLabel", totalLabel);
  9631. #region 填充word模板书签内容
  9632. foreach (var key in dic.Keys)
  9633. {
  9634. Bookmark bookmark = doc.Range.Bookmarks[key];
  9635. if (bookmark != null)
  9636. {
  9637. builder.MoveToBookmark(key);
  9638. builder.Write(dic[key]);
  9639. }
  9640. }
  9641. #endregion
  9642. //文件名
  9643. string strFileName = $"{_EnterExitCosts.DraftName}_出入境费用-草稿{Guid.NewGuid().ToString()}.docx";
  9644. strFileName = CommonFun.ValidFileName(strFileName);
  9645. AsposeHelper.removewatermark_v2180();
  9646. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  9647. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  9648. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  9649. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  9650. }
  9651. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  9652. {
  9653. //获取模板
  9654. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  9655. //载入模板
  9656. Document doc = new Document(tempPath);
  9657. DocumentBuilder builder = new DocumentBuilder(doc);
  9658. Dictionary<string, string> dic = new Dictionary<string, string>();
  9659. string returnCodeLabel = string.Empty;
  9660. if (nationalTravelFeeData.Any())
  9661. {
  9662. List<string> list = new List<string>();
  9663. foreach (var item in nationalTravelFeeData)
  9664. {
  9665. list.Add($"{item.Country}({item.City})");
  9666. }
  9667. list = list.Distinct().ToList();
  9668. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  9669. }
  9670. var countryLabel = string.Empty;
  9671. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  9672. if (countryData.Any())
  9673. {
  9674. countryLabel = string.Join("、", countryData);
  9675. }
  9676. dic.Add("ReturnCodeAir", returnCodeLabel);
  9677. dic.Add("VisitStartDate", "-");
  9678. dic.Add("VisitEndDate", "-");
  9679. dic.Add("Day", "-");
  9680. dic.Add("VisitCountry", countryLabel);
  9681. dic.Add("ClientUnit", "-");
  9682. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  9683. //dic.Add("Names", Names);
  9684. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  9685. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  9686. decimal dac1totalPrice = 0.00M;
  9687. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  9688. foreach (var dac in dac1)
  9689. {
  9690. if (dac.SubTotal == 0.00M)
  9691. {
  9692. continue;
  9693. }
  9694. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  9695. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  9696. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  9697. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  9698. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  9699. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  9700. builder.Write(currency);//币种
  9701. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  9702. builder.Write(dac.Cost.ToString("#0.00"));//标准
  9703. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  9704. builder.Write("");//人数
  9705. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  9706. builder.Write("");//天数
  9707. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  9708. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  9709. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  9710. decimal rate = 0.00M;
  9711. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  9712. builder.Write(rate.ToString("#0.0000"));//汇率
  9713. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  9714. decimal rbmPrice = dac.SubTotal;
  9715. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  9716. accommodationStartIndex++;
  9717. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  9718. }
  9719. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  9720. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  9721. {
  9722. table1.Rows.RemoveAt(i - 1);
  9723. foodandotherStartIndex--;
  9724. }
  9725. if (dac2.Count == dac3.Count)//国家 币种 金额
  9726. {
  9727. for (int i = 0; i < dac2.Count; i++)
  9728. {
  9729. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  9730. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  9731. }
  9732. }
  9733. decimal dac2totalPrice = 0.00M;
  9734. foreach (var dac in dac2)
  9735. {
  9736. if (dac.SubTotal == 0)
  9737. {
  9738. continue;
  9739. }
  9740. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  9741. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  9742. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  9743. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  9744. builder.Write(currency);//币种
  9745. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  9746. builder.Write(dac.Cost.ToString("#0.00"));//标准
  9747. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  9748. builder.Write("");//人数
  9749. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  9750. builder.Write("");//天数
  9751. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  9752. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  9753. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  9754. decimal rate = 0.00M;
  9755. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  9756. builder.Write(rate.ToString("#0.0000"));//汇率
  9757. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  9758. decimal rbmPrice = dac.SubTotal;
  9759. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  9760. foodandotherStartIndex++;
  9761. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  9762. }
  9763. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  9764. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  9765. {
  9766. table1.Rows.RemoveAt(i - 1);
  9767. }
  9768. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  9769. string otherFeeStr = "";
  9770. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  9771. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  9772. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  9773. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  9774. foreach (var otherInfo in dac5)
  9775. {
  9776. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  9777. }
  9778. #endregion
  9779. if (otherFeeStr.Length > 0)
  9780. {
  9781. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  9782. otherFeeStr = $"({otherFeeStr})";
  9783. dic.Add("OtherFeeStr", otherFeeStr);
  9784. }
  9785. //总计
  9786. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  9787. //国际旅费
  9788. string outsideAir = string.Empty;
  9789. string allPriceAir = string.Empty;
  9790. if (_EnterExitCosts.SumJJC == 1)
  9791. {
  9792. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  9793. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  9794. }
  9795. if (_EnterExitCosts.SumGWC == 1)
  9796. {
  9797. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  9798. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  9799. }
  9800. if (_EnterExitCosts.SumTDC == 1)
  9801. {
  9802. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  9803. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  9804. }
  9805. dic.Add("InTravelPrice", $"({outsideAir})");
  9806. dic.Add("FinalSumPrice", $"({allPriceAir})");
  9807. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  9808. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  9809. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  9810. foreach (var key in dic.Keys)
  9811. {
  9812. builder.MoveToBookmark(key);
  9813. builder.Write(dic[key]);
  9814. }
  9815. //模板文件名
  9816. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  9817. strFileName = CommonFun.ValidFileName(strFileName);
  9818. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  9819. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  9820. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  9821. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  9822. }
  9823. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  9824. {
  9825. //获取模板
  9826. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  9827. //载入模板
  9828. WorkbookDesigner designer = new WorkbookDesigner();
  9829. designer.Workbook = new Workbook(tempPath);
  9830. Dictionary<string, string> dic = new Dictionary<string, string>();
  9831. string returnCodeLabel = string.Empty;
  9832. if (nationalTravelFeeData.Any())
  9833. {
  9834. List<string> list = new List<string>();
  9835. foreach (var item in nationalTravelFeeData)
  9836. {
  9837. list.Add($"{item.Country}({item.City})");
  9838. }
  9839. list = list.Distinct().ToList();
  9840. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  9841. }
  9842. var countryLabel = string.Empty;
  9843. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  9844. if (countryData.Any())
  9845. {
  9846. countryLabel = string.Join("、", countryData);
  9847. }
  9848. dic.Add("ReturnCodeAir", returnCodeLabel);
  9849. dic.Add("VisitStartDate", "-");
  9850. dic.Add("VisitEndDate", "-");
  9851. dic.Add("Day", "0");
  9852. dic.Add("VisitCountry", countryLabel);
  9853. dic.Add("ClientUnit", "-");
  9854. designer.SetDataSource("ClientUnit", "-");
  9855. designer.SetDataSource("VisitCountry", countryLabel);
  9856. designer.SetDataSource("Group", "-");
  9857. designer.SetDataSource("ClientUnitTitle", "-");
  9858. designer.SetDataSource("Name", "-");
  9859. designer.SetDataSource("VisitStartDate", "-");
  9860. designer.SetDataSource("Day", "0");
  9861. designer.SetDataSource("ReturnCode", returnCodeLabel);
  9862. designer.SetDataSource("ReturnCodeAir", "-");
  9863. int startIndex = 10;
  9864. const int startIndexcopy = 10;
  9865. if (dac2.Count == dac3.Count)//国家 币种 金额
  9866. {
  9867. for (int i = 0; i < dac2.Count; i++)
  9868. {
  9869. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  9870. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  9871. }
  9872. }
  9873. DataTable dtdac1 = new DataTable();
  9874. List<string> place = new List<string>();
  9875. dtdac1.Columns.AddRange(new DataColumn[] {
  9876. new DataColumn(){ ColumnName = "city"},
  9877. new DataColumn(){ ColumnName = "curr"},
  9878. new DataColumn(){ ColumnName = "criterion"},
  9879. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  9880. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  9881. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  9882. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  9883. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  9884. });
  9885. DataTable dtdac2 = new DataTable();
  9886. dtdac2.Columns.AddRange(new DataColumn[] {
  9887. new DataColumn(){ ColumnName = "city"},
  9888. new DataColumn(){ ColumnName = "curr"},
  9889. new DataColumn(){ ColumnName = "criterion"},
  9890. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  9891. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  9892. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  9893. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  9894. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  9895. });
  9896. dtdac1.TableName = "tb1";
  9897. dtdac2.TableName = "tb2";
  9898. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  9899. foreach (var item in dac1)
  9900. {
  9901. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  9902. if (place.Contains(item.Place))
  9903. {
  9904. continue;
  9905. }
  9906. DataRow row = dtdac1.NewRow();
  9907. row["city"] = item.Place;
  9908. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  9909. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  9910. row["curr"] = currency;
  9911. row["rate"] = rate.ToString("#0.0000");
  9912. row["criterion"] = item.Cost.ToString("#0.00");
  9913. row["number"] = 1;
  9914. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  9915. //row["costRMB"] = rbmPrice;
  9916. dtdac1.Rows.Add(row);
  9917. place.Add(item.Place);
  9918. }
  9919. place = new List<string>();
  9920. foreach (var item in dac2)
  9921. {
  9922. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  9923. if (place.Contains(item.Place))
  9924. {
  9925. continue;
  9926. }
  9927. DataRow row = dtdac2.NewRow();
  9928. row["city"] = item.Place;
  9929. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  9930. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  9931. row["curr"] = currency;
  9932. row["rate"] = rate.ToString("#0.0000");
  9933. row["criterion"] = item.Cost.ToString("#0.00");
  9934. row["number"] = 1;
  9935. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  9936. //row["cost"] = item.SubTotal;
  9937. //row["costRMB"] = rbmPrice;
  9938. dtdac2.Rows.Add(row);
  9939. place.Add(item.Place);
  9940. //dac2totalPrice += rbmPrice;
  9941. }
  9942. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  9943. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  9944. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  9945. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  9946. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic:#0.00} 元");
  9947. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic:#0.00} ");
  9948. string cell4Str1 = string.Empty;
  9949. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ:#0.00} 元/人;";
  9950. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW:#0.00} 元/人;";
  9951. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD:#0.00} 元/人;";
  9952. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  9953. string cellStr = $" 5.其他费用(";
  9954. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  9955. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  9956. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  9957. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  9958. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  9959. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  9960. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  9961. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  9962. foreach (var otherInfo in dac5)
  9963. {
  9964. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal:#0.00} 元,";
  9965. }
  9966. #endregion
  9967. if (cellStr.Length > 8)
  9968. {
  9969. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  9970. }
  9971. cellStr += ")";
  9972. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  9973. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  9974. decimal pxFee = dac4.Sum(it => it.Cost);
  9975. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  9976. string celllastStr1 = "";
  9977. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice:#0.00} 元";
  9978. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice:#0.00} 元";
  9979. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee:#0.00} 元";
  9980. celllastStr1 += $",国际旅费 元";
  9981. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee:#0.00} 元";
  9982. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  9983. designer.SetDataSource("cell4Str", cell4Str);
  9984. designer.SetDataSource("cellStr", cellStr);
  9985. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  9986. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  9987. designer.SetDataSource("celllastStr", celllastStr);
  9988. Workbook wb = designer.Workbook;
  9989. var sheet = wb.Worksheets[0];
  9990. //绑定datatable数据集
  9991. designer.SetDataSource(dtdac1);
  9992. designer.SetDataSource(dtdac2);
  9993. designer.Process();
  9994. var rowStart = dtdac1.Rows.Count;
  9995. while (rowStart > 0)
  9996. {
  9997. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  9998. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  9999. startIndex++;
  10000. rowStart--;
  10001. }
  10002. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  10003. startIndex += 1; //总计行
  10004. rowStart = dtdac2.Rows.Count;
  10005. while (rowStart > 0)
  10006. {
  10007. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  10008. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  10009. startIndex++;
  10010. rowStart--;
  10011. }
  10012. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  10013. wb.CalculateFormula(true);
  10014. //模板文件名
  10015. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  10016. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  10017. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  10018. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  10019. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  10020. }
  10021. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  10022. {
  10023. //获取模板
  10024. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  10025. //载入模板
  10026. Document doc = new Document(tempPath);
  10027. DocumentBuilder builder = new DocumentBuilder(doc);
  10028. Dictionary<string, string> dic = new Dictionary<string, string>();
  10029. dic.Add("GroupName", "-");
  10030. dic.Add("ClientUnit", "-");
  10031. //string missionLeader = ""; //团负责人默认接团客户名单第一个人
  10032. //string missionLeaderJob = "";//负责人job
  10033. //int groupNumber = 0; //团人数
  10034. dic.Add("MissionLeader", "-"); //团负责人
  10035. dic.Add("MissionLeaderJob", "-"); //团负责人job
  10036. dic.Add("GroupNumber", "0"); //团人数
  10037. dic.Add("Day", "0");
  10038. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  10039. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  10040. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  10041. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  10042. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  10043. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  10044. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  10045. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  10046. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  10047. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  10048. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  10049. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  10050. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  10051. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  10052. //其他费用
  10053. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  10054. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  10055. //其他费用合计
  10056. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  10057. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  10058. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  10059. //公务舱合计
  10060. //国际旅费
  10061. //string outsideJJ = "";
  10062. //string allPriceJJ = "";
  10063. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  10064. {
  10065. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  10066. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  10067. }
  10068. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  10069. {
  10070. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  10071. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  10072. }
  10073. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  10074. {
  10075. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ:#0.00} 公务舱:{_EnterExitCosts.AirGW:#0.00}");
  10076. dic.Add("AirFeeTotal", airFeeTotalStr);
  10077. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal:#0.00} 公务舱:{_gwcFeeToatal:#0.00}");
  10078. dic.Add("FeeTotal", feeTotalStr);
  10079. }
  10080. foreach (var key in dic.Keys)
  10081. {
  10082. builder.MoveToBookmark(key);
  10083. builder.Write(dic[key]);
  10084. }
  10085. //模板文件名
  10086. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  10087. strFileName = CommonFun.ValidFileName(strFileName);
  10088. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  10089. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  10090. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  10091. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  10092. }
  10093. }
  10094. else if (dto.ExportType == 2) //表格
  10095. {
  10096. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  10097. }
  10098. else if (dto.ExportType == 3)
  10099. {
  10100. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  10101. }
  10102. return Ok(JsonView(400, "只可导出明细表!", ""));
  10103. }
  10104. catch (Exception ex)
  10105. {
  10106. return Ok(JsonView(400, ex.Message, ""));
  10107. }
  10108. }
  10109. /// <summary>
  10110. /// 获取三公费用标准city
  10111. /// </summary>
  10112. /// <param name="placeData"></param>
  10113. /// <param name="nationalTravelFeeId"></param>
  10114. /// <returns></returns>
  10115. private string GetEnterExitCostDraftExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  10116. {
  10117. string _city = string.Empty;
  10118. if (!placeData.Any()) return _city;
  10119. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  10120. if (data == null) return _city;
  10121. string country = data.Country;
  10122. string city = data.City;
  10123. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  10124. else _city = city;
  10125. return _city;
  10126. }
  10127. /// <summary>
  10128. /// 团组模块 - 出入境费用-草稿 - 一键清空
  10129. /// </summary>
  10130. /// <returns></returns>
  10131. [HttpPost]
  10132. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  10133. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10134. public async Task<IActionResult> EnterExitCostDraftOneClickEmpty(EnterExitCostDraftOneClickEmptyDto dto)
  10135. {
  10136. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  10137. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  10138. var _view = await _enterExitCostDraftRep.OneClickEmpty(dto.Id, dto.UserId);
  10139. if (_view.Code == 0)
  10140. {
  10141. return Ok(JsonView(true, "操作成功"));
  10142. }
  10143. return Ok(JsonView(false, "操作失败"));
  10144. }
  10145. /// <summary>
  10146. /// 团组模块 - 出入境费用-草稿 - 子项删除
  10147. /// </summary>
  10148. /// <returns></returns>
  10149. [HttpPost]
  10150. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  10151. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10152. public async Task<IActionResult> EnterExitCostDraftSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  10153. {
  10154. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  10155. if (data.Code != 0)
  10156. {
  10157. return Ok(JsonView(false, data.Msg));
  10158. }
  10159. return Ok(JsonView(true, "操作成功!", data.Data));
  10160. }
  10161. /// <summary>
  10162. /// 三公其他费用草稿 删除
  10163. /// </summary>
  10164. /// <param name="dto"></param>
  10165. /// <returns></returns>
  10166. [HttpPost]
  10167. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  10168. public IActionResult EnterExitCostDraftOtherExpensesDel(EnterExitCostDraftOtherExpensesDelDto dto)
  10169. {
  10170. var jw = JsonView(false, "删除失败!");
  10171. var data = new Grp_DayOtherPriceDraft()
  10172. {
  10173. Id = dto.Id,
  10174. IsDel = 1,
  10175. DeleteUserId = dto.DeleteUserId,
  10176. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  10177. };
  10178. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  10179. if (del > 0)
  10180. {
  10181. jw.Code = 200;
  10182. jw.Msg = "删除成功!";
  10183. }
  10184. return Ok(jw);
  10185. }
  10186. /// <summary>
  10187. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用基础数据
  10188. /// </summary>
  10189. /// <returns></returns>
  10190. [HttpPost]
  10191. public async Task<IActionResult> EnterExitCostDraftImportDataInit()
  10192. {
  10193. var jw = JsonView(false);
  10194. var groupNameDatas = await _groupRepository.EnterExitCostGroupNameAsync();
  10195. var draftDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0).OrderByDescending(x => x.CreateTime).Select(x => new { x.Id, x.DraftName }).ToListAsync();
  10196. jw.Code = StatusCodes.Status200OK;
  10197. jw.Msg = "操作成功!";
  10198. jw.Data = new { groupNameDatas = groupNameDatas, draftNames = draftDatas };
  10199. return Ok(jw);
  10200. }
  10201. /// <summary>
  10202. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用
  10203. /// </summary>
  10204. /// <param name="dto"></param>
  10205. /// <returns></returns>
  10206. [HttpPost]
  10207. public async Task<IActionResult> EnterExitCostDraftImportData(EnterExitCostDraftImportDataDto dto)
  10208. {
  10209. int userId = dto.UserId,
  10210. portId = dto.PortType,
  10211. groupId = dto.GroupId,
  10212. draftId = dto.DraftId;
  10213. _portTypeData.Add(1);
  10214. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10215. if (!_portTypeData.Contains(portId)) return Ok(JsonView(false, MsgTips.Port));
  10216. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId!"));
  10217. if (draftId < 1) return Ok(JsonView(false, "请传入有效的DraftId!"));
  10218. _sqlSugar.BeginTran();
  10219. try
  10220. {
  10221. var draftDatas = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).First();
  10222. if (draftDatas == null)
  10223. {
  10224. _sqlSugar.RollbackTran();
  10225. return Ok(JsonView(false, "草稿数据为空,不可导入!"));
  10226. }
  10227. //验证可覆盖已有数据 两边创建人需为同一人;
  10228. int draftCreateUserId = draftDatas.CreateUserId,
  10229. formalCreateUserId = 0;
  10230. var formalData = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  10231. if (formalData != null)
  10232. {
  10233. formalCreateUserId = formalData.CreateUserId;
  10234. if (draftCreateUserId != formalCreateUserId)
  10235. {
  10236. _sqlSugar.RollbackTran();
  10237. return Ok(JsonView(false, "由草稿数据到入至正式数据,两边创建人为同一人才可导入正式版!"));
  10238. }
  10239. }
  10240. //默认添加查看、编辑权限(创建人、自己)
  10241. await _enterExitCostRep.InitPerm(dto.GroupId, dto.UserId);
  10242. var dayDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  10243. var otherDatas = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  10244. var newExterData = _mapper.Map<Grp_EnterExitCost>(draftDatas);
  10245. newExterData.DiId = groupId;
  10246. newExterData.CreateUserId = userId;
  10247. newExterData.Remark = $"由草稿数据导入;草稿数Id:{draftId}";
  10248. var newDayDatas = _mapper.Map<List<Grp_DayAndCost>>(dayDatas);
  10249. if (newDayDatas.Any()) newDayDatas.Select(x => { x.DiId = groupId; x.CreateUserId = userId; return x; }).ToList();
  10250. var newOtherDatas = _mapper.Map<List<Grp_DayOtherPrice>>(otherDatas);
  10251. if (newOtherDatas.Any()) newOtherDatas.Select(x => { x.Diid = groupId; x.CreateUserId = userId; return x; }).ToList();
  10252. var enterExitCostInfo = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  10253. //数据如果存在执行删除
  10254. if (enterExitCostInfo != null)
  10255. {
  10256. _sqlSugar.Updateable<Grp_EnterExitCost>()
  10257. .SetColumns(x => new Grp_EnterExitCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Remark = "由草稿数据导入前软删除数据!" })
  10258. .Where(x => x.Id == enterExitCostInfo.Id)
  10259. .ExecuteCommand();
  10260. _sqlSugar.Updateable<Grp_DayAndCost>()
  10261. .SetColumns(x => new Grp_DayAndCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  10262. .Where(x => x.DiId == groupId)
  10263. .ExecuteCommand();
  10264. _sqlSugar.Updateable<Grp_DayOtherPrice>()
  10265. .SetColumns(x => new Grp_DayOtherPrice() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  10266. .Where(x => x.Diid == groupId)
  10267. .ExecuteCommand();
  10268. _sqlSugar.Updateable<Grp_EnterExitCostPermission>()
  10269. .SetColumns(x => new Grp_EnterExitCostPermission() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  10270. .Where(x => x.GroupId == groupId)
  10271. .ExecuteCommand();
  10272. }
  10273. //执行insert
  10274. var insertId = _sqlSugar.Insertable(newExterData).ExecuteReturnIdentity();
  10275. if (insertId < 1)
  10276. {
  10277. _sqlSugar.RollbackTran();
  10278. return Ok(JsonView(false, "草稿数据导入失败!"));
  10279. }
  10280. if (newDayDatas.Any()) _sqlSugar.Insertable(newDayDatas).ExecuteCommand();
  10281. if (newOtherDatas.Any()) _sqlSugar.Insertable(newOtherDatas).ExecuteCommand();
  10282. #region 默认添加权限
  10283. #endregion
  10284. _sqlSugar.CommitTran();
  10285. //执行操作之后
  10286. //生成默认文件pdf并且通知人员
  10287. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  10288. {
  10289. DiId = groupId,
  10290. ExportType = 1,
  10291. SubTypeId = 1005
  10292. }, "pdf");
  10293. //发送通知
  10294. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  10295. string md5Sign = GeneralMethod.Encrypt($"{insertId}&fileName={fileUrl}");
  10296. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", insertId, fileUrl);
  10297. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(groupId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  10298. //汇率信息记录
  10299. await GeneralMethod.RateRecordSave(userId, insertId, "出入境费用-草稿导入");
  10300. return Ok(JsonView(true));
  10301. }
  10302. catch (Exception ex)
  10303. {
  10304. _sqlSugar.RollbackTran();
  10305. return Ok(JsonView(false, ex.Message));
  10306. }
  10307. }
  10308. #endregion
  10309. #region 团组经理模块 出入境费用 移动端(Android/IOS)
  10310. /// <summary>
  10311. /// 获取币种基础数据(含逻辑处理)
  10312. /// </summary>
  10313. /// <returns></returns>
  10314. private async Task<List<CurrencyInfo>> EnterExitCostMobileGetCurrencyInit()
  10315. {
  10316. return await GeneralMethod.EnterExitCostInitRate();
  10317. }
  10318. /// <summary>
  10319. /// 团组模块 - 出入境费用-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  10320. /// </summary>
  10321. /// <returns></returns>
  10322. [HttpPost]
  10323. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10324. public async Task<IActionResult> EnterExitCostMobileDataSource(EnterExitCostMobileDataSourceDto dto)
  10325. {
  10326. //验证城市归属并给默认值
  10327. int provinceId = dto.ProvinceId;
  10328. if (provinceId < 1) provinceId = 122;
  10329. var dataSource = await _sqlSugar
  10330. .Queryable<Sys_SetData>()
  10331. .Where(x => x.IsDel == 0 && (x.STid == 72 || x.STid == 73) && x.Remark.Contains(provinceId.ToString()))
  10332. .ToListAsync();
  10333. var fileTypes = new List<EecSetDataInfoView>();
  10334. //三公费用-Word明细类型
  10335. var wordTypeData = dataSource
  10336. .Where(it => it.STid == 72)
  10337. .Select(x => new EecSetDataInfoView
  10338. {
  10339. ParentId = 1,
  10340. Id = x.Id,
  10341. Name = x.Name
  10342. })
  10343. .ToArray();
  10344. if (wordTypeData.Any()) fileTypes.AddRange(wordTypeData);
  10345. var excelTypeData = dataSource
  10346. .Where(it => it.STid == 73)
  10347. .Select(x => new EecSetDataInfoView
  10348. {
  10349. ParentId = 2,
  10350. Id = x.Id,
  10351. Name = x.Name
  10352. })
  10353. .ToArray();
  10354. if (excelTypeData.Any()) fileTypes.AddRange(excelTypeData);
  10355. var groupNameList = new EecSetDataInfoView() { ParentId = 3, Id = 1, Name = "团组成员名单" };
  10356. fileTypes.Add(groupNameList);
  10357. fileTypes = fileTypes.OrderBy(x => x.ParentId).ThenBy(x => x.Id).ToList();
  10358. //默认币种显示
  10359. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  10360. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  10361. return Ok(JsonView(true, "查询成功!", new
  10362. {
  10363. FileTypeData = fileTypes,
  10364. CurrencyInit = _currencyInfos,
  10365. viewPermissionData = viewPermissionData
  10366. }));
  10367. }
  10368. /// <summary>
  10369. /// 团组模块 - 出入境费用-移动端 - 团组基础数据Data
  10370. /// </summary>
  10371. /// <returns></returns>
  10372. [HttpPost]
  10373. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10374. public async Task<IActionResult> EnterExitCostMobileGroupData(PostEnterExitCostMobileGroupDataDto dto)
  10375. {
  10376. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10377. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10378. RefAsync<int> total = 0;
  10379. int diId = 0;
  10380. var status = int.TryParse(dto.GroupName, out diId);
  10381. var basicUserId = await _enterExitCostRep.PermissionViewUsersAsync();
  10382. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  10383. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  10384. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  10385. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  10386. .OrderByDescending(x => x.VisitStartDate)
  10387. .Select(x => new EnterExitCostMobileGroupView()
  10388. {
  10389. Id = x.Id,
  10390. GroupName = x.TeamName,
  10391. IsNull = SqlFunc.Subqueryable<Grp_EnterExitCost>().Where(x1 => x1.DiId == x.Id && x1.IsDel == 0).Any() ? false : true,
  10392. IsView = SqlFunc.Subqueryable<Grp_EnterExitCostPermission>().Where(x1 => x1.GroupId == x.Id && x1.UserId == dto.CurrUserId).Any(),
  10393. ProvinceId = x.CityId
  10394. })
  10395. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10396. //处理省份Id
  10397. if (data.Any())
  10398. {
  10399. var provCityDatas = await _groupRepository.ProvinceCityBasicSource();
  10400. if (provCityDatas.Any())
  10401. {
  10402. foreach (var item in data)
  10403. {
  10404. var provinceId = item.ProvinceId;
  10405. var isDefualtVal = true;
  10406. if (provinceId > 0)
  10407. {
  10408. var parentId = _groupRepository.FindParentIdByChildId(provCityDatas, provinceId);
  10409. if (parentId != null)
  10410. {
  10411. isDefualtVal = false;
  10412. item.ProvinceId = (int)parentId;
  10413. }
  10414. }
  10415. if (isDefualtVal)
  10416. {
  10417. item.ProvinceId = 122; //默认四川
  10418. }
  10419. }
  10420. }
  10421. }
  10422. //处理是否显示
  10423. if (basicUserId.Any(x => x.Id == dto.CurrUserId))
  10424. {
  10425. foreach (var item in data)
  10426. {
  10427. item.IsView = true;
  10428. }
  10429. }
  10430. return Ok(JsonView(true, "查询成功!", data, total));
  10431. }
  10432. /// <summary>
  10433. /// 团组模块 - 出入境费用-移动端 - 币种基础数据Data
  10434. /// </summary>
  10435. /// <returns></returns>
  10436. [HttpPost]
  10437. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10438. public async Task<IActionResult> EnterExitCostMobileCurrencyData(PostEnterExitCostMobileCurrencyDataDto dto)
  10439. {
  10440. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10441. RefAsync<int> total = 0;
  10442. var data = await _sqlSugar.Queryable<Sys_SetData>()
  10443. .Where(x => x.IsDel == 0 && x.STid == 66)
  10444. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  10445. .Select(x => new
  10446. {
  10447. id = x.Id,
  10448. name = x.Name,
  10449. remark = x.Remark,
  10450. })
  10451. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10452. return Ok(JsonView(true, "查询成功!", data, total));
  10453. }
  10454. /// <summary>
  10455. /// 团组模块 - 出入境费用-移动端 - 其他款项 - 币种、费用类型基础数据Data
  10456. /// </summary>
  10457. /// <returns></returns>
  10458. [HttpPost]
  10459. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10460. public async Task<IActionResult> EnterExitCostMobileOtherItemCurrencyData(PostEnterExitCostMobileOtherItemCurrencyDataDto dto)
  10461. {
  10462. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10463. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10464. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType, dto.DiId, 98);
  10465. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  10466. var groupOtherRateData = groupRateData.TeamRates;
  10467. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  10468. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  10469. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  10470. groupOtherRateData = groupOtherRateData
  10471. .Select(x => new TeamRateDescAddCurrencyIdView
  10472. {
  10473. CurrencyId = x.CurrencyId,
  10474. CurrencyName = x.CurrencyName,
  10475. CurrencyCode = x.CurrencyCode,
  10476. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  10477. }).ToList();
  10478. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  10479. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  10480. }
  10481. /// <summary>
  10482. /// 团组模块 - 出入境费用-移动端 - 实时汇率、签证费用、机票费用 Tips
  10483. /// </summary>
  10484. /// <returns></returns>
  10485. [HttpPost]
  10486. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10487. public async Task<IActionResult> EnterExitCostMobileFeeTips(GetEnterExitCostMobileFeeTipsDto dto)
  10488. {
  10489. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10490. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10491. var tipsData = new List<int>() { 1, 2, 3 };
  10492. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  10493. if (dto.TipsType == 1)
  10494. {
  10495. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  10496. }
  10497. else if (dto.TipsType == 2)
  10498. {
  10499. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.GroupId);
  10500. return Ok(JsonView(true, "查询成功!", visaData.Data));
  10501. }
  10502. else if (dto.TipsType == 3)
  10503. {
  10504. var airData = await GeneralMethod.EntryAndExitTips(dto.GroupId);
  10505. return Ok(JsonView(true, "查询成功!", airData));
  10506. }
  10507. return Ok(JsonView(false));
  10508. }
  10509. /// <summary>
  10510. /// 团组模块 - 出入境国家费用标准-移动端 List
  10511. /// </summary>
  10512. /// <returns></returns>
  10513. [HttpPost]
  10514. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10515. public async Task<IActionResult> NationalTravelFeeMobileData(PostNationalTravelFeeMobileDataDto dto)
  10516. {
  10517. Stopwatch sw = new Stopwatch();
  10518. sw.Start();
  10519. int provinceId = dto.ProvinceId;
  10520. if (provinceId < 1) provinceId = 122; // 默认四川
  10521. RefAsync<int> total = 0;
  10522. var data = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  10523. .LeftJoin<Sys_SetData>((ntf, sd) => ntf.Currency == sd.Id)
  10524. .LeftJoin<Sys_Users>((ntf, sd, u) => ntf.CreateUserId == u.Id)
  10525. .LeftJoin<Sys_Cities>((ntf, sd, u, sd1) => ntf.ProvinceId == sd1.Id)
  10526. .Where((ntf, sd, u, sd1) => ntf.IsDel == 0 && ntf.ProvinceId == provinceId)
  10527. .WhereIF(!string.IsNullOrEmpty(dto.Search), (ntf, sd, u, sd1) => dto.Search.Contains(ntf.Country) || dto.Search.Contains(ntf.City))
  10528. .Select((ntf, sd, u, sd1) => new
  10529. {
  10530. Id = ntf.Id,
  10531. Area = $"{ntf.Country}-{ntf.City}",
  10532. Currency = ntf.Currency,
  10533. CurrencyCode = sd.Name,
  10534. CurrencyName = sd.Remark,
  10535. RoomCost = ntf.RoomCost,
  10536. FoodCost = ntf.FoodCost,
  10537. PublicCost = ntf.PublicCost,
  10538. TrainCost = ntf.TrainCost,
  10539. LastUpdateUserId = ntf.LastUpdateUserId,
  10540. LastUpdateUserName = u.CnName,
  10541. LastUpdateTime = ntf.LastUpdateTime
  10542. })
  10543. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10544. sw.Stop();
  10545. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", data, total));
  10546. }
  10547. /// <summary>
  10548. /// 团组模块 - 出入境费用-移动端 - Info
  10549. /// </summary>
  10550. /// <returns></returns>
  10551. [HttpPost]
  10552. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10553. public async Task<IActionResult> EnterExitCostMobileInfo(EnterExitCostInfobyDiIdDto dto)
  10554. {
  10555. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10556. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10557. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  10558. return Ok(data);
  10559. }
  10560. /// <summary>
  10561. /// 团组模块 - 出入境费用-移动端 - ParentInfo
  10562. /// </summary>
  10563. /// <returns></returns>
  10564. [HttpPost]
  10565. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10566. public async Task<IActionResult> EnterExitCostMobileParentInfo(EnterExitCostInfobyDiIdDto dto)
  10567. {
  10568. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10569. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10570. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10571. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  10572. var mobileInfo = new EnterExitCostMobileParentInfoView();
  10573. mobileInfo.DiId = dto.DiId;
  10574. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  10575. if (eecInfo == null) return Ok(mobileInfo);
  10576. //验证查看权限
  10577. (bool isView, bool isSet) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);
  10578. if (!isView) return Ok(JsonView(false, "没有查看权限!"));
  10579. mobileInfo = _mapper.Map<EnterExitCostMobileParentInfoView>(eecInfo);
  10580. mobileInfo.IsAssignPerm = isSet;
  10581. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCost>()
  10582. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10583. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10584. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  10585. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  10586. {
  10587. SubId = dac.Id,
  10588. DiId = dac.DiId,
  10589. Type = dac.Type,
  10590. Days = dac.Days,
  10591. NationalTravelFeeId = dac.NationalTravelFeeId,
  10592. Arae = $"{ntf.Country}-{ntf.City}",
  10593. Cost = dac.Cost,
  10594. Currency = dac.Currency,
  10595. CurrencyName = sd.Name,
  10596. SubTotal = dac.SubTotal,
  10597. })
  10598. .ToList();
  10599. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  10600. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  10601. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  10602. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  10603. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  10604. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  10605. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  10606. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  10607. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  10608. //其他款项
  10609. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  10610. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  10611. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  10612. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  10613. .OrderBy((dop, sd1, sd2) => dop.Index)
  10614. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  10615. {
  10616. SubId = dop.Id,
  10617. DiId = dop.Diid,
  10618. Index = dop.Index,
  10619. SetDataId = dop.SetDataId,
  10620. SetDataName = sd1.Name,
  10621. Cost = dop.Cost,
  10622. Currency = dop.Currency,
  10623. CurrencyName = sd2.Remark,
  10624. SubTotal = dop.SubTotal,
  10625. Remark = dop.Remark,
  10626. })
  10627. .ToArray();
  10628. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  10629. return Ok(mobileInfo);
  10630. }
  10631. /// <summary>
  10632. /// 团组模块 - 出入境费用-移动端 - 查看权限用户
  10633. /// </summary>
  10634. /// <returns></returns>
  10635. [HttpPost]
  10636. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10637. public async Task<IActionResult> EnterExitCostMobileViewPermissionUsers(EnterExitCostMobileViewPermissionUsersDto dto)
  10638. {
  10639. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10640. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10641. //验证查看权限
  10642. (bool viewPerm, bool assignPerm) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);//分配权限
  10643. if (!viewPerm) return Ok(JsonView(false, "未分配查看权限,如要查看,请联系市场部或国交部负责人!"));
  10644. var userIds = await _sqlSugar
  10645. .Queryable<Grp_EnterExitCostPermission>()
  10646. .Where(x => x.IsDel == 0 && x.GroupId == dto.DiId)
  10647. .Select(x => x.UserId)
  10648. .ToArrayAsync();
  10649. var perUsers = await _enterExitCostRep.PermissionViewUsersAsync();
  10650. var perUsersView = new List<dynamic>();
  10651. foreach (var item in perUsers)
  10652. {
  10653. bool isView1 = false;
  10654. if (userIds.Any(x => x == item.Id)) isView1 = true;
  10655. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  10656. }
  10657. return Ok(JsonView(perUsersView));
  10658. }
  10659. /// <summary>
  10660. /// 团组模块 - 出入境费用-移动端 - SubInfo
  10661. /// </summary>
  10662. /// <returns></returns>
  10663. [HttpPost]
  10664. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10665. public async Task<IActionResult> EnterExitCostMobileSubInfo(PostEnterExitCostMobileSubInfoDto dto)
  10666. {
  10667. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10668. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10669. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10670. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  10671. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  10672. //验证查看权限
  10673. //(bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  10674. //if (!isView) return Ok(JsonView(false, msg));
  10675. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  10676. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  10677. var subType = dto.SubType;
  10678. if (subType == 1) //1:境内费用
  10679. {
  10680. var oneData = new ChoiceOneMobileSubInfoView()
  10681. {
  10682. Id = eecInfo.Id,
  10683. ChoiceOne = eecInfo.ChoiceOne,
  10684. ChoiceOneTotalCost = eecInfo.InsidePay,
  10685. Visa = eecInfo.Visa,
  10686. VisaRemark = eecInfo.VisaRemark,
  10687. YiMiao = eecInfo.YiMiao,
  10688. HeSuan = eecInfo.HeSuan,
  10689. Service = eecInfo.Service,
  10690. Ticket = eecInfo.Ticket,
  10691. Safe = eecInfo.Safe,
  10692. FirstItemRemark = eecInfo.FirstItemRemark
  10693. };
  10694. return Ok(JsonView(oneData));
  10695. }
  10696. else if (subType == 2) //2:国际旅费
  10697. {
  10698. var twoData = new ChoiceTwoMobileSubInfoView()
  10699. {
  10700. Id = eecInfo.Id,
  10701. ChoiceTwoJJ = eecInfo.SumJJC,
  10702. OutsideJJPay = eecInfo.OutsideJJPay,
  10703. ChoiceTwoGW = eecInfo.SumGWC,
  10704. OutsideGWPay = eecInfo.OutsideGWPay,
  10705. ChoiceTwoTD = eecInfo.SumTDC,
  10706. OutsideTDPay = eecInfo.OutsideTDPay,
  10707. AirJJ = eecInfo.AirJJ,
  10708. AirGW = eecInfo.AirGW,
  10709. AirTD = eecInfo.AirTD,
  10710. CityTranffic = eecInfo.CityTranffic,
  10711. TwoItemRemark = eecInfo.TwoItemRemark
  10712. };
  10713. return Ok(JsonView(twoData));
  10714. }
  10715. else if (subType == 3) //3:住宿费
  10716. {
  10717. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  10718. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10719. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10720. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 1)
  10721. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  10722. {
  10723. SubId = dac.Id,
  10724. DiId = dac.DiId,
  10725. Type = dac.Type,
  10726. Days = dac.Days,
  10727. NationalTravelFeeId = dac.NationalTravelFeeId,
  10728. Arae = $"{ntf.Country}-{ntf.City}",
  10729. Cost = dac.Cost,
  10730. Currency = dac.Currency,
  10731. CurrencyName = sd.Name,
  10732. SubTotal = dac.SubTotal,
  10733. })
  10734. .ToArray();
  10735. var data = new ChoiceMobileSubInfo3To6View()
  10736. {
  10737. ParentId = eecInfo.Id,
  10738. Choice = eecInfo.ChoiceThree,
  10739. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10740. Details = dayAndCostDatas
  10741. };
  10742. return Ok(JsonView(data));
  10743. }
  10744. else if (subType == 4) //4:伙食费
  10745. {
  10746. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  10747. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10748. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10749. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 2)
  10750. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  10751. {
  10752. SubId = dac.Id,
  10753. DiId = dac.DiId,
  10754. Type = dac.Type,
  10755. Days = dac.Days,
  10756. NationalTravelFeeId = dac.NationalTravelFeeId,
  10757. Arae = $"{ntf.Country}-{ntf.City}",
  10758. Cost = dac.Cost,
  10759. Currency = dac.Currency,
  10760. CurrencyName = sd.Name,
  10761. SubTotal = dac.SubTotal,
  10762. })
  10763. .ToArray();
  10764. var data = new ChoiceMobileSubInfo3To6View()
  10765. {
  10766. ParentId = eecInfo.Id,
  10767. Choice = eecInfo.ChoiceFour,
  10768. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10769. Details = dayAndCostDatas
  10770. };
  10771. return Ok(JsonView(data));
  10772. }
  10773. else if (subType == 5) //5:公杂费
  10774. {
  10775. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  10776. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10777. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10778. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 3)
  10779. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  10780. {
  10781. SubId = dac.Id,
  10782. DiId = dac.DiId,
  10783. Type = dac.Type,
  10784. Days = dac.Days,
  10785. NationalTravelFeeId = dac.NationalTravelFeeId,
  10786. Arae = $"{ntf.Country}-{ntf.City}",
  10787. Cost = dac.Cost,
  10788. Currency = dac.Currency,
  10789. CurrencyName = sd.Name,
  10790. SubTotal = dac.SubTotal,
  10791. })
  10792. .ToArray();
  10793. var data = new ChoiceMobileSubInfo3To6View()
  10794. {
  10795. ParentId = eecInfo.Id,
  10796. Choice = eecInfo.ChoiceFive,
  10797. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10798. Details = dayAndCostDatas
  10799. };
  10800. return Ok(JsonView(data));
  10801. }
  10802. else if (subType == 6) //6:培训费
  10803. {
  10804. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  10805. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10806. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10807. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 4)
  10808. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  10809. {
  10810. SubId = dac.Id,
  10811. DiId = dac.DiId,
  10812. Type = dac.Type,
  10813. Days = dac.Days,
  10814. NationalTravelFeeId = dac.NationalTravelFeeId,
  10815. Arae = $"{ntf.Country}-{ntf.City}",
  10816. Cost = dac.Cost,
  10817. Currency = dac.Currency,
  10818. CurrencyName = sd.Name,
  10819. SubTotal = dac.SubTotal,
  10820. })
  10821. .ToArray();
  10822. var data = new ChoiceMobileSubInfo3To6View()
  10823. {
  10824. ParentId = eecInfo.Id,
  10825. Choice = eecInfo.ChoiceSix,
  10826. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10827. Details = dayAndCostDatas
  10828. };
  10829. return Ok(JsonView(data));
  10830. }
  10831. else if (subType == 7) //7:其他
  10832. {
  10833. //其他款项
  10834. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  10835. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  10836. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  10837. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  10838. .OrderBy((dop, sd1, sd2) => dop.Index)
  10839. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  10840. {
  10841. SubId = dop.Id,
  10842. DiId = dop.Diid,
  10843. Index = dop.Index,
  10844. SetDataId = dop.SetDataId,
  10845. SetDataName = sd1.Name,
  10846. Cost = dop.Cost,
  10847. Currency = dop.Currency,
  10848. CurrencyName = sd2.Name,
  10849. SubTotal = dop.SubTotal,
  10850. Remark = dop.Remark,
  10851. })
  10852. .ToArray();
  10853. var data = new ChoiceSevenMobileSubInfoView()
  10854. {
  10855. ParentId = eecInfo.Id,
  10856. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  10857. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  10858. Details = otherData
  10859. };
  10860. return Ok(JsonView(data));
  10861. }
  10862. return Ok(JsonView(false));
  10863. }
  10864. #region op
  10865. ///// <summary>
  10866. ///// 移动端更新费用消息通知
  10867. ///// </summary>
  10868. ///// <param name="diid"></param>
  10869. ///// <param name="id"></param>
  10870. ///// <param name="currUserId"></param>
  10871. //private async Task EnterExitCostMobileOpNotice(int diid, int id, int currUserId)
  10872. //{
  10873. // try
  10874. // {
  10875. // ////生成默认文件pdf并且通知人员
  10876. // //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  10877. // //{
  10878. // // DiId = diid,
  10879. // // ExportType = 1,
  10880. // // SubTypeId = 1005
  10881. // //}, "pdf");
  10882. // ////发送通知
  10883. // //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  10884. // //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  10885. // //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  10886. // //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(diid, new List<string>() { "208", "233", "21" }, currUserId, url);
  10887. // ////汇率信息记录
  10888. // //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  10889. // }
  10890. // catch (Exception ex)
  10891. // {
  10892. // //记录日志
  10893. // throw;
  10894. // }
  10895. //}
  10896. /// <summary>
  10897. /// 验证出入境费用数据是否存在
  10898. /// 不存在添加
  10899. /// </summary>
  10900. /// <param name="diId"></param>
  10901. /// <param name="currUserId"></param>
  10902. /// <returns></returns>
  10903. /// <exception cref="CustomException"></exception>
  10904. private async Task<int> EnterExitCostVerifyIsNull(int diId, int currUserId)
  10905. {
  10906. var parentId = 0;
  10907. var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).OrderByDescending(x => x.CreateTime).FirstAsync();
  10908. if (info != null)
  10909. {
  10910. parentId = info.Id;
  10911. }
  10912. else
  10913. {
  10914. var currencys = await EnterExitCostMobileGetCurrencyInit();
  10915. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCost() { DiId = diId, CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  10916. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  10917. parentId = addId;
  10918. }
  10919. return parentId;
  10920. }
  10921. /// <summary>
  10922. /// 团组模块 - 出入境费用-移动端 - 设置view权限
  10923. /// </summary>
  10924. /// <returns></returns>
  10925. [HttpPost]
  10926. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10927. public async Task<IActionResult> EnterExitCostMobileSetViewPermissiion(EnterExitCostMobileSetViewPermissiionDto dto)
  10928. {
  10929. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10930. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10931. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  10932. //验证编辑权限
  10933. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10934. //if (!isEdit) return Ok(JsonView(false, msg));
  10935. var permissions = new List<Grp_EnterExitCostPermission>();
  10936. foreach (var userId in dto.UserIds)
  10937. {
  10938. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = userId, CreateUserId = dto.CurrUserId });
  10939. }
  10940. if (permissions.Any())
  10941. {
  10942. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  10943. {
  10944. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  10945. }
  10946. _sqlSugar.BeginTran();
  10947. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.DiId).ExecuteCommandAsync();
  10948. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  10949. if (result < 1)
  10950. {
  10951. _sqlSugar.RollbackTran();
  10952. return Ok(JsonView(false));
  10953. }
  10954. _sqlSugar.CommitTran();
  10955. return Ok(JsonView(true));
  10956. }
  10957. return Ok(JsonView(false));
  10958. }
  10959. /// <summary>
  10960. /// 团组模块 - 出入境费用-移动端 - OP --> 汇率
  10961. /// </summary>
  10962. /// <returns></returns>
  10963. [HttpPost]
  10964. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10965. public async Task<IActionResult> EnterExitCostMobileOpRate(PostEnterExitCostMobileFeeRateOpDto dto)
  10966. {
  10967. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10968. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10969. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10970. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  10971. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  10972. int id = dto.Id;
  10973. if (id <= 0) //add
  10974. {
  10975. //int provinceId = dto.ProvinceId;
  10976. int groupId = dto.DiId;
  10977. //if (provinceId < 1) provinceId = 122;
  10978. var info = new Grp_EnterExitCost() { DiId = groupId, CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId };
  10979. info.LastUpdateUserId = dto.CurrUserId;
  10980. info.LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  10981. var add = await _sqlSugar.Insertable(info).ExecuteCommandAsync();
  10982. if (add < 1) return Ok(JsonView(false));
  10983. id = add;
  10984. }
  10985. else //update
  10986. {
  10987. ////验证编辑权限
  10988. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10989. //if (!isEdit) return Ok(JsonView(false, msg));
  10990. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>().SetColumns(x => new Grp_EnterExitCost()
  10991. {
  10992. CurrencyRemark = currencyStr,
  10993. LastUpdateUserId = dto.CurrUserId,
  10994. LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10995. }).Where(x => x.Id == dto.Id).ExecuteCommandAsync();
  10996. if (upd < 1) return Ok(JsonView(false));
  10997. }
  10998. #region 汇率变更时更改币种相关费用
  10999. var opDayCosts = new List<Grp_DayAndCost>();
  11000. var opDayOtherCosts = new List<Grp_DayOtherPrice>();
  11001. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  11002. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCost>()
  11003. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  11004. .Where((dac, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  11005. .Select((dac, sd) => new
  11006. {
  11007. dac.Id,
  11008. dac.DiId,
  11009. CurrencyCode = sd.Name,
  11010. dac.Cost
  11011. })
  11012. .ToList();
  11013. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  11014. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  11015. .Where((dop, sd) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  11016. .Select((dop, sd) => new
  11017. {
  11018. dop.Id,
  11019. dop.Diid,
  11020. CurrencyCode = sd.Name,
  11021. dop.Cost
  11022. })
  11023. .ToList();
  11024. if (dayCosts.Count > 0)
  11025. {
  11026. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  11027. foreach (var dc in new_dayCosts)
  11028. {
  11029. var thisCurrency = dc.Key.ToUpper();
  11030. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  11031. if (thisRate == 0.00M) continue;
  11032. foreach (var dcSub in dc)
  11033. {
  11034. opDayCosts.Add(new Grp_DayAndCost()
  11035. {
  11036. Id = dcSub.Id,
  11037. DiId = dcSub.DiId,
  11038. Cost = dcSub.Cost,
  11039. SubTotal = dcSub.Cost * thisRate,
  11040. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  11041. });
  11042. }
  11043. }
  11044. if (opDayCosts.Count > 0)
  11045. {
  11046. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  11047. }
  11048. }
  11049. if (dayOtherCosts.Count > 0)
  11050. {
  11051. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  11052. foreach (var dc in new_dayOtherCosts)
  11053. {
  11054. var thisCurrency = dc.Key.ToUpper();
  11055. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  11056. if (thisRate == 0.00M) continue;
  11057. foreach (var dcSub in dc)
  11058. {
  11059. opDayOtherCosts.Add(new Grp_DayOtherPrice()
  11060. {
  11061. Id = dcSub.Id,
  11062. Diid = dcSub.Diid,
  11063. Cost = dcSub.Cost,
  11064. SubTotal = dcSub.Cost * thisRate,
  11065. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  11066. });
  11067. }
  11068. }
  11069. if (opDayOtherCosts.Count > 0)
  11070. {
  11071. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  11072. }
  11073. }
  11074. #endregion
  11075. //消息通知
  11076. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11077. //汇率信息记录
  11078. await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  11079. return Ok(JsonView(new { parentId = id }));
  11080. }
  11081. /// <summary>
  11082. /// 团组模块 - 出入境费用-移动端 - OP --> 复选框
  11083. /// </summary>
  11084. /// <returns></returns>
  11085. [HttpPost]
  11086. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11087. public async Task<IActionResult> EnterExitCostMobileOpCheckbox(PostEnterExitCostMobileFeeOpCheckboxDto dto)
  11088. {
  11089. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11090. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11091. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11092. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11093. var checkboxInfo = _mapper.Map<Grp_EnterExitCost>(dto);
  11094. checkboxInfo.LastUpdateUserId = dto.CurrUserId;
  11095. checkboxInfo.LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  11096. int id = dto.Id;
  11097. if (id <= 0) //add
  11098. {
  11099. checkboxInfo.CreateUserId = dto.CurrUserId;
  11100. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11101. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  11102. if (add < 1) return Ok(JsonView(false));
  11103. }
  11104. else //update
  11105. {
  11106. ////验证编辑权限
  11107. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  11108. //if (!isEdit) return Ok(JsonView(false, msg));
  11109. var upd = await _sqlSugar.Updateable(checkboxInfo)
  11110. .UpdateColumns(x => new
  11111. {
  11112. x.ChoiceOne,
  11113. x.ChoiceTwo,
  11114. x.SumJJC,
  11115. x.SumGWC,
  11116. x.SumTDC,
  11117. x.ChoiceThree,
  11118. x.ChoiceFour,
  11119. x.ChoiceFive,
  11120. x.ChoiceSix,
  11121. x.OtherExpenses_Checked
  11122. })
  11123. .Where(x => x.Id == id)
  11124. .ExecuteCommandAsync();
  11125. if (upd < 1) return Ok(JsonView(false));
  11126. }
  11127. return Ok(JsonView(new { parentId = id }));
  11128. }
  11129. /// <summary>
  11130. /// 团组模块 - 出入境费用-移动端 - OP --> 3-7项复选框单个复选框更改
  11131. /// </summary>
  11132. /// <returns></returns>
  11133. [HttpPost]
  11134. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11135. public async Task<IActionResult> EnterExitCostMobileOpSingleCheckbox(EnterExitCostMobileOpSingleCheckboxDto dto)
  11136. {
  11137. int itemTypeId = dto.ItemType, id = dto.Id, currUserId = dto.CurrUserId, diId = dto.DiId, isSelected = dto.IsSelected;
  11138. // if (provinceId < 1) provinceId = 122;
  11139. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  11140. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11141. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11142. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11143. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  11144. var checkboxInfo = new Grp_EnterExitCost()
  11145. {
  11146. Id = id,
  11147. //ProvinceId = provinceId,
  11148. DiId = diId,
  11149. CreateUserId = currUserId,
  11150. LastUpdateUserId = dto.CurrUserId,
  11151. LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  11152. };
  11153. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  11154. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  11155. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  11156. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  11157. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  11158. if (id <= 0) //add
  11159. {
  11160. checkboxInfo.CreateUserId = dto.CurrUserId;
  11161. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11162. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  11163. if (add < 1) return Ok(JsonView(false));
  11164. }
  11165. else //update
  11166. {
  11167. ////验证编辑权限
  11168. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  11169. //if (!isEdit) return Ok(JsonView(false, msg));
  11170. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>()
  11171. .SetColumns(it => it.LastUpdateUserId == dto.CurrUserId)
  11172. .SetColumns(it => it.LastUpdateTime == DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
  11173. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  11174. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  11175. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  11176. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  11177. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  11178. .Where(x => x.Id == id)
  11179. .ExecuteCommandAsync();
  11180. if (upd < 1) return Ok(JsonView(false));
  11181. }
  11182. return Ok(JsonView(new { parentId = id }));
  11183. }
  11184. /// <summary>
  11185. /// 团组模块 - 出入境费用-移动端 - OP --> 境内费用 Step1
  11186. /// </summary>
  11187. /// <returns></returns>
  11188. [HttpPost]
  11189. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11190. public async Task<IActionResult> EnterExitCostMobileOpStep1(PostEnterExitCostMobileOpStep1Dto dto)
  11191. {
  11192. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11193. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11194. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11195. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11196. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  11197. info.FirstItemRemark = dto.FirstItemRemark;
  11198. info.LastUpdateUserId = dto.CurrUserId;
  11199. info.LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  11200. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  11201. int id = dto.Id;
  11202. if (id <= 0) //add
  11203. {
  11204. info.CreateUserId = dto.CurrUserId;
  11205. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11206. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  11207. if (add < 1) return Ok(JsonView(false));
  11208. id = add;
  11209. }
  11210. else //update
  11211. {
  11212. ////验证编辑权限
  11213. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  11214. //if (!isEdit) return Ok(JsonView(false, msg));
  11215. var upd = await _sqlSugar.Updateable(info)
  11216. .UpdateColumns(x => new
  11217. {
  11218. x.ChoiceOne,
  11219. x.InsidePay,
  11220. x.VisaRemark,
  11221. x.Visa,
  11222. x.Service,
  11223. x.Safe,
  11224. x.Ticket,
  11225. x.HeSuan,
  11226. x.YiMiao,
  11227. x.FirstItemRemark,
  11228. x.LastUpdateUserId,
  11229. x.LastUpdateTime
  11230. })
  11231. .Where(x => x.Id == id)
  11232. .ExecuteCommandAsync();
  11233. if (upd < 1) return Ok(JsonView(false));
  11234. }
  11235. //消息通知
  11236. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11237. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  11238. }
  11239. /// <summary>
  11240. /// 团组模块 - 出入境费用-移动端 - OP --> 国际旅费 Step2
  11241. /// </summary>
  11242. /// <returns></returns>
  11243. [HttpPost]
  11244. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11245. public async Task<IActionResult> EnterExitCostMobileOpStep2(PostEnterExitCostMobileOpStep2Dto dto)
  11246. {
  11247. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11248. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11249. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11250. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11251. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  11252. info.DiId = dto.DiId;
  11253. //info.ProvinceId = dto.ProvinceId;
  11254. info.OutsideJJPay = dto.OutsideJJPay;
  11255. info.OutsideGWPay = dto.OutsideGWPay;
  11256. info.OutsideTDPay = dto.OutsideTDPay;
  11257. info.AirJJ = dto.AirJJ;
  11258. info.AirGW = dto.AirGW;
  11259. info.AirTD = dto.AirTD;
  11260. info.CityTranffic = dto.CityTranffic;
  11261. info.TwoItemRemark = dto.TwoItemRemark;
  11262. info.SumJJC = dto.ChoiceTwoJJ;
  11263. info.SumGWC = dto.ChoiceTwoGW;
  11264. info.SumTDC = dto.ChoiceTwoTD;
  11265. info.LastUpdateUserId = dto.CurrUserId;
  11266. info.LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  11267. int id = dto.Id;
  11268. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  11269. if (id <= 0) //add i
  11270. {
  11271. info.CreateUserId = dto.CurrUserId;
  11272. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11273. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  11274. if (addId <= 0) return Ok(JsonView(false));
  11275. id = addId;
  11276. }
  11277. else //update
  11278. {
  11279. ////验证编辑权限
  11280. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  11281. //if (!isEdit) return Ok(JsonView(false, msg));
  11282. var upd = await _sqlSugar.Updateable(info)
  11283. .UpdateColumns(x => new
  11284. {
  11285. x.SumJJC,
  11286. x.OutsideJJPay,
  11287. x.SumGWC,
  11288. x.OutsideGWPay,
  11289. x.SumTDC,
  11290. x.OutsideTDPay,
  11291. x.AirJJ,
  11292. x.AirGW,
  11293. x.AirTD,
  11294. x.CityTranffic,
  11295. x.TwoItemRemark,
  11296. x.LastUpdateTime,
  11297. x.LastUpdateUserId
  11298. })
  11299. .Where(x => x.Id == id)
  11300. .ExecuteCommandAsync();
  11301. if (upd < 1) return Ok(JsonView(false));
  11302. }
  11303. jjcItemTotal = info.AirJJ + info.CityTranffic;
  11304. gwcItemTotal = info.AirGW + info.CityTranffic;
  11305. tdcItemTotal = info.AirTD + info.CityTranffic;
  11306. //消息通知
  11307. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11308. return Ok(JsonView(new
  11309. {
  11310. parentId = id,
  11311. choiceTwoJJ = dto.ChoiceTwoJJ,
  11312. jjcItemTotal = jjcItemTotal,
  11313. choiceTwoGW = dto.ChoiceTwoGW,
  11314. gwcItemTotal = gwcItemTotal,
  11315. choiceTwoTD = dto.ChoiceTwoTD,
  11316. tdcItemTotal = tdcItemTotal
  11317. }));
  11318. }
  11319. /// <summary>
  11320. /// 团组模块 - 出入境费用-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  11321. /// </summary>
  11322. /// <returns></returns>
  11323. [HttpPost]
  11324. [ApiExplorerSettings(IgnoreApi = true)]
  11325. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11326. public async Task<IActionResult> EnterExitCostMobileOpBatchStep3To6(PostEnterExitCostMobileOpStep3To6Dto dto)
  11327. {
  11328. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11329. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11330. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11331. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  11332. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  11333. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  11334. var infos1 = _mapper.Map<List<Grp_DayAndCost>>(dto.Infos);
  11335. var infos = infos1.Select(x => new Grp_DayAndCost
  11336. {
  11337. Id = x.Id,
  11338. DiId = dto.DiId,
  11339. Type = dto.FeeType,
  11340. Days = x.Days,
  11341. NationalTravelFeeId = x.NationalTravelFeeId,
  11342. Cost = x.Cost,
  11343. Currency = x.Currency,
  11344. SubTotal = x.SubTotal,
  11345. CreateUserId = dto.CurrUserId
  11346. })
  11347. .ToList();
  11348. var adds = infos.Where(x => x.Id <= 0).ToList();
  11349. var upds = infos.Where(x => x.Id > 0).ToList();
  11350. if (adds.Count > 0)
  11351. {
  11352. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  11353. if (add < 1) return Ok(JsonView(false));
  11354. }
  11355. if (upds.Count > 0)
  11356. {
  11357. var upd = await _sqlSugar.Updateable(adds)
  11358. .UpdateColumns(x => new
  11359. {
  11360. x.Days,
  11361. x.NationalTravelFeeId,
  11362. x.Cost,
  11363. x.Currency,
  11364. x.SubTotal
  11365. })
  11366. .WhereColumns(x => new { x.Id })
  11367. .ExecuteCommandAsync();
  11368. if (upd < 1) return Ok(JsonView(false));
  11369. }
  11370. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  11371. //消息通知
  11372. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  11373. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11374. return Ok(JsonView(new { itemTotal = itemTotal }));
  11375. }
  11376. /// <summary>
  11377. /// 团组模块 - 出入境费用-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  11378. /// </summary>
  11379. /// <returns></returns>
  11380. [HttpPost]
  11381. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11382. public async Task<IActionResult> EnterExitCostMobileOpSingleStep3To6(PostEnterExitCostMobileOpSingleStep3To6Dto dto)
  11383. {
  11384. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  11385. int subId = dto.SubId, feeType = dto.FeeType;
  11386. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11387. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11388. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11389. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  11390. var subInfo = _mapper.Map<Grp_DayAndCost>(dto);
  11391. subInfo.Id = subId;
  11392. subInfo.DiId = dto.DiId;
  11393. if (feeType == 3) subInfo.Type = 1;
  11394. else if (feeType == 4) subInfo.Type = 2;
  11395. else if (feeType == 5) subInfo.Type = 3;
  11396. else if (feeType == 6) subInfo.Type = 4;
  11397. subInfo.CreateUserId = dto.CurrUserId;
  11398. int parentId = await EnterExitCostVerifyIsNull(dto.DiId, dto.CurrUserId); //主表验证
  11399. if (parentId < 1) return Ok(JsonView(false));
  11400. //子表op
  11401. if (subId < 1)
  11402. {
  11403. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  11404. if (subAdd < 1) return Ok(JsonView(false));
  11405. }
  11406. else
  11407. {
  11408. ////验证编辑权限
  11409. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  11410. //if (!isEdit) return Ok(JsonView(false, msg));
  11411. var subUpd = await _sqlSugar.Updateable(subInfo)
  11412. .UpdateColumns(x => new
  11413. {
  11414. x.Days,
  11415. x.NationalTravelFeeId,
  11416. x.Cost,
  11417. x.Currency,
  11418. x.SubTotal
  11419. })
  11420. .WhereColumns(x => new { x.Id })
  11421. .ExecuteCommandAsync();
  11422. if (subUpd < 1) return Ok(JsonView(false));
  11423. }
  11424. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == feeType).Sum(x => x.SubTotal);
  11425. //await EnterExitCostMobileOpNotice(dto.DiId, parentId, dto.CurrUserId);
  11426. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  11427. }
  11428. /// <summary>
  11429. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-批量 Step7
  11430. /// </summary>
  11431. /// <returns></returns>
  11432. [HttpPost]
  11433. [ApiExplorerSettings(IgnoreApi = true)]
  11434. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11435. public async Task<IActionResult> EnterExitCostMobileOpBatchStep7(PostEnterExitCostMobileOpStep7Dto dto)
  11436. {
  11437. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11438. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11439. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11440. var infos1 = _mapper.Map<List<Grp_DayOtherPrice>>(dto.Infos);
  11441. var infos = infos1.Select(x => new Grp_DayOtherPrice()
  11442. {
  11443. Id = x.Id,
  11444. Diid = dto.DiId,
  11445. SetDataId = x.SetDataId,
  11446. Index = x.Index,
  11447. Cost = x.Cost,
  11448. Currency = x.Currency,
  11449. SubTotal = x.SubTotal,
  11450. CreateUserId = dto.CurrUserId,
  11451. Remark = x.Remark
  11452. }).ToList();
  11453. var adds = infos.Where(x => x.Id <= 0).ToList();
  11454. var upds = infos.Where(x => x.Id > 0).ToList();
  11455. if (adds.Count > 0)
  11456. {
  11457. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  11458. if (add < 1) return Ok(JsonView(false));
  11459. }
  11460. if (upds.Count > 0)
  11461. {
  11462. var upd = await _sqlSugar.Updateable(adds)
  11463. .UpdateColumns(x => new
  11464. {
  11465. x.Index,
  11466. x.SetDataId,
  11467. x.Cost,
  11468. x.Currency,
  11469. x.SubTotal,
  11470. x.Remark
  11471. })
  11472. .WhereColumns(x => new { x.Id })
  11473. .ExecuteCommandAsync();
  11474. if (upd < 1) return Ok(JsonView(false));
  11475. }
  11476. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == dto.DiId).Sum(x => x.SubTotal);
  11477. //消息通知
  11478. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  11479. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11480. return Ok(JsonView(new { itemTotal = itemTotal }));
  11481. }
  11482. /// <summary>
  11483. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-单条 Step7
  11484. /// </summary>
  11485. /// <returns></returns>
  11486. [HttpPost]
  11487. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11488. public async Task<IActionResult> EnterExitCostMobileOpSingleStep7(PostEnterExitCostMobileOpSingleStep7Dto dto)
  11489. {
  11490. int subId = dto.SubId;
  11491. int diId = dto.Diid;
  11492. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11493. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11494. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11495. var subInfo = _mapper.Map<Grp_DayOtherPrice>(dto);
  11496. subInfo.Id = subId;
  11497. subInfo.Diid = dto.Diid;
  11498. subInfo.CreateUserId = dto.CurrUserId;
  11499. int parentId = await EnterExitCostVerifyIsNull(diId, dto.CurrUserId); //主表验证
  11500. if (parentId < 1) return Ok(JsonView(false));
  11501. #region 子表op
  11502. if (subId < 1)//add
  11503. {
  11504. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  11505. if (subAdd < 1) return Ok(JsonView(false));
  11506. }
  11507. else //upd
  11508. {
  11509. ////验证编辑权限
  11510. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.Diid, dto.CurrUserId, 2);
  11511. //if (!isEdit) return Ok(JsonView(false, msg));
  11512. var subUpd = await _sqlSugar.Updateable(subInfo)
  11513. .UpdateColumns(x => new
  11514. {
  11515. x.Index,
  11516. x.SetDataId,
  11517. x.Cost,
  11518. x.Currency,
  11519. x.SubTotal,
  11520. x.Remark
  11521. })
  11522. .WhereColumns(x => new { x.Id })
  11523. .ExecuteCommandAsync();
  11524. if (subUpd < 1) return Ok(JsonView(false));
  11525. }
  11526. #endregion
  11527. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == diId).Sum(x => x.SubTotal);
  11528. //消息通知
  11529. //await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  11530. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  11531. }
  11532. /// <summary>
  11533. /// 团组模块 - 出入境费用-移动端 - 3-6子项删除
  11534. /// </summary>
  11535. /// <returns></returns>
  11536. [HttpPost]
  11537. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11538. public async Task<IActionResult> EnterExitCostMobileSubItemDel(EnterExitCostSubItemDelDto dto)
  11539. {
  11540. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  11541. if (data.Code != 0)
  11542. {
  11543. return Ok(JsonView(false, data.Msg));
  11544. }
  11545. return Ok(JsonView(true, "操作成功!", data.Data));
  11546. }
  11547. /// <summary>
  11548. /// 团组模块 - 出入境费用-移动端 - 其他费用删除
  11549. /// </summary>
  11550. /// <param name="dto"></param>
  11551. /// <returns></returns>
  11552. [HttpPost]
  11553. public IActionResult EnterExitCostMobileOtherFeeDel(EnterExitCostSubItemDelDto dto)
  11554. {
  11555. var data = new Grp_DayOtherPrice()
  11556. {
  11557. Id = dto.Id,
  11558. IsDel = 1,
  11559. DeleteUserId = dto.DeleteUserId,
  11560. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  11561. };
  11562. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  11563. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  11564. return Ok(JsonView(false, "删除失败!"));
  11565. }
  11566. #endregion
  11567. #endregion
  11568. #region 团组经理模块 出入境费用-草稿 移动端(Android/IOS)
  11569. /// <summary>
  11570. /// 团组模块 - 出入境费用-草稿 - 基础数据源 - 省份归属
  11571. /// </summary>
  11572. /// <returns></returns>
  11573. [HttpGet]
  11574. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11575. public async Task<IActionResult> EnterExitDraftMobileProvBelongCostDataSource()
  11576. {
  11577. var provData = await _groupRepository.ProvinceBasicSource();
  11578. return Ok(JsonView(true, "查询成功!", provData));
  11579. }
  11580. /// <summary>
  11581. /// 团组模块 - 出入境费用-草稿-移动端 - 草稿名称数据Data
  11582. /// </summary>
  11583. /// <returns></returns>
  11584. [HttpPost]
  11585. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11586. public async Task<IActionResult> EnterExitCostDraftMobileNameData(EnterExitCostDraftMobileNameDataDto dto)
  11587. {
  11588. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11589. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11590. RefAsync<int> total = 0;
  11591. var data = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  11592. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.DraftName))
  11593. .WhereIF(!string.IsNullOrEmpty(dto.DraftName), x => x.DraftName.Contains(dto.DraftName))
  11594. .Select(x => new
  11595. {
  11596. Id = x.Id,
  11597. DraftName = x.DraftName,
  11598. IsViewOrEdit = SqlFunc.Subqueryable<Grp_EnterExitCostDraftPermission>()
  11599. .Where(x1 => x1.IsDel == 0 && x1.Permission == 1 && x1.DraftId == x.Id && x1.UserId == dto.CurrUserId)
  11600. .Any()
  11601. })
  11602. .OrderByDescending(x => x.Id)
  11603. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  11604. return Ok(JsonView(true, "查询成功!", data, total));
  11605. }
  11606. /// <summary>
  11607. /// 出入境费用-草稿 移动端
  11608. /// 获取币种基础数据(含逻辑处理)
  11609. /// </summary>
  11610. /// <returns></returns>
  11611. private async Task<List<CurrencyInfo>> EnterExitCostDraftMobileGetCurrencyInit()
  11612. {
  11613. return await GeneralMethod.EnterExitCostInitRate();
  11614. }
  11615. /// <summary>
  11616. /// 团组模块 - 出入境费用-草稿-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  11617. /// </summary>
  11618. /// <returns></returns>
  11619. [HttpPost]
  11620. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11621. public async Task<IActionResult> EnterExitCostDraftMobileDataSource(EnterExitCostDraftMobileDataSourceDto dto)
  11622. {
  11623. //验证城市归属并给默认值
  11624. int provinceId = dto.ProvinceId;
  11625. if (provinceId < 1) provinceId = 122;
  11626. var dataSource = await _sqlSugar
  11627. .Queryable<Sys_SetData>()
  11628. .Where(x => x.IsDel == 0 && (x.STid == 72 || x.STid == 73) && x.Remark.Contains(provinceId.ToString()))
  11629. .ToListAsync();
  11630. //三公费用-Word明细类型
  11631. var wordTypeData = dataSource.Where(it => it.STid == 72)
  11632. .Select(x => new SetDataInfoView
  11633. {
  11634. Id = x.Id,
  11635. Name = x.Name,
  11636. Remark = x.Remark
  11637. })
  11638. .ToList();
  11639. //三公费用-Excel明细类型
  11640. var excelTypeData = dataSource.Where(it => it.STid == 73)
  11641. .Select(x => new SetDataInfoView
  11642. {
  11643. Id = x.Id,
  11644. Name = x.Name,
  11645. Remark = x.Remark
  11646. })
  11647. .ToList();
  11648. //默认币种显示
  11649. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  11650. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  11651. return Ok(JsonView(true, "查询成功!", new
  11652. {
  11653. WordTypeData = wordTypeData,
  11654. ExcelTypeData = excelTypeData,
  11655. CurrencyInit = _currencyInfos,
  11656. viewPermissionData = viewPermissionData
  11657. }));
  11658. }
  11659. /// <summary>
  11660. /// 团组模块 - 出入境费用-草稿-移动端 - 团组基础数据Data
  11661. /// </summary>
  11662. /// <returns></returns>
  11663. [HttpPost]
  11664. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11665. public async Task<IActionResult> EnterExitCostDraftMobileGroupData(PostEnterExitCostDraftMobileGroupDataDto dto)
  11666. {
  11667. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11668. RefAsync<int> total = 0;
  11669. int diId = 0;
  11670. var status = int.TryParse(dto.GroupName, out diId);
  11671. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  11672. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  11673. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  11674. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  11675. .OrderByDescending(x => x.VisitStartDate)
  11676. .Select(x => new
  11677. {
  11678. Id = x.Id,
  11679. GroupName = x.TeamName
  11680. })
  11681. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  11682. return Ok(JsonView(true, "查询成功!", data, total));
  11683. }
  11684. /// <summary>
  11685. /// 团组模块 - 出入境费用-草稿-移动端 - 币种基础数据Data
  11686. /// </summary>
  11687. /// <returns></returns>
  11688. [HttpPost]
  11689. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11690. public async Task<IActionResult> EnterExitCostDraftMobileCurrencyData(PostEnterExitCostDraftMobileCurrencyDataDto dto)
  11691. {
  11692. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11693. RefAsync<int> total = 0;
  11694. var data = await _sqlSugar.Queryable<Sys_SetData>()
  11695. .Where(x => x.IsDel == 0 && x.STid == 66)
  11696. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  11697. .Select(x => new
  11698. {
  11699. id = x.Id,
  11700. name = x.Name,
  11701. remark = x.Remark,
  11702. })
  11703. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  11704. return Ok(JsonView(true, "查询成功!", data, total));
  11705. }
  11706. /// <summary>
  11707. /// 团组模块 - 出入境费用-草稿-移动端 - 其他款项 - 币种、费用类型基础数据Data
  11708. /// </summary>
  11709. /// <returns></returns>
  11710. [HttpPost]
  11711. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11712. public async Task<IActionResult> EnterExitCostDraftMobileOtherItemCurrencyData(PostEnterExitCostDraftMobileOtherItemCurrencyDataDto dto)
  11713. {
  11714. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11715. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11716. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(1, 2477, 98);
  11717. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  11718. var groupOtherRateData = groupRateData.TeamRates;
  11719. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  11720. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  11721. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  11722. groupOtherRateData = groupOtherRateData
  11723. .Select(x => new TeamRateDescAddCurrencyIdView
  11724. {
  11725. CurrencyId = x.CurrencyId,
  11726. CurrencyName = x.CurrencyName,
  11727. CurrencyCode = x.CurrencyCode,
  11728. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  11729. }).ToList();
  11730. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  11731. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  11732. }
  11733. /// <summary>
  11734. /// 团组模块 - 出入境费用-草稿-移动端 - 实时汇率、签证费用、机票费用 Tips
  11735. /// </summary>
  11736. /// <returns></returns>
  11737. [HttpPost]
  11738. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11739. public async Task<IActionResult> EnterExitCostDraftMobileFeeTips(EnterExitCostDraftMobileFeeTipsDto dto)
  11740. {
  11741. int portType = dto.PortType;
  11742. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11743. var tipsData = new List<int>() { 1, 2, 3 };
  11744. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  11745. if (dto.TipsType == 1)
  11746. {
  11747. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  11748. }
  11749. else if (dto.TipsType == 2)
  11750. {
  11751. if (portType == 2)
  11752. {
  11753. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11754. }
  11755. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11756. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  11757. .Select(x => x.NationalTravelFeeId)
  11758. .Distinct()
  11759. .ToListAsync();
  11760. if (portType == 2)
  11761. {
  11762. if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  11763. }
  11764. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  11765. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  11766. .Select(x => x.Country)
  11767. .Distinct()
  11768. .ToArrayAsync();
  11769. if (portType == 2)
  11770. {
  11771. if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  11772. }
  11773. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  11774. return Ok(JsonView(true, "查询成功!", new
  11775. {
  11776. totalAmt = totalAmt,
  11777. remark = remark
  11778. }));
  11779. }
  11780. else if (dto.TipsType == 3)
  11781. {
  11782. return Ok(JsonView(false, "暂无机票费用提示信息!"));
  11783. }
  11784. return Ok(JsonView(false));
  11785. }
  11786. /// <summary>
  11787. /// 团组模块 - 出入境费用-草稿-移动端 - 创建
  11788. /// </summary>
  11789. /// <returns></returns>
  11790. [HttpPost]
  11791. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11792. public async Task<IActionResult> EnterExitCostDraftMobileCreate(EnterExitCostDraftMobileCreateDto dto)
  11793. {
  11794. if (string.IsNullOrEmpty(dto.DraftName)) return Ok(JsonView(false, "草稿名称为空!"));
  11795. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11796. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11797. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DraftName.Equals(dto.DraftName) && it.IsDel == 0);
  11798. if (eecInfo != null) return Ok(JsonView(false, "草稿名称重复!"));
  11799. var rateInfos = await EnterExitCostMobileGetCurrencyInit();
  11800. var info = new Grp_EnterExitCostDraft()
  11801. {
  11802. ProvinceId = dto.ProvinceId,
  11803. DraftName = dto.DraftName,
  11804. CurrencyRemark = CommonFun.GetCurrencyChinaToString(rateInfos),
  11805. CreateUserId = dto.CurrUserId
  11806. };
  11807. _sqlSugar.BeginTran();
  11808. var draftId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  11809. if (draftId < 1)
  11810. {
  11811. _sqlSugar.RollbackTran();
  11812. return Ok(JsonView(false, "草稿创建失败!"));
  11813. }
  11814. //添加默认权限
  11815. await _enterExitCostDraftRep.InitPerm(draftId, dto.CurrUserId);
  11816. _sqlSugar.CommitTran();
  11817. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(draftId, dto.CurrUserId);
  11818. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  11819. mobileInfo.Id = draftId;
  11820. mobileInfo.DraftName = dto.DraftName;
  11821. mobileInfo.Currencys = rateInfos;
  11822. mobileInfo.IsAssignPerm = assignPerm;
  11823. return Ok(JsonView(mobileInfo));
  11824. }
  11825. /// <summary>
  11826. /// 出入境费用-草稿-移动端 查看编辑提示消息
  11827. /// </summary>
  11828. private static string _viewPermStr = $"未分配查看权限,如要查看,请联系市场部或国交部负责人!";
  11829. /// <summary>
  11830. /// 团组模块 - 出入境费用-草稿-移动端 - ParentInfo
  11831. /// </summary>
  11832. /// <returns></returns>
  11833. [HttpPost]
  11834. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11835. public async Task<IActionResult> EnterExitCostDraftMobileParentInfo(EnterExitCostDraftMobileParentInfoDto dto)
  11836. {
  11837. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11838. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11839. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  11840. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  11841. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  11842. if (eecInfo == null) return Ok(JsonView(mobileInfo));
  11843. //验证查看编辑权限
  11844. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11845. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  11846. mobileInfo = _mapper.Map<EnterExitCostDraftMobileParentInfoView>(eecInfo);
  11847. mobileInfo.ProvinceId = eecInfo.ProvinceId;
  11848. mobileInfo.IsAssignPerm = assignPerm;
  11849. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11850. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  11851. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  11852. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  11853. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  11854. {
  11855. ParentId = dac.ParentId,
  11856. SubId = dac.Id,
  11857. Type = dac.Type,
  11858. Days = dac.Days,
  11859. NationalTravelFeeId = dac.NationalTravelFeeId,
  11860. Arae = $"{ntf.Country}-{ntf.City}",
  11861. Cost = dac.Cost,
  11862. Currency = dac.Currency,
  11863. CurrencyName = sd.Name,
  11864. SubTotal = dac.SubTotal,
  11865. })
  11866. .ToList();
  11867. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  11868. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  11869. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  11870. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  11871. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  11872. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  11873. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  11874. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  11875. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  11876. //其他款项
  11877. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  11878. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  11879. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  11880. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  11881. .OrderBy((dop, sd1, sd2) => dop.Index)
  11882. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  11883. {
  11884. ParentId = dop.ParentId,
  11885. SubId = dop.Id,
  11886. Index = dop.Index,
  11887. SetDataId = dop.SetDataId,
  11888. SetDataName = sd1.Name,
  11889. Cost = dop.Cost,
  11890. Currency = dop.Currency,
  11891. CurrencyName = sd2.Remark,
  11892. SubTotal = dop.SubTotal,
  11893. Remark = dop.Remark,
  11894. })
  11895. .ToArray();
  11896. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  11897. return Ok(mobileInfo);
  11898. }
  11899. /// <summary>
  11900. /// 团组模块 - 出入境费用-草稿-移动端 - SubInfo
  11901. /// </summary>
  11902. /// <returns></returns>
  11903. [HttpPost]
  11904. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11905. public async Task<IActionResult> EnterExitCostDraftMobileSubInfo(PostEnterExitCostDraftMobileSubInfoDto dto)
  11906. {
  11907. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11908. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11909. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11910. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  11911. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  11912. //验证查看编辑权限
  11913. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11914. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  11915. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  11916. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  11917. var subType = dto.SubType;
  11918. if (subType == 1) //1:境内费用
  11919. {
  11920. var oneData = new ChoiceOneMobileSubInfoView()
  11921. {
  11922. Id = eecInfo.Id,
  11923. ChoiceOne = eecInfo.ChoiceOne,
  11924. ChoiceOneTotalCost = eecInfo.InsidePay,
  11925. Visa = eecInfo.Visa,
  11926. VisaRemark = eecInfo.VisaRemark,
  11927. YiMiao = eecInfo.YiMiao,
  11928. HeSuan = eecInfo.HeSuan,
  11929. Service = eecInfo.Service,
  11930. Ticket = eecInfo.Ticket,
  11931. Safe = eecInfo.Safe,
  11932. FirstItemRemark = eecInfo.FirstItemRemark
  11933. };
  11934. return Ok(JsonView(oneData));
  11935. }
  11936. else if (subType == 2) //2:国际旅费
  11937. {
  11938. var twoData = new ChoiceTwoMobileSubInfoView()
  11939. {
  11940. Id = eecInfo.Id,
  11941. ChoiceTwoJJ = eecInfo.SumJJC,
  11942. OutsideJJPay = eecInfo.OutsideJJPay,
  11943. ChoiceTwoGW = eecInfo.SumGWC,
  11944. OutsideGWPay = eecInfo.OutsideGWPay,
  11945. ChoiceTwoTD = eecInfo.SumTDC,
  11946. OutsideTDPay = eecInfo.OutsideTDPay,
  11947. AirJJ = eecInfo.AirJJ,
  11948. AirGW = eecInfo.AirGW,
  11949. AirTD = eecInfo.AirTD,
  11950. CityTranffic = eecInfo.CityTranffic,
  11951. TwoItemRemark = eecInfo.TwoItemRemark
  11952. };
  11953. return Ok(JsonView(twoData));
  11954. }
  11955. else if (subType == 3) //3:住宿费
  11956. {
  11957. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11958. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  11959. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  11960. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 1)
  11961. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  11962. {
  11963. ParentId = dac.ParentId,
  11964. SubId = dac.Id,
  11965. Type = dac.Type,
  11966. Days = dac.Days,
  11967. NationalTravelFeeId = dac.NationalTravelFeeId,
  11968. Arae = $"{ntf.Country}-{ntf.City}",
  11969. Cost = dac.Cost,
  11970. Currency = dac.Currency,
  11971. CurrencyName = sd.Name,
  11972. SubTotal = dac.SubTotal,
  11973. })
  11974. .ToArray();
  11975. var data = new ChoiceDraftMobileSubInfo3To6View()
  11976. {
  11977. ParentId = eecInfo.Id,
  11978. Choice = eecInfo.ChoiceThree,
  11979. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  11980. Details = dayAndCostDatas
  11981. };
  11982. return Ok(JsonView(data));
  11983. }
  11984. else if (subType == 4) //4:伙食费
  11985. {
  11986. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11987. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  11988. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  11989. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 2)
  11990. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  11991. {
  11992. ParentId = dac.ParentId,
  11993. SubId = dac.Id,
  11994. Type = dac.Type,
  11995. Days = dac.Days,
  11996. NationalTravelFeeId = dac.NationalTravelFeeId,
  11997. Arae = $"{ntf.Country}-{ntf.City}",
  11998. Cost = dac.Cost,
  11999. Currency = dac.Currency,
  12000. CurrencyName = sd.Name,
  12001. SubTotal = dac.SubTotal,
  12002. })
  12003. .ToArray();
  12004. var data = new ChoiceDraftMobileSubInfo3To6View()
  12005. {
  12006. ParentId = eecInfo.Id,
  12007. Choice = eecInfo.ChoiceFour,
  12008. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  12009. Details = dayAndCostDatas
  12010. };
  12011. return Ok(JsonView(data));
  12012. }
  12013. else if (subType == 5) //5:公杂费
  12014. {
  12015. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  12016. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  12017. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  12018. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 3)
  12019. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  12020. {
  12021. ParentId = dac.ParentId,
  12022. SubId = dac.Id,
  12023. Type = dac.Type,
  12024. Days = dac.Days,
  12025. NationalTravelFeeId = dac.NationalTravelFeeId,
  12026. Arae = $"{ntf.Country}-{ntf.City}",
  12027. Cost = dac.Cost,
  12028. Currency = dac.Currency,
  12029. CurrencyName = sd.Name,
  12030. SubTotal = dac.SubTotal,
  12031. })
  12032. .ToArray();
  12033. var data = new ChoiceDraftMobileSubInfo3To6View()
  12034. {
  12035. ParentId = eecInfo.Id,
  12036. Choice = eecInfo.ChoiceFive,
  12037. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  12038. Details = dayAndCostDatas
  12039. };
  12040. return Ok(JsonView(data));
  12041. }
  12042. else if (subType == 6) //6:培训费
  12043. {
  12044. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  12045. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  12046. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  12047. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 4)
  12048. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  12049. {
  12050. ParentId = dac.ParentId,
  12051. SubId = dac.Id,
  12052. Type = dac.Type,
  12053. Days = dac.Days,
  12054. NationalTravelFeeId = dac.NationalTravelFeeId,
  12055. Arae = $"{ntf.Country}-{ntf.City}",
  12056. Cost = dac.Cost,
  12057. Currency = dac.Currency,
  12058. CurrencyName = sd.Name,
  12059. SubTotal = dac.SubTotal,
  12060. })
  12061. .ToArray();
  12062. var data = new ChoiceDraftMobileSubInfo3To6View()
  12063. {
  12064. ParentId = eecInfo.Id,
  12065. Choice = eecInfo.ChoiceSix,
  12066. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  12067. Details = dayAndCostDatas
  12068. };
  12069. return Ok(JsonView(data));
  12070. }
  12071. else if (subType == 7) //7:其他
  12072. {
  12073. //其他款项
  12074. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  12075. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  12076. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  12077. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  12078. .OrderBy((dop, sd1, sd2) => dop.Index)
  12079. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  12080. {
  12081. ParentId = dop.ParentId,
  12082. SubId = dop.Id,
  12083. Index = dop.Index,
  12084. SetDataId = dop.SetDataId,
  12085. SetDataName = sd1.Name,
  12086. Cost = dop.Cost,
  12087. Currency = dop.Currency,
  12088. CurrencyName = sd2.Name,
  12089. SubTotal = dop.SubTotal,
  12090. Remark = dop.Remark,
  12091. })
  12092. .ToArray();
  12093. var data = new ChoiceSevenDraftMobileSubInfoView()
  12094. {
  12095. ParentId = eecInfo.Id,
  12096. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  12097. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  12098. Details = otherData
  12099. };
  12100. return Ok(JsonView(data));
  12101. }
  12102. return Ok(JsonView(false));
  12103. }
  12104. #region op
  12105. ///// <summary>
  12106. ///// 移动端更新费用消息通知
  12107. ///// </summary>
  12108. ///// <param name="draftId"></param>
  12109. ///// <param name="id"></param>
  12110. ///// <param name="currUserId"></param>
  12111. //private async Task EnterExitCostDraftMobileOpNotice(int draftId, int id, int currUserId)
  12112. //{
  12113. // try
  12114. // {
  12115. // ////生成默认文件pdf并且通知人员
  12116. // //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  12117. // //{
  12118. // // DiId = draftId,
  12119. // // ExportType = 1,
  12120. // // SubTypeId = 1005
  12121. // //}, "pdf");
  12122. // ////发送通知
  12123. // //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  12124. // //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  12125. // //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  12126. // //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(draftId, new List<string>() { "208", "233", "21" }, currUserId, url);
  12127. // ////汇率信息记录
  12128. // //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  12129. // }
  12130. // catch (Exception ex)
  12131. // {
  12132. // //记录日志
  12133. // throw;
  12134. // }
  12135. //}
  12136. /// <summary>
  12137. /// 验证出入境费用数据是否存在
  12138. /// 不存在添加
  12139. /// </summary>
  12140. /// <param name="draftId"></param>
  12141. /// <param name="currUserId"></param>
  12142. /// <returns></returns>
  12143. /// <exception cref="CustomException"></exception>
  12144. private async Task<int> EnterExitCostDraftVerifyIsNull(int draftId, int currUserId)
  12145. {
  12146. var parentId = 0;
  12147. var info = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).OrderByDescending(x => x.CreateTime).FirstAsync();
  12148. if (info != null) parentId = info.Id;
  12149. else
  12150. {
  12151. var currencys = await EnterExitCostDraftMobileGetCurrencyInit();
  12152. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  12153. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  12154. parentId = addId;
  12155. }
  12156. return parentId;
  12157. }
  12158. /// <summary>
  12159. /// 团组模块 - 出入境费用-草稿-移动端 - 查看权限用户
  12160. /// </summary>
  12161. /// <returns></returns>
  12162. [HttpPost]
  12163. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12164. public async Task<IActionResult> EnterExitCostDraftMobileViewPermissionUsers(EnterExitCostDraftMobileViewPermissionUsersDto dto)
  12165. {
  12166. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  12167. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12168. //验证查看权限
  12169. (bool isView, bool isSet) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  12170. if (!isView) return Ok(JsonView(false, _viewPermStr));
  12171. var userIds = await _sqlSugar
  12172. .Queryable<Grp_EnterExitCostDraftPermission>()
  12173. .Where(x => x.IsDel == 0 && x.DraftId == dto.DraftId)
  12174. .Select(x => x.UserId)
  12175. .ToArrayAsync();
  12176. var perUsers = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  12177. var perUsersView = new List<dynamic>();
  12178. var feeBasePerm = AppSettingsHelper.Get<FeeBasePermView>("FeeBasePerm");
  12179. var viewPermissionData = new List<PermissionViewUserview>();
  12180. if (feeBasePerm.Any())
  12181. {
  12182. foreach (var item in feeBasePerm)
  12183. {
  12184. if (item.Users.Any())
  12185. {
  12186. viewPermissionData.AddRange(item.Users);
  12187. }
  12188. }
  12189. }
  12190. foreach (var item in perUsers)
  12191. {
  12192. bool isView1 = false;
  12193. if (userIds.Any(x => x == item.Id)) isView1 = true;
  12194. else if (viewPermissionData.Any(x => x.Id == dto.CurrUserId) && item.Id == dto.CurrUserId) isView1 = true;
  12195. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  12196. }
  12197. return Ok(JsonView(perUsersView));
  12198. }
  12199. /// <summary>
  12200. /// 团组模块 - 出入境费用-草稿-移动端 - 设置view权限
  12201. /// </summary>
  12202. /// <returns></returns>
  12203. [HttpPost]
  12204. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12205. public async Task<IActionResult> EnterExitCostDraftMobileSetViewPermissiion(EnterExitCostDraftMobileSetViewPermissiionDto dto)
  12206. {
  12207. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12208. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  12209. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  12210. //验证查看编辑权限
  12211. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  12212. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  12213. var permissions = new List<Grp_EnterExitCostDraftPermission>() { };
  12214. foreach (var userId in dto.UserIds)
  12215. {
  12216. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  12217. }
  12218. if (permissions.Any())
  12219. {
  12220. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  12221. {
  12222. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  12223. }
  12224. _sqlSugar.BeginTran();
  12225. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  12226. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  12227. if (result < 1)
  12228. {
  12229. _sqlSugar.RollbackTran();
  12230. return Ok(JsonView(false));
  12231. }
  12232. _sqlSugar.CommitTran();
  12233. return Ok(JsonView(true));
  12234. }
  12235. return Ok(JsonView(false));
  12236. }
  12237. /// <summary>
  12238. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 省份
  12239. /// </summary>
  12240. /// <returns></returns>
  12241. [HttpPost]
  12242. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12243. public async Task<IActionResult> EnterExitCostDraftMobileOpProv(EnterExitCostDraftMobileOpProvDto dto)
  12244. {
  12245. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12246. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12247. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12248. if (dto.ProvinceId < 1) return Ok(JsonView(false, "请传入有效的省份Id!"));
  12249. int id = dto.DraftId;
  12250. if (id <= 0) //add
  12251. {
  12252. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  12253. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  12254. if (add < 1) return Ok(JsonView(false));
  12255. id = add;
  12256. }
  12257. else //update
  12258. {
  12259. //验证查看编辑权限
  12260. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  12261. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  12262. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  12263. if (upd < 1) return Ok(JsonView(false));
  12264. }
  12265. return Ok(JsonView(new { parentId = id }));
  12266. }
  12267. /// <summary>
  12268. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 汇率
  12269. /// </summary>
  12270. /// <returns></returns>
  12271. [HttpPost]
  12272. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12273. public async Task<IActionResult> EnterExitCostDraftMobileOpRate(PostEnterExitCostDraftMobileFeeRateOpDto dto)
  12274. {
  12275. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12276. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12277. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12278. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  12279. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  12280. int id = dto.DraftId;
  12281. if (id <= 0) //add
  12282. {
  12283. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  12284. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId, CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  12285. if (add < 1) return Ok(JsonView(false));
  12286. id = add;
  12287. }
  12288. else //update
  12289. {
  12290. //验证查看编辑权限
  12291. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  12292. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  12293. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  12294. if (upd < 1) return Ok(JsonView(false));
  12295. }
  12296. #region 汇率变更时更改币种相关费用
  12297. var opDayCosts = new List<Grp_DayAndCostDraft>();
  12298. var opDayOtherCosts = new List<Grp_DayOtherPriceDraft>();
  12299. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  12300. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  12301. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  12302. .Where((dac, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  12303. .Select((dac, sd) => new
  12304. {
  12305. dac.Id,
  12306. dac.ParentId,
  12307. CurrencyCode = sd.Name,
  12308. dac.Cost
  12309. })
  12310. .ToList();
  12311. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  12312. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  12313. .Where((dop, sd) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  12314. .Select((dop, sd) => new
  12315. {
  12316. dop.Id,
  12317. dop.ParentId,
  12318. CurrencyCode = sd.Name,
  12319. dop.Cost
  12320. })
  12321. .ToList();
  12322. if (dayCosts.Count > 0)
  12323. {
  12324. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  12325. foreach (var dc in new_dayCosts)
  12326. {
  12327. var thisCurrency = dc.Key.ToUpper();
  12328. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  12329. if (thisRate == 0.00M) continue;
  12330. foreach (var dcSub in dc)
  12331. {
  12332. opDayCosts.Add(new Grp_DayAndCostDraft()
  12333. {
  12334. Id = dcSub.Id,
  12335. ParentId = dcSub.ParentId,
  12336. Cost = dcSub.Cost,
  12337. SubTotal = dcSub.Cost * thisRate,
  12338. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now:yyyy-MM-dd HH:mm:ss}、opUserId:{dto.CurrUserId}]"
  12339. });
  12340. }
  12341. }
  12342. if (opDayCosts.Count > 0)
  12343. {
  12344. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  12345. }
  12346. }
  12347. if (dayOtherCosts.Count > 0)
  12348. {
  12349. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  12350. foreach (var dc in new_dayOtherCosts)
  12351. {
  12352. var thisCurrency = dc.Key.ToUpper();
  12353. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  12354. if (thisRate == 0.00M) continue;
  12355. foreach (var dcSub in dc)
  12356. {
  12357. opDayOtherCosts.Add(new Grp_DayOtherPriceDraft()
  12358. {
  12359. Id = dcSub.Id,
  12360. ParentId = dcSub.ParentId,
  12361. Cost = dcSub.Cost,
  12362. SubTotal = dcSub.Cost * thisRate,
  12363. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  12364. });
  12365. }
  12366. }
  12367. if (opDayOtherCosts.Count > 0)
  12368. {
  12369. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  12370. }
  12371. }
  12372. #endregion
  12373. ////消息通知
  12374. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  12375. ////汇率信息记录
  12376. //await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  12377. return Ok(JsonView(new { parentId = id }));
  12378. }
  12379. /// <summary>
  12380. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 复选框
  12381. /// </summary>
  12382. /// <returns></returns>
  12383. [HttpPost]
  12384. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12385. public async Task<IActionResult> EnterExitCostDraftMobileOpCheckbox(PostEnterExitCostDraftMobileFeeOpCheckboxDto dto)
  12386. {
  12387. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12388. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  12389. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12390. var checkboxInfo = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  12391. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  12392. int id = dto.DraftId;
  12393. if (id <= 0) //add
  12394. {
  12395. checkboxInfo.ProvinceId = dto.ProvinceId;
  12396. checkboxInfo.CreateUserId = dto.CurrUserId;
  12397. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostDraftMobileGetCurrencyInit());
  12398. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  12399. if (add < 1) return Ok(JsonView(false));
  12400. }
  12401. else //update
  12402. {
  12403. var upd = await _sqlSugar.Updateable(checkboxInfo)
  12404. .UpdateColumns(x => new
  12405. {
  12406. x.ChoiceOne,
  12407. x.ChoiceTwo,
  12408. x.SumJJC,
  12409. x.SumGWC,
  12410. x.SumTDC,
  12411. x.ChoiceThree,
  12412. x.ChoiceFour,
  12413. x.ChoiceFive,
  12414. x.ChoiceSix,
  12415. x.OtherExpenses_Checked
  12416. })
  12417. .Where(x => x.Id == id)
  12418. .ExecuteCommandAsync();
  12419. if (upd < 1) return Ok(JsonView(false));
  12420. }
  12421. return Ok(JsonView(new { parentId = id }));
  12422. }
  12423. /// <summary>
  12424. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 3-7项复选框单个复选框
  12425. /// </summary>
  12426. /// <returns></returns>
  12427. [HttpPost]
  12428. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12429. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleCheckbox(EnterExitCostDarftMobileOpSingleCheckboxDto dto)
  12430. {
  12431. int itemTypeId = dto.ItemType, currUserId = dto.CurrUserId, draftId = dto.DraftId, isSelected = dto.IsSelected;
  12432. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  12433. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12434. if (draftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  12435. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12436. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  12437. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  12438. var checkboxInfo = new Grp_EnterExitCostDraft()
  12439. {
  12440. Id = draftId,
  12441. ProvinceId = dto.ProvinceId,
  12442. CreateUserId = currUserId
  12443. };
  12444. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  12445. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  12446. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  12447. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  12448. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  12449. if (draftId <= 0) //add
  12450. {
  12451. checkboxInfo.CreateUserId = dto.CurrUserId;
  12452. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  12453. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  12454. if (add < 1) return Ok(JsonView(false));
  12455. }
  12456. else //update
  12457. {
  12458. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>()
  12459. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  12460. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  12461. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  12462. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  12463. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  12464. .Where(x => x.Id == draftId)
  12465. .ExecuteCommandAsync();
  12466. if (upd < 1) return Ok(JsonView(false));
  12467. }
  12468. return Ok(JsonView(new { parentId = draftId }));
  12469. }
  12470. /// <summary>
  12471. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 境内费用 Step1
  12472. /// </summary>
  12473. /// <returns></returns>
  12474. [HttpPost]
  12475. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12476. public async Task<IActionResult> EnterExitCostDraftMobileOpStep1(PostEnterExitCostDraftMobileOpStep1Dto dto)
  12477. {
  12478. int id = dto.DraftId, currUserId = dto.CurrUserId;
  12479. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12480. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  12481. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12482. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  12483. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  12484. info.ProvinceId = dto.ProvinceId;
  12485. info.FirstItemRemark = dto.FirstItemRemark;
  12486. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  12487. if (id <= 0) //add
  12488. {
  12489. info.CreateUserId = dto.CurrUserId;
  12490. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  12491. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  12492. if (add < 1) return Ok(JsonView(false));
  12493. id = add;
  12494. }
  12495. else //update
  12496. {
  12497. var upd = await _sqlSugar.Updateable(info)
  12498. .UpdateColumns(x => new
  12499. {
  12500. x.ChoiceOne,
  12501. x.InsidePay,
  12502. x.VisaRemark,
  12503. x.Visa,
  12504. x.Service,
  12505. x.Safe,
  12506. x.Ticket,
  12507. x.HeSuan,
  12508. x.YiMiao,
  12509. x.FirstItemRemark
  12510. })
  12511. .Where(x => x.Id == id)
  12512. .ExecuteCommandAsync();
  12513. if (upd < 1) return Ok(JsonView(false));
  12514. }
  12515. ////消息通知
  12516. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  12517. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  12518. }
  12519. /// <summary>
  12520. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 国际旅费 Step2
  12521. /// </summary>
  12522. /// <returns></returns>
  12523. [HttpPost]
  12524. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12525. public async Task<IActionResult> EnterExitCostDraftMobileOpStep2(PostEnterExitCostDraftMobileOpStep2Dto dto)
  12526. {
  12527. int id = dto.DraftId;
  12528. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12529. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  12530. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12531. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  12532. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  12533. info.ProvinceId = dto.ProvinceId;
  12534. info.OutsideJJPay = dto.OutsideJJPay;
  12535. info.OutsideGWPay = dto.OutsideGWPay;
  12536. info.OutsideTDPay = dto.OutsideTDPay;
  12537. info.AirJJ = dto.AirJJ;
  12538. info.AirGW = dto.AirGW;
  12539. info.AirTD = dto.AirTD;
  12540. info.CityTranffic = dto.CityTranffic;
  12541. info.TwoItemRemark = dto.TwoItemRemark;
  12542. info.SumJJC = dto.ChoiceTwoJJ;
  12543. info.SumGWC = dto.ChoiceTwoGW;
  12544. info.SumTDC = dto.ChoiceTwoTD;
  12545. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  12546. if (id <= 0) //add
  12547. {
  12548. info.CreateUserId = dto.CurrUserId;
  12549. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  12550. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  12551. if (addId <= 0) return Ok(JsonView(false));
  12552. id = addId;
  12553. }
  12554. else //update
  12555. {
  12556. var upd = await _sqlSugar.Updateable(info)
  12557. .UpdateColumns(x => new
  12558. {
  12559. x.SumJJC,
  12560. x.OutsideJJPay,
  12561. x.SumGWC,
  12562. x.OutsideGWPay,
  12563. x.SumTDC,
  12564. x.OutsideTDPay,
  12565. x.AirJJ,
  12566. x.AirGW,
  12567. x.AirTD,
  12568. x.CityTranffic,
  12569. x.TwoItemRemark
  12570. })
  12571. .Where(x => x.Id == id)
  12572. .ExecuteCommandAsync();
  12573. if (upd < 1) return Ok(JsonView(false));
  12574. }
  12575. jjcItemTotal = info.AirJJ + info.CityTranffic;
  12576. gwcItemTotal = info.AirGW + info.CityTranffic;
  12577. tdcItemTotal = info.AirTD + info.CityTranffic;
  12578. ////消息通知
  12579. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  12580. return Ok(JsonView(new
  12581. {
  12582. parentId = id,
  12583. choiceTwoJJ = dto.ChoiceTwoJJ,
  12584. jjcItemTotal = jjcItemTotal,
  12585. choiceTwoGW = dto.ChoiceTwoGW,
  12586. gwcItemTotal = gwcItemTotal,
  12587. choiceTwoTD = dto.ChoiceTwoTD,
  12588. tdcItemTotal = tdcItemTotal
  12589. }));
  12590. }
  12591. /// <summary>
  12592. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  12593. /// </summary>
  12594. /// <returns></returns>
  12595. [HttpPost]
  12596. [ApiExplorerSettings(IgnoreApi = true)]
  12597. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12598. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep3To6(PostEnterExitCostDraftMobileOpStep3To6Dto dto)
  12599. {
  12600. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12601. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  12602. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12603. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  12604. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  12605. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  12606. var infos1 = _mapper.Map<List<Grp_DayAndCostDraft>>(dto.Infos);
  12607. var infos = infos1.Select(x => new Grp_DayAndCostDraft
  12608. {
  12609. Id = x.Id,
  12610. ParentId = dto.DraftId,
  12611. Type = dto.FeeType,
  12612. Days = x.Days,
  12613. NationalTravelFeeId = x.NationalTravelFeeId,
  12614. Cost = x.Cost,
  12615. Currency = x.Currency,
  12616. SubTotal = x.SubTotal,
  12617. CreateUserId = dto.CurrUserId
  12618. })
  12619. .ToList();
  12620. var adds = infos.Where(x => x.Id <= 0).ToList();
  12621. var upds = infos.Where(x => x.Id > 0).ToList();
  12622. if (adds.Count > 0)
  12623. {
  12624. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  12625. if (add < 1) return Ok(JsonView(false));
  12626. }
  12627. if (upds.Count > 0)
  12628. {
  12629. var upd = await _sqlSugar.Updateable(adds)
  12630. .UpdateColumns(x => new
  12631. {
  12632. x.Days,
  12633. x.NationalTravelFeeId,
  12634. x.Cost,
  12635. x.Currency,
  12636. x.SubTotal
  12637. })
  12638. .WhereColumns(x => new { x.Id })
  12639. .ExecuteCommandAsync();
  12640. if (upd < 1) return Ok(JsonView(false));
  12641. }
  12642. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  12643. ////消息通知
  12644. //var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).First()?.Id ?? 0;
  12645. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  12646. return Ok(JsonView(new { itemTotal = itemTotal }));
  12647. }
  12648. /// <summary>
  12649. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  12650. /// </summary>
  12651. /// <returns></returns>
  12652. [HttpPost]
  12653. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12654. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep3To6(PostEnterExitCostDraftMobileOpSingleStep3To6Dto dto)
  12655. {
  12656. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  12657. int subId = dto.SubId, feeType = dto.FeeType;
  12658. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12659. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  12660. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12661. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  12662. var subInfo = _mapper.Map<Grp_DayAndCostDraft>(dto);
  12663. subInfo.Id = subId;
  12664. subInfo.ParentId = dto.DraftId;
  12665. if (feeType == 3) subInfo.Type = 1;
  12666. else if (feeType == 4) subInfo.Type = 2;
  12667. else if (feeType == 5) subInfo.Type = 3;
  12668. else if (feeType == 6) subInfo.Type = 4;
  12669. subInfo.CreateUserId = dto.CurrUserId;
  12670. int parentId = await EnterExitCostDraftVerifyIsNull(dto.DraftId, dto.CurrUserId); //主表验证
  12671. if (parentId < 1) return Ok(JsonView(false));
  12672. //子表op
  12673. if (subId < 1)
  12674. {
  12675. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  12676. if (subAdd < 1) return Ok(JsonView(false));
  12677. }
  12678. else
  12679. {
  12680. var subUpd = await _sqlSugar.Updateable(subInfo)
  12681. .UpdateColumns(x => new
  12682. {
  12683. x.Days,
  12684. x.NationalTravelFeeId,
  12685. x.Cost,
  12686. x.Currency,
  12687. x.SubTotal
  12688. })
  12689. .WhereColumns(x => new { x.Id })
  12690. .ExecuteCommandAsync();
  12691. if (subUpd < 1) return Ok(JsonView(false));
  12692. }
  12693. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == feeType).Sum(x => x.SubTotal);
  12694. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  12695. }
  12696. /// <summary>
  12697. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-批量 Step7
  12698. /// </summary>
  12699. /// <returns></returns>
  12700. [HttpPost]
  12701. [ApiExplorerSettings(IgnoreApi = true)]
  12702. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12703. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep7(PostEnterExitCostDraftMobileOpStep7Dto dto)
  12704. {
  12705. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12706. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  12707. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12708. var infos1 = _mapper.Map<List<Grp_DayOtherPriceDraft>>(dto.Infos);
  12709. var infos = infos1.Select(x => new Grp_DayOtherPriceDraft()
  12710. {
  12711. Id = x.Id,
  12712. ParentId = dto.DraftId,
  12713. SetDataId = x.SetDataId,
  12714. Index = x.Index,
  12715. Cost = x.Cost,
  12716. Currency = x.Currency,
  12717. SubTotal = x.SubTotal,
  12718. CreateUserId = dto.CurrUserId,
  12719. Remark = x.Remark
  12720. }).ToList();
  12721. var adds = infos.Where(x => x.Id <= 0).ToList();
  12722. var upds = infos.Where(x => x.Id > 0).ToList();
  12723. if (adds.Count > 0)
  12724. {
  12725. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  12726. if (add < 1) return Ok(JsonView(false));
  12727. }
  12728. if (upds.Count > 0)
  12729. {
  12730. var upd = await _sqlSugar.Updateable(adds)
  12731. .UpdateColumns(x => new
  12732. {
  12733. x.Index,
  12734. x.SetDataId,
  12735. x.Cost,
  12736. x.Currency,
  12737. x.SubTotal,
  12738. x.Remark
  12739. })
  12740. .WhereColumns(x => new { x.Id })
  12741. .ExecuteCommandAsync();
  12742. if (upd < 1) return Ok(JsonView(false));
  12743. }
  12744. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).Sum(x => x.SubTotal);
  12745. //消息通知
  12746. //var id = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == dto.DraftId).First()?.Id ?? 0;
  12747. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  12748. return Ok(JsonView(new { itemTotal = itemTotal }));
  12749. }
  12750. /// <summary>
  12751. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-单条 Step7
  12752. /// </summary>
  12753. /// <returns></returns>
  12754. [HttpPost]
  12755. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12756. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep7(PostEnterExitCostDraftMobileOpSingleStep7Dto dto)
  12757. {
  12758. int subId = dto.SubId, id = dto.DraftId;
  12759. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12760. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  12761. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12762. var subInfo = _mapper.Map<Grp_DayOtherPriceDraft>(dto);
  12763. subInfo.Id = subId;
  12764. subInfo.ParentId = id;
  12765. subInfo.CreateUserId = dto.CurrUserId;
  12766. int parentId = await EnterExitCostDraftVerifyIsNull(id, dto.CurrUserId); //主表验证
  12767. if (parentId < 1) return Ok(JsonView(false));
  12768. #region 子表op
  12769. if (subId < 1)//add
  12770. {
  12771. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  12772. if (subAdd < 1) return Ok(JsonView(false));
  12773. }
  12774. else //upd
  12775. {
  12776. var subUpd = await _sqlSugar.Updateable(subInfo)
  12777. .UpdateColumns(x => new
  12778. {
  12779. x.Index,
  12780. x.SetDataId,
  12781. x.Cost,
  12782. x.Currency,
  12783. x.SubTotal,
  12784. x.Remark
  12785. })
  12786. .WhereColumns(x => new { x.Id })
  12787. .ExecuteCommandAsync();
  12788. if (subUpd < 1) return Ok(JsonView(false));
  12789. }
  12790. #endregion
  12791. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == id).Sum(x => x.SubTotal);
  12792. ////消息通知
  12793. //await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  12794. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  12795. }
  12796. /// <summary>
  12797. /// 团组模块 - 出入境费用-草稿-移动端 - 3-6子项删除
  12798. /// </summary>
  12799. /// <returns></returns>
  12800. [HttpPost]
  12801. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12802. public async Task<IActionResult> EnterExitCostDraftMobileSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  12803. {
  12804. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  12805. if (data.Code != 0)
  12806. {
  12807. return Ok(JsonView(false, data.Msg));
  12808. }
  12809. return Ok(JsonView(true, "操作成功!", data.Data));
  12810. }
  12811. /// <summary>
  12812. /// 团组模块 - 出入境费用-草稿-移动端 - 其他费用删除
  12813. /// </summary>
  12814. /// <param name="dto"></param>
  12815. /// <returns></returns>
  12816. [HttpPost]
  12817. public IActionResult EnterExitCostDraftMobileOtherFeeDel(EnterExitCostDraftSubItemDelDto dto)
  12818. {
  12819. var data = new Grp_DayOtherPriceDraft()
  12820. {
  12821. Id = dto.Id,
  12822. IsDel = 1,
  12823. DeleteUserId = dto.DeleteUserId,
  12824. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  12825. };
  12826. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  12827. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  12828. return Ok(JsonView(false, "删除失败!"));
  12829. }
  12830. #endregion
  12831. #endregion
  12832. #region 团组经理模块 出入境费用报价表
  12833. /// <summary>
  12834. /// 团组模块 - 出入境费用报价表 - 初始化数据源(币种类型)
  12835. /// </summary>
  12836. /// <returns></returns>
  12837. [HttpPost]
  12838. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12839. public async Task<IActionResult> EnterExitCostQuoteInitData(PortDtoBase dto)
  12840. {
  12841. var initRates = await GeneralMethod.EnterExitCostInitRate();
  12842. var liveRates = await GeneralMethod.EnterExitCostLiveRate();
  12843. var cnyInfo = new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.0000M };
  12844. initRates.Insert(0, cnyInfo);
  12845. liveRates.Insert(0, cnyInfo);
  12846. return Ok(JsonView(true, "查询成功!", new
  12847. {
  12848. InitRates = initRates,
  12849. LiveRates = liveRates
  12850. }));
  12851. }
  12852. /// <summary>
  12853. /// 团组模块 - 出入境费用报价表 - 报价表名称列表
  12854. /// </summary>
  12855. /// <returns></returns>
  12856. [HttpPost]
  12857. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12858. public async Task<IActionResult> EnterExitCostQuoteNameList(EnterExitCostQuoteNameListDto dto)
  12859. {
  12860. return Ok(await _enterExitCostQuoteRep.QuoteNameListAsync(dto));
  12861. }
  12862. /// <summary>
  12863. /// 团组模块 - 出入境费用报价表 - 团组名称列表
  12864. /// </summary>
  12865. /// <returns></returns>
  12866. [HttpPost]
  12867. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12868. public async Task<IActionResult> EnterExitCostQuoteGroupNameList(EnterExitCostQuoteGroupNameListDto dto)
  12869. {
  12870. return Ok(await _enterExitCostQuoteRep.GroupNameListAsync(dto));
  12871. }
  12872. /// <summary>
  12873. /// 团组模块 - 出入境费用报价表 - 根据团组Id获出入境费用相关信息
  12874. /// </summary>
  12875. /// <returns></returns>
  12876. [HttpPost]
  12877. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12878. public async Task<IActionResult> EnterExitCostQuoteEntryExitCosts(EnterExitCostInfobyDiIdDto dto)
  12879. {
  12880. int groupId = dto.DiId,
  12881. currUserId = dto.CurrUserId;
  12882. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId;"));
  12883. if (currUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId;"));
  12884. //验证报价数据是否存在
  12885. var isNull = await _sqlSugar.Queryable<Grp_EnterExitCostQuote>().FirstAsync(x => x.IsDel == 0 && x.GroupId == dto.DiId);
  12886. if (isNull != null)
  12887. {
  12888. var info1 = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { Id = isNull.Id });
  12889. if (!info1.Rates.Any())
  12890. {
  12891. var rates = await GeneralMethod.EnterExitCostInitRate();
  12892. rates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  12893. info1.Rates = rates.ToArray();
  12894. }
  12895. return Ok(JsonView(info1));
  12896. }
  12897. var result = await _enterExitCostQuoteRep.InfoByGroupIdAsync(dto.DiId);
  12898. result.GroupId = groupId;
  12899. //处理报价名称
  12900. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.DiId && x.IsDel == 0);
  12901. if (groupInfo != null)
  12902. {
  12903. var visitCountry = groupInfo.VisitCountry;
  12904. if (!string.IsNullOrEmpty(visitCountry))
  12905. {
  12906. string quoteName = string.Empty;
  12907. if (visitCountry.Contains("|"))
  12908. {
  12909. var countrys = visitCountry.Split("|");
  12910. quoteName = string.Join("、", countrys);
  12911. }
  12912. else quoteName = visitCountry;
  12913. quoteName += $"团组报价表";
  12914. result.Name = quoteName;
  12915. }
  12916. }
  12917. var info = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  12918. if (info.Code != StatusCodes.Status200OK)
  12919. {
  12920. if (!result.Rates.Any())
  12921. {
  12922. var rates = await GeneralMethod.EnterExitCostInitRate();
  12923. result.Rates = rates.ToArray();
  12924. }
  12925. return Ok(JsonView(true, $"出入境费用明细未填写!", result));
  12926. }
  12927. var infoView = info.Data as EnterExitCostInfoView;
  12928. if (infoView == null) return Ok(JsonView(false, "数据类型转换失败!;"));
  12929. var countryFees = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).ToListAsync();
  12930. var cityFilter = new List<string>() { "全部城市", "其他城市" };
  12931. var currencys = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  12932. var eecRates = infoView.Currencys;
  12933. //默认添加人名币
  12934. if (!eecRates.Any(x => x.CurrencyCode.Equals("CNY")))
  12935. {
  12936. eecRates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  12937. }
  12938. //处理团组人数
  12939. int pplNum = 1;
  12940. if (groupInfo != null) pplNum = groupInfo.VisitPNumber;
  12941. var views = new List<QuoteSubItemInfo>();
  12942. #region 数据填充
  12943. var intTravelCosts = new List<QuoteSubItemInfo>();
  12944. #region 机票费用 1354
  12945. int intTravelIndex = 1;
  12946. if (infoView.SumJJC == 1)
  12947. {
  12948. intTravelCosts.Add(new QuoteSubItemInfo
  12949. {
  12950. ItemId = 1354,
  12951. Index = intTravelIndex,
  12952. FeeName = "经济舱",
  12953. UnitPrice = infoView.AirJJ,
  12954. Currency = "CNY",
  12955. Quantity = 1,
  12956. PplNum = 1,
  12957. TotalAmt = infoView.AirJJ,
  12958. Remark = "",
  12959. });
  12960. intTravelIndex++;
  12961. }
  12962. if (infoView.SumGWC == 1)
  12963. {
  12964. intTravelCosts.Add(new QuoteSubItemInfo
  12965. {
  12966. ItemId = 1354,
  12967. Index = intTravelIndex,
  12968. FeeName = "公务舱",
  12969. UnitPrice = infoView.AirGW,
  12970. Currency = "CNY",
  12971. Quantity = 1,
  12972. PplNum = 1,
  12973. TotalAmt = infoView.AirGW,
  12974. Remark = "",
  12975. });
  12976. intTravelIndex++;
  12977. }
  12978. if (infoView.SumTDC == 1)
  12979. {
  12980. intTravelCosts.Add(new QuoteSubItemInfo
  12981. {
  12982. ItemId = 1354,
  12983. Index = intTravelIndex,
  12984. FeeName = "头等舱",
  12985. UnitPrice = infoView.AirTD,
  12986. Currency = "CNY",
  12987. Quantity = 1,
  12988. PplNum = 1,
  12989. TotalAmt = infoView.AirTD,
  12990. Remark = "",
  12991. });
  12992. intTravelIndex++;
  12993. }
  12994. intTravelCosts.Add(new QuoteSubItemInfo
  12995. {
  12996. ItemId = 1354,
  12997. Index = intTravelIndex,
  12998. FeeName = "城市间交通费用",
  12999. UnitPrice = infoView.CityTranffic,
  13000. Currency = "CNY",
  13001. Quantity = 1,
  13002. PplNum = pplNum,
  13003. TotalAmt = infoView.CityTranffic * pplNum,
  13004. Remark = "",
  13005. });
  13006. views.AddRange(intTravelCosts);
  13007. #endregion
  13008. var accomCosts = new List<QuoteSubItemInfo>();
  13009. #region 住宿费 1355
  13010. if (infoView.QuarterageData.Any())
  13011. {
  13012. int accomIndex = 1;
  13013. int accomItemTypeId = 1355;
  13014. var groupData = infoView.QuarterageData.GroupBy(x => x.NationalTravelFeeId);
  13015. foreach (var item in groupData)
  13016. {
  13017. string feeName = string.Empty;
  13018. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  13019. if (countryInfo != null)
  13020. {
  13021. feeName = countryInfo.Country;
  13022. var city = countryInfo.City;
  13023. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  13024. {
  13025. feeName += $"-{city}";
  13026. }
  13027. }
  13028. var hotelInfo = item.FirstOrDefault();
  13029. if (hotelInfo == null) continue;
  13030. var thisCurrency = currencys.FirstOrDefault(x => x.Id == hotelInfo.Currency)?.Name ?? "nuknow";
  13031. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  13032. int quantity = item.ToList().Count;
  13033. accomCosts.Add(new QuoteSubItemInfo
  13034. {
  13035. ItemId = accomItemTypeId,
  13036. Index = accomIndex,
  13037. FeeName = feeName,
  13038. UnitPrice = hotelInfo.Cost,
  13039. Currency = thisCurrency,
  13040. Quantity = quantity,
  13041. PplNum = pplNum,
  13042. TotalAmt = hotelInfo.Cost * thisRate * quantity * pplNum,
  13043. Remark = "",
  13044. });
  13045. accomIndex++;
  13046. }
  13047. views.AddRange(accomCosts);
  13048. }
  13049. #endregion
  13050. var mealCosts = new List<QuoteSubItemInfo>();
  13051. #region 餐饮费 1356
  13052. if (infoView.BoardWagesData.Any())
  13053. {
  13054. var mealIndex = 1;
  13055. int mealItemTypeId = 1356;
  13056. var groupData = infoView.BoardWagesData.GroupBy(x => x.NationalTravelFeeId);
  13057. foreach (var item in groupData)
  13058. {
  13059. string feeName = string.Empty;
  13060. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  13061. if (countryInfo != null)
  13062. {
  13063. feeName = countryInfo.Country;
  13064. var city = countryInfo.City;
  13065. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  13066. {
  13067. feeName += $"-{city}";
  13068. }
  13069. }
  13070. var mealInfo = item.FirstOrDefault();
  13071. if (mealInfo == null) continue;
  13072. var thisCurrency = currencys.FirstOrDefault(x => x.Id == mealInfo.Currency)?.Name ?? "nuknow";
  13073. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  13074. int quantity = item.ToList().Count;
  13075. mealCosts.Add(new QuoteSubItemInfo
  13076. {
  13077. ItemId = mealItemTypeId,
  13078. Index = mealIndex,
  13079. FeeName = feeName,
  13080. UnitPrice = mealInfo.Cost,
  13081. Currency = thisCurrency,
  13082. Quantity = quantity,
  13083. PplNum = pplNum,
  13084. TotalAmt = mealInfo.Cost * thisRate * quantity * pplNum,
  13085. Remark = "",
  13086. });
  13087. mealIndex++;
  13088. }
  13089. views.AddRange(mealCosts);
  13090. }
  13091. #endregion
  13092. var miscCosts = new List<QuoteSubItemInfo>();
  13093. #region 公杂费 1364
  13094. if (infoView.MiscellaneousFeeData.Any())
  13095. {
  13096. var miscIndex = 1;
  13097. int miscItemTypeId = 1364;
  13098. var groupData = infoView.MiscellaneousFeeData.GroupBy(x => x.NationalTravelFeeId);
  13099. foreach (var item in groupData)
  13100. {
  13101. string feeName = string.Empty;
  13102. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  13103. if (countryInfo != null)
  13104. {
  13105. feeName = countryInfo.Country;
  13106. var city = countryInfo.City;
  13107. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  13108. {
  13109. feeName += $"-{city}";
  13110. }
  13111. }
  13112. var miscInfo = item.FirstOrDefault();
  13113. if (miscInfo == null) continue;
  13114. var thisCurrency = currencys.FirstOrDefault(x => x.Id == miscInfo.Currency)?.Name ?? "nuknow";
  13115. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  13116. int quantity = item.ToList().Count;
  13117. miscCosts.Add(new QuoteSubItemInfo
  13118. {
  13119. ItemId = miscItemTypeId,
  13120. Index = miscIndex,
  13121. FeeName = feeName,
  13122. UnitPrice = miscInfo.Cost,
  13123. Currency = thisCurrency,
  13124. Quantity = quantity,
  13125. PplNum = pplNum,
  13126. TotalAmt = miscInfo.Cost * thisRate * quantity * pplNum,
  13127. Remark = "",
  13128. });
  13129. miscIndex++;
  13130. }
  13131. views.AddRange(miscCosts);
  13132. }
  13133. #endregion
  13134. #region 签证+保险 1362
  13135. int visaInsIndex = 1;
  13136. int visaInsItemTypeId = 1362;
  13137. if (infoView.Visa > 0)
  13138. {
  13139. views.Add(new QuoteSubItemInfo()
  13140. {
  13141. ItemId = visaInsItemTypeId,
  13142. Index = visaInsIndex,
  13143. FeeName = $"签证",
  13144. UnitPrice = infoView.Visa,
  13145. Currency = $"CNY",
  13146. Quantity = 1,
  13147. PplNum = pplNum,
  13148. TotalAmt = infoView.Visa * pplNum,
  13149. Remark = "",
  13150. });
  13151. visaInsIndex++;
  13152. }
  13153. if (infoView.Safe > 0)
  13154. {
  13155. views.Add(new QuoteSubItemInfo()
  13156. {
  13157. ItemId = visaInsItemTypeId,
  13158. Index = visaInsIndex,
  13159. FeeName = $"保险",
  13160. UnitPrice = infoView.Safe,
  13161. Currency = $"CNY",
  13162. Quantity = 1,
  13163. PplNum = pplNum,
  13164. TotalAmt = infoView.Safe * pplNum,
  13165. Remark = "",
  13166. });
  13167. }
  13168. #endregion
  13169. #region 服务费 1363
  13170. int serviceFeeIndex = 1;
  13171. int serviceFeeItemTypeId = 1363;
  13172. if (infoView.Service > 0)
  13173. {
  13174. views.Add(new QuoteSubItemInfo()
  13175. {
  13176. ItemId = serviceFeeItemTypeId,
  13177. Index = serviceFeeIndex,
  13178. FeeName = $"服务费",
  13179. UnitPrice = infoView.Service,
  13180. Currency = $"CNY",
  13181. Quantity = 1,
  13182. PplNum = pplNum,
  13183. TotalAmt = infoView.Service * pplNum,
  13184. Remark = "",
  13185. });
  13186. }
  13187. #endregion
  13188. #endregion
  13189. if (result.FeeItems.Any())
  13190. {
  13191. result.FeeItems.Select(x =>
  13192. {
  13193. var feeInfos = views.Where(y => y.ItemId == x.ItemId).OrderBy(y => y.Index).ToArray();
  13194. if (feeInfos.Any()) x.Infos = feeInfos;
  13195. return x;
  13196. }
  13197. ).OrderBy(x => x.Index)
  13198. .ToList();
  13199. if (!result.Rates.Any())
  13200. {
  13201. if (eecRates.Any()) result.Rates = eecRates?.ToArray() ?? Array.Empty<CurrencyInfo>();
  13202. else
  13203. {
  13204. var rates = await GeneralMethod.EnterExitCostInitRate();
  13205. rates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  13206. result.Rates = rates.ToArray();
  13207. }
  13208. }
  13209. }
  13210. return Ok(JsonView(result));
  13211. }
  13212. /// <summary>
  13213. /// 团组模块 - 出入境费用报价表 - Info
  13214. /// </summary>
  13215. /// <returns></returns>
  13216. [HttpPost]
  13217. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13218. public async Task<IActionResult> EnterExitCostQuoteInfo(EnterExitCostQuoteInfoDto dto)
  13219. {
  13220. var info = await _enterExitCostQuoteRep.InfoAsync(dto);
  13221. if (!info.Rates.Any())
  13222. {
  13223. var rates = await GeneralMethod.EnterExitCostInitRate();
  13224. rates.Add(new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  13225. info.Rates = rates.ToArray();
  13226. }
  13227. return Ok(JsonView(info));
  13228. }
  13229. /// <summary>
  13230. /// 团组模块 - 出入境费用报价表 - OP
  13231. /// </summary>
  13232. /// <returns></returns>
  13233. [HttpPost]
  13234. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13235. public async Task<IActionResult> EnterExitCostQuoteOp(EnterExitCostQuoteOpDto dto)
  13236. {
  13237. return Ok(await _enterExitCostQuoteRep.OpAsync(dto));
  13238. }
  13239. /// <summary>
  13240. /// 团组模块 - 出入境费用报价表 - 删除 项
  13241. /// </summary>
  13242. /// <returns></returns>
  13243. [HttpPost]
  13244. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13245. public async Task<IActionResult> EnterExitCostQuoteItemDel(EnterExitCostQuoteItemDelDto dto)
  13246. {
  13247. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  13248. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  13249. return Ok(await _enterExitCostQuoteRep.ItemDelAsync(dto));
  13250. }
  13251. /// <summary>
  13252. /// 团组模块 - 出入境费用报价表 - 导出
  13253. /// </summary>
  13254. /// <returns></returns>
  13255. [HttpPost]
  13256. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13257. public async Task<IActionResult> EnterExitCostQuoteExcelExport(EnterExitCostQuoteExcelExportDto dto)
  13258. {
  13259. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  13260. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  13261. var info = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { Id = dto.Id });
  13262. if (info == null) return Ok(JsonView(false, "报价信息未填写!"));
  13263. var rates = info.Rates;
  13264. var intTravelCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1354);//国际旅费
  13265. var accomCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1355); //住宿费
  13266. var mealCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1356); //餐饮费
  13267. var vehArranges = info.FeeItems.FirstOrDefault(x => x.ItemId == 1357); //车辆安排
  13268. var inviteTo = info.FeeItems.FirstOrDefault(x => x.ItemId == 1358); //邀请函发放对象
  13269. var inviteCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1359); //邀请函费用
  13270. var inviteTime = info.FeeItems.FirstOrDefault(x => x.ItemId == 1360); //邀请函发放时间
  13271. var officialActs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1361); //公务活动
  13272. var visaIns = info.FeeItems.FirstOrDefault(x => x.ItemId == 1362); //签证+保险
  13273. var serviceCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1363); //服务费
  13274. var pubMiscs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1364); //公杂费
  13275. var taxCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1365); //税费
  13276. //获取模板
  13277. string tempPath = AppSettingsHelper.Get("ExcelBasePath") + "Template/出入境费用明细报价表模板.xlsx";
  13278. var designer = new WorkbookDesigner();
  13279. designer.Workbook = new Workbook(tempPath);
  13280. designer.SetDataSource("QuoteName", info.Name);
  13281. designer.SetDataSource("CompanyTitle", "公司名称");
  13282. designer.SetDataSource("CompanyLabel", "");
  13283. #region 国际旅费
  13284. designer.SetDataSource("IntTravelTitle", intTravelCosts?.ItemWrapName ?? "国际旅费\r\n(公务舱和经济舱分别罗列)");
  13285. if (intTravelCosts != null && intTravelCosts.Infos.Any())
  13286. {
  13287. var cabClassFilter = new string[] { "经济舱", "公务舱", "头等舱" };
  13288. var label = new StringBuilder();
  13289. var infos = intTravelCosts.Infos.Where(x => cabClassFilter.Contains(x.FeeName)).ToArray();
  13290. if (infos.Any())
  13291. {
  13292. label.Append(infos.Sum(x => x.PplNum));
  13293. label.Append("人全程机票:");
  13294. label.Append(infos.Sum(x => x.TotalAmt).TruncDecimals(2));
  13295. label.AppendLine("元");
  13296. }
  13297. foreach (var item in intTravelCosts.Infos)
  13298. {
  13299. label.Append(item.FeeName);
  13300. label.Append(":");
  13301. label.Append(item.UnitPrice.TruncDecimals(2));
  13302. label.Append("元/人*");
  13303. label.Append(item.PplNum);
  13304. label.AppendLine("人");
  13305. }
  13306. if (label.HasValue())
  13307. {
  13308. label.Append("\r\n以上小计:");
  13309. label.Append(intTravelCosts.TotalAmt.TruncDecimals(2));
  13310. label.Append("元");
  13311. }
  13312. designer.SetDataSource("IntTravelLabel", label.ToString());
  13313. }
  13314. #endregion
  13315. #region 住宿费
  13316. designer.SetDataSource("AccomTitle", accomCosts?.ItemWrapName ?? "住宿费\r\n(请备注明酒店星级)");
  13317. if (accomCosts != null && accomCosts.Infos.Any())
  13318. {
  13319. string currencyName = string.Empty,
  13320. countryName = string.Empty;
  13321. decimal rate = 1.0000M;
  13322. var label = new StringBuilder();
  13323. label.AppendLine("全程五星酒店,每人1间房");
  13324. foreach (var item in accomCosts.Infos)
  13325. {
  13326. //乌兹别克斯坦: 塔什干:120美金/间/晚*2*6人
  13327. string name = string.Empty, thisCountryName = string.Empty;
  13328. if (item.FeeName.Contains('-'))
  13329. {
  13330. var feeName = item.FeeName.Split('-');
  13331. thisCountryName = feeName[0];
  13332. if (!thisCountryName.Equals(countryName)) countryName = feeName[0];
  13333. name = feeName[1];
  13334. }
  13335. else name = item.FeeName;
  13336. string thisFeeName = string.Empty;
  13337. if (!thisCountryName.Equals(countryName)) thisFeeName = $"{countryName}:\r\n{name}:";
  13338. else thisFeeName = $"\r\n{name}:";
  13339. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  13340. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  13341. rate = rateInfo?.Rate ?? 1.0000M;
  13342. string subLabel = string.Format("{0}{1}{2}/间/晚*{3}*{4}人", thisFeeName, item.UnitPrice.TruncDecimals(2), currencyName, item.Quantity.ToString("#0"), item.PplNum.ToString("#0"));
  13343. label.AppendLine(subLabel);
  13344. }
  13345. if (label.HasValue())
  13346. {
  13347. //以上小计:52440元(美金汇率:7.5 )
  13348. string subLabel = string.Format("\r\n以上小计:{0}元({1}汇率:{2})", accomCosts.TotalAmt.TruncDecimals(2), currencyName, rate.TruncDecimals(4));
  13349. label.AppendLine(subLabel);
  13350. }
  13351. designer.SetDataSource("AccomLabel", label.ToString());
  13352. }
  13353. #endregion
  13354. #region 餐饮费
  13355. designer.SetDataSource("MealTitle", mealCosts?.ItemWrapName ?? "餐饮费");
  13356. if (mealCosts != null && mealCosts.Infos.Any())
  13357. {
  13358. string currencyName = string.Empty;
  13359. decimal rate = 1.0000M;
  13360. var label = new StringBuilder();
  13361. label.Append("全程酒店含早,\r\n若因航班过早,\r\n酒店准备路早。\r\n\r\n");
  13362. foreach (var item in mealCosts.Infos)
  13363. {
  13364. string name = string.Empty;
  13365. if (item.FeeName.Contains('-'))
  13366. {
  13367. var feeName = item.FeeName.Split('-');
  13368. name = $"\r\n{feeName[0]}:\r\n{feeName[1]}:";
  13369. }
  13370. else name = $"\r\n{item.FeeName}:";
  13371. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  13372. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  13373. rate = rateInfo?.Rate ?? 1.0000M;
  13374. label.Append(name);
  13375. label.Append(item.UnitPrice.TruncDecimals(2));
  13376. label.Append(currencyName);
  13377. label.Append("/天*");
  13378. label.Append(item.Quantity.ToString("#0"));
  13379. label.Append('*');
  13380. label.Append(item.PplNum);
  13381. label.Append("人\r\n");
  13382. }
  13383. if (label.HasValue())
  13384. {
  13385. label.Append("\r\n以上小计:");
  13386. label.Append(accomCosts.TotalAmt.TruncDecimals(2));
  13387. label.Append("元\r\n(");
  13388. label.Append("汇率:");
  13389. label.Append(rate.TruncDecimals(4));
  13390. label.Append(')');
  13391. }
  13392. designer.SetDataSource("MealLabel", label.ToString());
  13393. }
  13394. #endregion
  13395. #region 车辆安排
  13396. designer.SetDataSource("VehArrangeTitle", vehArranges?.ItemWrapName ?? "车辆安排\r\n(司兼导分开的情况下,车辆品牌、座位及费用)");
  13397. if (vehArranges != null && vehArranges.Infos.Any())
  13398. {
  13399. string currencyName = string.Empty;
  13400. //decimal rate = 1.0000M;
  13401. var label = new StringBuilder();
  13402. foreach (var item in vehArranges.Infos)
  13403. {
  13404. label.AppendLine();
  13405. label.AppendLine();
  13406. label.Append(item.FeeName);
  13407. label.Append($"\r\n\r\n费用:{item.TotalAmt.TruncDecimals(2)}元");
  13408. }
  13409. designer.SetDataSource("VehArrangeLabel", label.ToString());
  13410. }
  13411. #endregion
  13412. #region 邀请函发放对象
  13413. designer.SetDataSource("InviteToTitle", inviteTo?.ItemWrapName ?? "邀请函发放对象");
  13414. designer.SetDataSource("InviteToContent", "");
  13415. #endregion
  13416. #region 邀请函费
  13417. designer.SetDataSource("InviteCostTitle", inviteCosts?.ItemWrapName ?? "邀请函费用");
  13418. var is_label = new StringBuilder();
  13419. if (inviteCosts != null && inviteCosts.Infos.Any())
  13420. {
  13421. string currencyName = string.Empty;
  13422. decimal rate = 1.0000M;
  13423. foreach (var item in inviteCosts.Infos)
  13424. {
  13425. //乌兹别克斯坦:2000美金
  13426. currencyName = item.Currency;
  13427. rate = rates.FirstOrDefault(x => currencyName.Equals(x.CurrencyCode))?.Rate ?? 1.0000M;
  13428. string label = string.Format("{0}:{1}{2}", item.FeeName, item.UnitPrice.TruncDecimals(2), currencyName);
  13429. is_label.AppendLine(label);
  13430. }
  13431. if (is_label.HasValue())
  13432. {
  13433. //以上小计:28500元(美金汇率:7.5)
  13434. string label = string.Format("以上小计:{0}{1}({2}汇率:{3})", inviteCosts.TotalAmt.TruncDecimals(2), "元", currencyName, rate.TruncDecimals(4));
  13435. is_label.AppendLine(label);
  13436. }
  13437. }
  13438. designer.SetDataSource("InviteCostContent", is_label.ToString());
  13439. #endregion
  13440. #region 邀请函发放时间
  13441. designer.SetDataSource("InviteToTimeTitle", inviteTime?.ItemWrapName ?? "邀请函发放时间");
  13442. designer.SetDataSource("InviteToTimeContent", "拿到团员名单10-15工作日");
  13443. #endregion
  13444. #region 公务活动(含翻译)
  13445. designer.SetDataSource("OfficialActsTitle", officialActs?.ItemWrapName ?? "公务活动(含翻译)");
  13446. var oa_label = new StringBuilder();
  13447. if (officialActs != null && officialActs.Infos.Any())
  13448. {
  13449. string currencyName = string.Empty;
  13450. decimal rate = 1.0000M;
  13451. string label_title = string.Empty, label_content = "超出报价部分需额付费:\r\n";
  13452. foreach (var item in officialActs.Infos)
  13453. {
  13454. //乌兹别克斯坦:1000美金/场
  13455. currencyName = item.Currency;
  13456. rate = rates.FirstOrDefault(x => currencyName.Equals(x.CurrencyCode))?.Rate ?? 1.0000M;
  13457. string label_remark = string.Empty;
  13458. if (!string.IsNullOrEmpty(item.Remark)) label_remark = $"({item.Remark})";
  13459. label_content += string.Format("{0}:{1}{2}/场{3}\r\n", item.FeeName, item.UnitPrice.TruncDecimals(2), currencyName, label_remark);
  13460. }
  13461. label_content += "*总费用中未含超出公务活动价格";
  13462. //8场公务活动(以上小计:60000元)
  13463. var quantity = officialActs.Infos.Sum(x => x.Quantity);
  13464. label_title = string.Format("{0}场公务活动(以上小计:{1}元)", quantity, officialActs.TotalAmt.TruncDecimals(2));
  13465. oa_label.AppendLine(label_title);
  13466. oa_label.AppendLine(label_content);
  13467. }
  13468. designer.SetDataSource("OfficialActsContent", oa_label.ToString());
  13469. #endregion
  13470. #region 签证+保险
  13471. designer.SetDataSource("VisaInsTitle", visaIns?.ItemWrapName ?? "签证+保险\r\n(单位:元)");
  13472. var vi_label = new StringBuilder();
  13473. if (visaIns != null && visaIns.Infos.Any())
  13474. {
  13475. foreach (var item in visaIns.Infos)
  13476. {
  13477. //签证:500元/人
  13478. string label = string.Format("{0}:{1}元/人*{2}人", item.FeeName, item.UnitPrice.TruncDecimals(2), item.PplNum);
  13479. vi_label.AppendLine(label);
  13480. }
  13481. if (vi_label.HasValue())
  13482. {
  13483. //以上小计:6000元
  13484. string label = string.Format("以上小计:{0}元", visaIns.TotalAmt.TruncDecimals(2));
  13485. vi_label.AppendLine(label);
  13486. }
  13487. }
  13488. designer.SetDataSource("VisaInsContent", vi_label.ToString());
  13489. #endregion
  13490. #region 服务费
  13491. designer.SetDataSource("ServiceCostTitle", serviceCosts?.ItemWrapName ?? "服务费");
  13492. designer.SetDataSource("ServiceCostContent", serviceCosts?.TotalAmt.TruncDecimals(2) ?? 0.00M);
  13493. #endregion
  13494. #region 公杂费
  13495. designer.SetDataSource("PubMiscsTitle", pubMiscs?.ItemWrapName ?? "公杂费\r\n(发给团组成员)");
  13496. var pm_label = new StringBuilder();
  13497. if (pubMiscs != null && pubMiscs.Infos.Any())
  13498. {
  13499. string currencyName = string.Empty,
  13500. countryName = string.Empty;
  13501. decimal rate = 1.0000M;
  13502. foreach (var item in pubMiscs.Infos)
  13503. {
  13504. //乌兹别克斯坦:塔什干:32美金 / 天 * 3 * 6人
  13505. string name = string.Empty, thisCountryName = string.Empty;
  13506. if (item.FeeName.Contains('-'))
  13507. {
  13508. var feeName = item.FeeName.Split('-');
  13509. thisCountryName = feeName[0];
  13510. if (!thisCountryName.Equals(countryName)) countryName = feeName[0];
  13511. name = feeName[1];
  13512. }
  13513. else name = item.FeeName;
  13514. string thisFeeName = string.Empty;
  13515. if (!thisCountryName.Equals(countryName)) thisFeeName = $"{countryName}:\r\n{name}:";
  13516. else thisFeeName = $"\r\n{name}:";
  13517. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  13518. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  13519. rate = rateInfo?.Rate ?? 1.0000M;
  13520. string label = string.Format("{0}:{1}{2}/天*{3}*{4}人", thisFeeName, item.UnitPrice.TruncDecimals(2), currencyName, item.Quantity, item.PplNum);
  13521. pm_label.AppendLine(label);
  13522. }
  13523. if (pm_label.HasValue())
  13524. {
  13525. //以上小计:13497.6元\r\n(美金汇率:7.5 )\r\n部分发放成员
  13526. pm_label.AppendLine(string.Format("以上小计:{0}元", pubMiscs.TotalAmt.TruncDecimals(2)));
  13527. pm_label.AppendLine(string.Format("({0}汇率:{1})", currencyName, rate.TruncDecimals(4)));
  13528. pm_label.AppendLine(string.Format("部分发放成员"));
  13529. }
  13530. }
  13531. designer.SetDataSource("PubMiscsContent", pm_label.ToString());
  13532. #endregion
  13533. #region 税费
  13534. designer.SetDataSource("TaxCostTitle", taxCosts?.ItemWrapName ?? "税费");
  13535. designer.SetDataSource("TaxCostContent", taxCosts?.TotalAmt.TruncDecimals(2) ?? 0.00M);
  13536. #endregion
  13537. #region 合计(单位:元)
  13538. designer.SetDataSource("CostTotalTitle", "合计\r\n(单位:元)");
  13539. designer.SetDataSource("CostTotalContent", info.FeeItems.Sum(x => x.TotalAmt).TruncDecimals(2));
  13540. #endregion
  13541. #region 汇率 Remark
  13542. var rate_label = new StringBuilder();
  13543. var rateGroups = rates.GroupBy(x => x.CurrencyName);
  13544. foreach (var item in rateGroups)
  13545. {
  13546. //美元汇率按\r\n1:7.5
  13547. string label = string.Format("{0}汇率按\r\n1:{1}", item.Key, item.FirstOrDefault()?.Rate.TruncDecimals(4) ?? 0.0000M);
  13548. rate_label.AppendLine(label);
  13549. }
  13550. designer.SetDataSource("RateLabel", rate_label.ToString());
  13551. #endregion
  13552. designer.Process();
  13553. //文件名
  13554. string fileName = $"{info.Name}{DateTime.Now:yyyyMMddHHmmss}.xls";
  13555. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + "EnterExitCostQuote/" + fileName);
  13556. string url = AppSettingsHelper.Get("ExcelBaseUrl") + "Office/Excel/EnterExitCostQuote/" + fileName;
  13557. return Ok(JsonView(true, "成功", url));
  13558. }
  13559. #endregion
  13560. #region 签证费用录入
  13561. /// <summary>
  13562. /// 根据diid查询签证费用列表
  13563. /// </summary>
  13564. /// <param name="dto"></param>
  13565. /// <returns></returns>
  13566. [HttpPost]
  13567. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13568. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  13569. {
  13570. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  13571. if (groupData.Code != 0)
  13572. {
  13573. return Ok(JsonView(false, groupData.Msg));
  13574. }
  13575. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  13576. }
  13577. /// <summary>
  13578. /// 根据签证费用Id查询单条数据及c表数据
  13579. /// </summary>
  13580. /// <param name="dto"></param>
  13581. /// <returns></returns>
  13582. [HttpPost]
  13583. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13584. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  13585. {
  13586. Result groupData = await _visaPriceRep.PostVisaById(dto);
  13587. if (groupData.Code != 0)
  13588. {
  13589. return Ok(JsonView(false, groupData.Msg));
  13590. }
  13591. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  13592. }
  13593. /// <summary>
  13594. /// 签证费用删除
  13595. /// </summary>
  13596. /// <param name="dto"></param>
  13597. /// <returns></returns>
  13598. [HttpPost]
  13599. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13600. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  13601. {
  13602. _sqlSugar.BeginTran();
  13603. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  13604. if (!res)
  13605. {
  13606. _sqlSugar.RollbackTran();
  13607. return Ok(JsonView(false, "删除失败"));
  13608. }
  13609. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  13610. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  13611. .SetColumns(a => new Grp_CreditCardPayment()
  13612. {
  13613. IsDel = 1,
  13614. DeleteUserId = dto.DeleteUserId,
  13615. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  13616. })
  13617. .ExecuteCommand();
  13618. if (resSub < 1)
  13619. {
  13620. _sqlSugar.RollbackTran();
  13621. return Ok(JsonView(false, "删除失败"));
  13622. }
  13623. _sqlSugar.CommitTran();
  13624. return Ok(JsonView(true, "删除成功!"));
  13625. }
  13626. /// <summary>
  13627. /// 签证费用录入下拉框初始化
  13628. /// </summary>
  13629. /// <returns></returns>
  13630. [HttpPost]
  13631. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13632. public async Task<IActionResult> VisaPriceAddSelect()
  13633. {
  13634. //支付方式
  13635. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  13636. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  13637. //币种
  13638. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  13639. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  13640. //乘客类型
  13641. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  13642. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  13643. //卡类型
  13644. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  13645. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  13646. //代办费类型
  13647. var agencyFeeTypeData = new List<dynamic>() {
  13648. new { id = 0 , Text = "未选择" },
  13649. new { id = 1 , Text = "小公务" },
  13650. new { id = 2 , Text = "大公务" },
  13651. };
  13652. //签证费用标准国家Data
  13653. var visaSql = string.Format(@"select
  13654. id,
  13655. case
  13656. when FeeType = 0 then Country+'(因公)'
  13657. when FeeType = 1 then Country+'(因私)'
  13658. else Country+'(未设置)'
  13659. end as 'country'
  13660. from Res_VisaFeeStandard where isdel = 0");
  13661. var visaCountryFeeData = _sqlSugar.SqlQueryable<dynamic>(visaSql).ToList();
  13662. var data = new
  13663. {
  13664. Payment = _Payment,
  13665. CurrencyList = _CurrencyList,
  13666. PassengerType = _PassengerType,
  13667. BankCard = _BankCard,
  13668. AgencyFeeType = agencyFeeTypeData,
  13669. CountryFeeData = visaCountryFeeData
  13670. };
  13671. return Ok(JsonView(true, "查询成功!", data));
  13672. }
  13673. /// <summary>
  13674. /// 签证费用录入操作(Status:1.新增,2.修改)
  13675. /// </summary>
  13676. /// <param name="dto"></param>
  13677. /// <returns></returns>
  13678. [HttpPost]
  13679. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13680. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  13681. {
  13682. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  13683. if (groupData.Code != 0)
  13684. {
  13685. return Ok(JsonView(false, groupData.Msg));
  13686. }
  13687. #region 应用推送
  13688. try
  13689. {
  13690. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  13691. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  13692. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  13693. //2024-10-21 新增LZ UID
  13694. var userIds = new List<int>() { 21 };
  13695. string title = $"系统通知";
  13696. string content = "";
  13697. var diId = dto.DiId;
  13698. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  13699. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  13700. if (dto.Status == 1) content = $"[新增-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  13701. else if (dto.Status == 2) content = $"[更新-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  13702. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  13703. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "80" };
  13704. await APNsTools.iOS_PushNotifications1("051", $"签证费用审核", "", content, true, "ExpenseAuditWebView", h5);
  13705. }
  13706. catch (Exception ex)
  13707. {
  13708. }
  13709. #endregion
  13710. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  13711. }
  13712. #endregion
  13713. #region 签证提成录入
  13714. /// <summary>
  13715. /// 签证提成录入
  13716. /// 基础数据
  13717. /// </summary>
  13718. /// <returns></returns>
  13719. [HttpGet]
  13720. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13721. public async Task<IActionResult> VisaCommissionInit()
  13722. {
  13723. return Ok(await _visaCommissionRep.Init());
  13724. }
  13725. /// <summary>
  13726. /// 签证提成录入
  13727. /// Item
  13728. /// </summary>
  13729. /// <param name="_dto"></param>
  13730. /// <returns></returns>
  13731. [HttpPost]
  13732. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13733. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
  13734. {
  13735. var validator = new VisaCommissionItemDtoValidator();
  13736. var validatorRes = await validator.ValidateAsync(_dto);
  13737. if (!validatorRes.IsValid)
  13738. {
  13739. var sb = new StringBuilder();
  13740. foreach (var item in validatorRes.Errors)
  13741. {
  13742. sb.AppendLine(item.ErrorMessage);
  13743. }
  13744. return Ok(JsonView(false, sb.ToString()));
  13745. }
  13746. return Ok(await _visaCommissionRep.Item(_dto));
  13747. }
  13748. /// <summary>
  13749. /// 签证提成录入
  13750. /// Save
  13751. /// </summary>
  13752. /// <param name="_dto"></param>
  13753. /// <returns></returns>
  13754. [HttpPost]
  13755. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13756. public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
  13757. {
  13758. //参数验证
  13759. if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
  13760. foreach (var item in _dto.Items)
  13761. {
  13762. if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
  13763. if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
  13764. if (string.IsNullOrEmpty(item.Country)) return Ok(JsonView(false, "国家为空!"));
  13765. //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
  13766. }
  13767. return Ok(await _visaCommissionRep.Save(_dto));
  13768. }
  13769. /// <summary>
  13770. /// 签证提成录入
  13771. /// Create
  13772. /// </summary>
  13773. /// <param name="_dto"></param>
  13774. /// <returns></returns>
  13775. [HttpPost]
  13776. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13777. public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
  13778. {
  13779. var validator = new VisaCommissionCreateDtoValidator();
  13780. var validatorRes = await validator.ValidateAsync(_dto);
  13781. if (!validatorRes.IsValid)
  13782. {
  13783. var sb = new StringBuilder();
  13784. foreach (var item in validatorRes.Errors)
  13785. {
  13786. sb.AppendLine(item.ErrorMessage);
  13787. }
  13788. return Ok(JsonView(false, sb.ToString()));
  13789. }
  13790. return Ok(await _visaCommissionRep.Create(_dto));
  13791. }
  13792. /// <summary>
  13793. /// 签证提成录入
  13794. /// Put(编辑)
  13795. /// </summary>
  13796. /// <param name="id"></param>
  13797. /// <param name="_dto"></param>
  13798. /// <returns></returns>
  13799. [HttpPut]
  13800. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13801. public async Task<IActionResult> VisaCommissionEdit(int id, VisaCommissionCreateDto _dto)
  13802. {
  13803. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  13804. var validator = new VisaCommissionCreateDtoValidator();
  13805. var validatorRes = await validator.ValidateAsync(_dto);
  13806. if (!validatorRes.IsValid)
  13807. {
  13808. var sb = new StringBuilder();
  13809. foreach (var item in validatorRes.Errors)
  13810. {
  13811. sb.AppendLine(item.ErrorMessage);
  13812. }
  13813. return Ok(JsonView(false, sb.ToString()));
  13814. }
  13815. return Ok(await _visaCommissionRep.Edit(id, _dto));
  13816. }
  13817. /// <summary>
  13818. /// 签证提成录入
  13819. /// Del
  13820. /// </summary>
  13821. /// <param name="id"></param>
  13822. /// <param name="currUserId"></param>
  13823. /// <returns></returns>
  13824. [HttpPost]
  13825. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13826. public async Task<IActionResult> VisaCommissionDel(int id, int currUserId)
  13827. {
  13828. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  13829. if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
  13830. return Ok(await _visaCommissionRep.Del(id, currUserId));
  13831. }
  13832. #endregion
  13833. #region op费用录入
  13834. /// <summary>
  13835. /// 根据diid查询op费用列表
  13836. /// </summary>
  13837. /// <param name="dto"></param>
  13838. /// <returns></returns>
  13839. [HttpPost]
  13840. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13841. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  13842. {
  13843. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  13844. if (groupData.Code != 0)
  13845. {
  13846. return Ok(JsonView(false, groupData.Msg));
  13847. }
  13848. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  13849. }
  13850. /// <summary>
  13851. /// 根据op费用Id查询单条数据及c表数据
  13852. /// </summary>
  13853. /// <param name="dto"></param>
  13854. /// <returns></returns>
  13855. [HttpPost]
  13856. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13857. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  13858. {
  13859. try
  13860. {
  13861. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  13862. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  13863. var data = new
  13864. {
  13865. CarTouristGuideGround = _groupData,
  13866. CreditCardPayment = _creditCardPayment
  13867. };
  13868. return Ok(JsonView(true, "查询成功!", data));
  13869. }
  13870. catch (Exception ex)
  13871. {
  13872. return Ok(JsonView(false, "程序错误!"));
  13873. }
  13874. }
  13875. /// <summary>
  13876. /// op费用删除
  13877. /// </summary>
  13878. /// <param name="dto"></param>
  13879. /// <returns></returns>
  13880. [HttpPost]
  13881. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13882. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  13883. {
  13884. try
  13885. {
  13886. _sqlSugar.BeginTran();
  13887. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  13888. if (!res)
  13889. {
  13890. return Ok(JsonView(false, "删除失败"));
  13891. }
  13892. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  13893. {
  13894. IsDel = 1,
  13895. DeleteUserId = dto.DeleteUserId,
  13896. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  13897. }).ExecuteCommandAsync();
  13898. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  13899. {
  13900. IsDel = 1,
  13901. DeleteUserId = dto.DeleteUserId,
  13902. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  13903. }).ExecuteCommandAsync();
  13904. #region 删除超支相关数据
  13905. //删除导入的超支数据
  13906. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  13907. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  13908. {
  13909. IsDel = 1,
  13910. DeleteUserId = dto.DeleteUserId,
  13911. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  13912. }).ExecuteCommand();
  13913. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  13914. {
  13915. IsDel = 1,
  13916. DeleteUserId = dto.DeleteUserId,
  13917. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  13918. }).ExecuteCommand();
  13919. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  13920. {
  13921. IsDel = 1,
  13922. DeleteUserId = dto.DeleteUserId,
  13923. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  13924. }).ExecuteCommand();
  13925. #endregion
  13926. _sqlSugar.CommitTran();
  13927. return Ok(JsonView(true, "删除成功!"));
  13928. }
  13929. catch (Exception ex)
  13930. {
  13931. _sqlSugar.RollbackTran();
  13932. return Ok(JsonView(false, "程序错误!" + ex.Message));
  13933. }
  13934. }
  13935. /// <summary>
  13936. /// op费用录入操作(Status:1.新增,2.修改)
  13937. /// </summary>
  13938. /// <param name="dto"></param>
  13939. /// <returns></returns>
  13940. [HttpPost]
  13941. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13942. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  13943. {
  13944. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  13945. if (groupData.Code != 0)
  13946. {
  13947. return Ok(JsonView(false, groupData.Msg));
  13948. }
  13949. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  13950. }
  13951. /// <summary>
  13952. /// 填写费用详细页面初始化绑定
  13953. /// </summary>
  13954. /// <param name="dto"></param>
  13955. /// <returns></returns>
  13956. [HttpPost]
  13957. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13958. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  13959. {
  13960. try
  13961. {
  13962. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  13963. if (groupData.Code != 0)
  13964. {
  13965. return Ok(JsonView(false, groupData.Msg));
  13966. }
  13967. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  13968. }
  13969. catch (Exception ex)
  13970. {
  13971. return Ok(JsonView(false, ex.Message));
  13972. }
  13973. }
  13974. /// <summary>
  13975. /// 根据op费用Id查询详细数据
  13976. /// </summary>
  13977. /// <param name="dto"></param>
  13978. /// <returns></returns>
  13979. [HttpPost]
  13980. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13981. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  13982. {
  13983. try
  13984. {
  13985. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  13986. if (groupData.Code != 0)
  13987. {
  13988. return Ok(JsonView(false, groupData.Msg));
  13989. }
  13990. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  13991. }
  13992. catch (Exception ex)
  13993. {
  13994. return Ok(JsonView(false, ex.Message));
  13995. }
  13996. }
  13997. /// <summary>
  13998. /// OP费用录入填写详情
  13999. /// </summary>
  14000. /// <param name="dto"></param>
  14001. /// <returns></returns>
  14002. [HttpPost]
  14003. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14004. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  14005. {
  14006. try
  14007. {
  14008. #region 参数校验
  14009. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  14010. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  14011. if (di == null) return Ok(JsonView(false, "团组错误!"));
  14012. #endregion
  14013. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  14014. if (groupData.Code != 0)
  14015. {
  14016. return Ok(JsonView(false, groupData.Msg));
  14017. }
  14018. //自动审核
  14019. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  14020. #region 尾款自动审核
  14021. var opinfos = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>()
  14022. .First(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Id == dto.CTGGRId);
  14023. if (opinfos.PriceType == 1062)
  14024. {
  14025. var isAuto = false;
  14026. //找对应的首付款
  14027. var firstPrice = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>()
  14028. .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))
  14029. .First(x => x.IsDel == 0 && x.DiId == dto.DiId && x.PriceName == opinfos.PriceName &&
  14030. x.ServiceStartTime == opinfos.ServiceStartTime && x.ServiceEndTime == opinfos.ServiceEndTime && x.Area == opinfos.Area &&
  14031. x.PriceType == 1061 && x.DiId == dto.DiId);
  14032. if (firstPrice != null && !(opinfos.SelectCheck.Contains("超时") || opinfos.SelectCheck.Contains("超支")) && firstPrice.CId == opinfos.CId)
  14033. {
  14034. var cprice = _sqlSugar.Queryable<Grp_CreditCardPayment>().First(x => x.IsDel == 0 && x.CId == firstPrice.Id && x.CTable == 79);
  14035. var balance = firstPrice.ServiceQuotedPrice * (100 - cprice.PayPercentage) / 100;
  14036. //合计中排除城市税
  14037. var cityPrice = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent>()
  14038. .Where(x => x.SId == 1452 && x.IsDel == 0 && x.DiId == dto.DiId && x.CTGGRId == dto.CTGGRId)
  14039. .Sum(x => x.Price * x.Count);
  14040. opinfos.ServiceQuotedPrice = opinfos.ServiceQuotedPrice - cityPrice;
  14041. if (balance >= opinfos.ServiceQuotedPrice)
  14042. {
  14043. isAuto = true;
  14044. }
  14045. }
  14046. if (isAuto)
  14047. {
  14048. var execCount = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  14049. .SetColumns(a => new Grp_CreditCardPayment
  14050. {
  14051. IsAuditGM = 3, //自动审核通过
  14052. AuditGMOperate = 4,
  14053. AuditGMDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  14054. })
  14055. .Where(a => a.CId == dto.CTGGRId && a.CTable == 79 && a.DIId == dto.DiId)
  14056. .ExecuteCommand();
  14057. }
  14058. }
  14059. #endregion
  14060. #region 应用推送
  14061. try
  14062. {
  14063. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  14064. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  14065. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  14066. //2024-10-21 新增LZ UID
  14067. var userIds = new List<int>() { 21 };
  14068. string title = $"系统通知";
  14069. var diId = dto.DiId;
  14070. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  14071. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  14072. string content = $"[更新-OP费用录入填写详情({groupInfo?.TeamName ?? "-"})]一项费用:{(((ccpInfo.PayMoney * ccpInfo.DayRate) / 100) * ccpInfo.PayPercentage):#0.00} CNY;";
  14073. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  14074. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "79" };
  14075. await APNsTools.iOS_PushNotifications1("051", $"OP费用审核", "", content, true, "ExpenseAuditWebView", h5);
  14076. }
  14077. catch (Exception ex)
  14078. {
  14079. }
  14080. #endregion
  14081. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  14082. }
  14083. catch (Exception ex)
  14084. {
  14085. return Ok(JsonView(false, ex.Message));
  14086. }
  14087. }
  14088. /// <summary>
  14089. /// 获取三公详细所有城市
  14090. /// </summary>
  14091. /// <returns></returns>
  14092. [HttpGet]
  14093. public IActionResult OpCarCityResult()
  14094. {
  14095. var jw = JsonView(false);
  14096. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  14097. {
  14098. x.Id,
  14099. x.Country,
  14100. x.City,
  14101. }).ToList();
  14102. if (data.Count > 0)
  14103. {
  14104. jw = JsonView(true, "获取成功!", data);
  14105. }
  14106. else
  14107. {
  14108. jw.Msg = "城市数据为空!";
  14109. jw.Data = Array.Empty<string>();
  14110. }
  14111. return Ok(jw);
  14112. }
  14113. /// <summary>
  14114. /// 导出地接费用明细
  14115. /// </summary>
  14116. /// <param name="dto"></param>
  14117. /// <returns></returns>
  14118. [HttpPost]
  14119. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  14120. {
  14121. var jw = JsonView(false);
  14122. if (dto.Diid < 1)
  14123. {
  14124. jw.Msg = "请输入正确的diid!";
  14125. return Ok(jw);
  14126. }
  14127. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  14128. if (group == null)
  14129. {
  14130. jw.Msg = "未找到团组信息!";
  14131. return Ok(jw);
  14132. }
  14133. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  14134. if (localGuideArr.Count == 0)
  14135. {
  14136. jw.Msg = "该团组暂无地接信息!";
  14137. return Ok(jw);
  14138. }
  14139. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  14140. var overspendSoure = new Dictionary<int, int>
  14141. {
  14142. { 91, 982 }, //车
  14143. { 92 , 1059} ,//导游
  14144. { 994 , 1073}, //翻译
  14145. { 988 , 1074 }, //早餐
  14146. { 93 , 1075 }, //午餐
  14147. { 989 , 1076 }, //晚餐
  14148. };
  14149. var Zips = new Dictionary<string, Stream>();
  14150. foreach (var groupArr in localGroup)
  14151. {
  14152. var keyValue = groupArr.Key;
  14153. if (int.TryParse(keyValue, out int cityid))
  14154. {
  14155. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  14156. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  14157. }
  14158. var contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  14159. foreach (var item in groupArr)
  14160. {
  14161. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  14162. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  14163. new Grp_CarTouristGuideGroundReservationsContentExtend
  14164. {
  14165. Count = a.Count,
  14166. CreateTime = a.CreateTime,
  14167. CreateUserId = a.CreateUserId,
  14168. CTGGRId = a.CTGGRId,
  14169. Currency = a.Currency,
  14170. DatePrice = a.DatePrice,
  14171. DeleteTime = a.DeleteTime,
  14172. DeleteUserId = a.DeleteUserId,
  14173. DiId = a.DiId,
  14174. Id = a.Id,
  14175. IsDel = a.IsDel,
  14176. Price = a.Price,
  14177. PriceContent = a.PriceContent,
  14178. Remark = a.Remark,
  14179. SId = a.SId,
  14180. SidName = b.Name,
  14181. Units = a.Units,
  14182. }
  14183. ).ToList();
  14184. if (content.Count > 0)
  14185. {
  14186. contentArr.Add(content);
  14187. }
  14188. }
  14189. //open excel
  14190. //set excel
  14191. //save excel
  14192. try
  14193. {
  14194. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  14195. IWorkbook workbook;
  14196. if (Path.GetExtension(filePath).ToLower() == ".xls")
  14197. {
  14198. workbook = new NPOI.HSSF.UserModel.HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  14199. }
  14200. else
  14201. {
  14202. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  14203. }
  14204. ISheet sheet = workbook.GetSheetAt(0);
  14205. var rowStartIndex = 2;
  14206. var clounmCount = 10;
  14207. var initStyleRow = sheet.GetRow(2);
  14208. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  14209. //var overspendArrDetail =
  14210. var existsId = new List<CarCompare>();
  14211. var lastElem = arr.Last();
  14212. var thisSid = -1;
  14213. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  14214. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  14215. {
  14216. Name = "未知币种!",
  14217. Remark = "未知币种!",
  14218. };
  14219. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  14220. Action cloneRowFn = () =>
  14221. {
  14222. rowStartIndex++;
  14223. var cloneRow = sheet.CreateRow(rowStartIndex);
  14224. // 复制样式
  14225. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  14226. {
  14227. ICell sourceCell = initStyleRow.GetCell(i);
  14228. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  14229. // 确保单元格存在样式
  14230. if (sourceCell.CellStyle != null)
  14231. {
  14232. targetCell.CellStyle = sourceCell.CellStyle;
  14233. }
  14234. }
  14235. };
  14236. var mergeRow = () =>
  14237. {
  14238. for (int i = 2; i < sheet.LastRowNum; i++)
  14239. {
  14240. var row = sheet.GetRow(i);
  14241. var cellFirst = row.GetCell(0);
  14242. var thisIndex = i + 1;
  14243. while (thisIndex < sheet.LastRowNum)
  14244. {
  14245. var nextRow = sheet.GetRow(thisIndex);
  14246. var nextCellFirst = nextRow.GetCell(0);
  14247. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  14248. {
  14249. thisIndex++;
  14250. }
  14251. else
  14252. {
  14253. break;
  14254. }
  14255. }
  14256. thisIndex--;
  14257. if (thisIndex != i)
  14258. {
  14259. //合并row
  14260. var cellRangeAddress = new CellRangeAddress(
  14261. i, // 起始行索引(0-based)
  14262. thisIndex, // 结束行索引(0-based)
  14263. 0, // 起始列索引(0-based)
  14264. 0 // 结束列索引(0-based)
  14265. );
  14266. sheet.AddMergedRegion(cellRangeAddress);
  14267. i = thisIndex;
  14268. }
  14269. }
  14270. };
  14271. var chaoshiNumber = 0;
  14272. var totalNumber = 0.00M;
  14273. string lastStr = "";
  14274. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  14275. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  14276. {
  14277. b.IsAuditGM,
  14278. x.Id,
  14279. x.Area,
  14280. b.PayPercentage,
  14281. b.PayMoney,
  14282. }).ToList();
  14283. string yesPayment = "", noPayment = "";
  14284. foreach (var item in queryCarArrByCityAndDiid)
  14285. {
  14286. if (item.IsAuditGM == 1)
  14287. {
  14288. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  14289. }
  14290. else
  14291. {
  14292. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  14293. }
  14294. }
  14295. lastStr = yesPayment + noPayment;
  14296. foreach (var item in arr)
  14297. {
  14298. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.ContainsValue(item.SId))
  14299. {
  14300. if (thisSid != item.SId)
  14301. {
  14302. if (thisSid == -1)
  14303. {
  14304. thisSid = item.SId;
  14305. }
  14306. else
  14307. {
  14308. //合并小计行
  14309. //创建合并区域的实例
  14310. var cellRangeAddress = new CellRangeAddress(
  14311. rowStartIndex, // 起始行索引(0-based)
  14312. rowStartIndex, // 结束行索引(0-based)
  14313. 0, // 起始列索引(0-based)
  14314. 3 // 结束列索引(0-based)
  14315. );
  14316. sheet.AddMergedRegion(cellRangeAddress);
  14317. var CellStyle = workbook.CreateCellStyle();
  14318. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  14319. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  14320. CellStyle.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground; // 填充方式
  14321. for (int i = 0; i <= clounmCount; i++)
  14322. {
  14323. if (i > 6)
  14324. {
  14325. var CellStyle1 = workbook.CreateCellStyle();
  14326. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  14327. IFont Font = workbook.CreateFont(); // 创建字体
  14328. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  14329. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  14330. CellStyle1.SetFont(Font);
  14331. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  14332. }
  14333. else
  14334. {
  14335. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  14336. }
  14337. }
  14338. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  14339. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  14340. //超时合计
  14341. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  14342. //超时数
  14343. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  14344. //超时合计费用
  14345. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  14346. thisSid = item.SId;
  14347. cloneRowFn();
  14348. chaoshiNumber = 0;
  14349. totalNumber = 0;
  14350. }
  14351. }
  14352. IRow row = sheet.GetRow(rowStartIndex);
  14353. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  14354. var isOpenOverspendSoure = overspendSoure.ContainsKey(item.SId);
  14355. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  14356. if (isOpenOverspendSoure)
  14357. {
  14358. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  14359. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  14360. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  14361. }
  14362. for (int i = 0; i <= clounmCount; i++)
  14363. {
  14364. var cell = row.GetCell(i);
  14365. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  14366. if (cell == null)
  14367. {
  14368. cell = row.CreateCell(i);
  14369. }
  14370. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  14371. fontRed.CloneStyleFrom(cell.CellStyle);
  14372. IFont Font = workbook.CreateFont(); // 创建字体
  14373. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  14374. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  14375. fontRed.SetFont(Font);
  14376. byte[] rgb = new byte[3] { 255, 242, 204 };
  14377. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  14378. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  14379. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  14380. if (workbook is XSSFWorkbook)
  14381. {
  14382. BackgroundColor255_242_204.FillForegroundColor = 0;
  14383. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  14384. BackgroundColor255_242_204.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground;
  14385. }
  14386. else
  14387. {
  14388. BackgroundColor255_242_204.FillForegroundColor = (((NPOI.HSSF.UserModel.HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  14389. }
  14390. if (i == 1 || i > 6)
  14391. {
  14392. if (i > 6)
  14393. {
  14394. fontRed.FillForegroundColor = 0;
  14395. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  14396. fontRed.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground;
  14397. }
  14398. cell.CellStyle = fontRed;
  14399. }
  14400. if (i > 2 && i < 7)
  14401. {
  14402. cell.CellStyle = BackgroundColor255_242_204;
  14403. }
  14404. cell.SetCellValue(setCellValue); //写入单元格
  14405. }
  14406. if (overspendSoure.ContainsKey(thisSid))
  14407. {
  14408. var overspendId = overspendSoure[thisSid];
  14409. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  14410. }
  14411. cloneRowFn();
  14412. existsId.Add(new CarCompare
  14413. {
  14414. DataPrice = item.DatePrice.ObjToDate(),
  14415. Sid = item.SId
  14416. });
  14417. }
  14418. if (item.Equals(lastElem))
  14419. {
  14420. //合并小计行
  14421. //创建合并区域的实例
  14422. var cellRangeAddress = new CellRangeAddress(
  14423. rowStartIndex, // 起始行索引(0-based)
  14424. rowStartIndex, // 结束行索引(0-based)
  14425. 0, // 起始列索引(0-based)
  14426. 3 // 结束列索引(0-based)
  14427. );
  14428. sheet.AddMergedRegion(cellRangeAddress);
  14429. var CellStyle = workbook.CreateCellStyle();
  14430. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  14431. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  14432. CellStyle.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground; // 填充方式
  14433. for (int i = 0; i <= clounmCount; i++)
  14434. {
  14435. if (i > 6)
  14436. {
  14437. var CellStyle1 = workbook.CreateCellStyle();
  14438. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  14439. IFont Font = workbook.CreateFont(); // 创建字体
  14440. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  14441. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  14442. CellStyle1.SetFont(Font);
  14443. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  14444. }
  14445. else
  14446. {
  14447. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  14448. }
  14449. }
  14450. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  14451. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  14452. //超时合计
  14453. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  14454. //超时数
  14455. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  14456. //超时合计费用
  14457. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  14458. cloneRowFn();
  14459. // 创建合并区域的实例
  14460. cellRangeAddress = new CellRangeAddress(
  14461. rowStartIndex, // 起始行索引(0-based)
  14462. rowStartIndex, // 结束行索引(0-based)
  14463. 0, // 起始列索引(0-based)
  14464. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  14465. );
  14466. // 添加合并区域
  14467. sheet.AddMergedRegion(cellRangeAddress);
  14468. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  14469. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  14470. }
  14471. }
  14472. mergeRow();
  14473. // 保存修改后的Excel文件到新文件
  14474. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  14475. // new FileStream(newFilePath, FileMode.CreateNew)
  14476. using (var stream = new MemoryStream())
  14477. {
  14478. workbook.Write(stream, true);
  14479. stream.Flush();
  14480. stream.Seek(0, SeekOrigin.Begin);
  14481. var memoryStream = new MemoryStream();
  14482. stream.CopyTo(memoryStream);
  14483. memoryStream.Seek(0, SeekOrigin.Begin);
  14484. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  14485. }
  14486. workbook.Close();
  14487. workbook.Dispose();
  14488. }
  14489. catch (Exception ex)
  14490. {
  14491. jw.Msg = "出现异常!" + ex.Message;
  14492. return Ok(jw);
  14493. }
  14494. }
  14495. if (Zips.Count > 0)
  14496. {
  14497. var io = new IOOperatorHelper();
  14498. var byts = io.ConvertZipStream(Zips);
  14499. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  14500. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  14501. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  14502. }
  14503. else
  14504. {
  14505. jw.Msg = "暂无生成文件!";
  14506. }
  14507. return Ok(jw);
  14508. }
  14509. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  14510. {
  14511. string outStr = string.Empty;
  14512. switch (i)
  14513. {
  14514. case 0:
  14515. outStr = arr[0].SidName;
  14516. break;
  14517. case 1:
  14518. outStr = arr[0].DataPriceStr;
  14519. break;
  14520. case 2:
  14521. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  14522. break;
  14523. case 4:
  14524. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  14525. break;
  14526. case 7:
  14527. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  14528. {
  14529. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  14530. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  14531. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  14532. }
  14533. break;
  14534. case 8:
  14535. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  14536. {
  14537. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  14538. }
  14539. break;
  14540. case 9:
  14541. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  14542. {
  14543. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  14544. }
  14545. break;
  14546. case 10:
  14547. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  14548. {
  14549. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  14550. }
  14551. break;
  14552. }
  14553. return outStr;
  14554. }
  14555. #region OP行程单
  14556. /// <summary>
  14557. /// OP行程单初始化
  14558. /// </summary>
  14559. /// <param name="dto"></param>
  14560. /// <returns></returns>
  14561. [HttpPost]
  14562. public IActionResult InitOpTravel(InitOpTravelDto dto)
  14563. {
  14564. var jw = JsonView(false);
  14565. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  14566. var group = groupList.First();
  14567. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  14568. if (group == null)
  14569. {
  14570. jw.Msg = "暂无团组!";
  14571. return Ok(jw);
  14572. }
  14573. group = groupList.Find(x => x.Id == diid);
  14574. if (group == null)
  14575. {
  14576. jw.Msg = "请输入正确的团组ID!";
  14577. return Ok(jw);
  14578. }
  14579. string city = string.Empty;
  14580. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  14581. if (blackCode.Count > 0)
  14582. {
  14583. var black = blackCode.First();
  14584. black.BlackCode = black.BlackCode ?? "";
  14585. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  14586. if (blackSp.Length > 0)
  14587. {
  14588. try
  14589. {
  14590. var cityArrCode = new List<string>(20);
  14591. foreach (var item in blackSp)
  14592. {
  14593. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  14594. var IndexSelect = itemSp[2];
  14595. var cityArrCodeLength = cityArrCode.Count - 1;
  14596. var startCity = IndexSelect.Substring(0, 3);
  14597. if (cityArrCodeLength > 0)
  14598. {
  14599. var arrEndCity = cityArrCode[cityArrCodeLength];
  14600. if (arrEndCity != startCity)
  14601. {
  14602. cityArrCode.Add(startCity.ToUpper());
  14603. }
  14604. }
  14605. else
  14606. {
  14607. cityArrCode.Add(startCity.ToUpper());
  14608. }
  14609. var endCity = IndexSelect.Substring(3, 3);
  14610. cityArrCode.Add(endCity.ToUpper());
  14611. }
  14612. var cityThree = string.Empty;
  14613. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  14614. cityThree = cityThree.TrimEnd(',');
  14615. if (string.IsNullOrWhiteSpace(cityThree))
  14616. {
  14617. throw new
  14618. Exception("error");
  14619. }
  14620. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  14621. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  14622. foreach (var item in cityArrCode)
  14623. {
  14624. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  14625. if (find != null)
  14626. {
  14627. city += find.City + "/";
  14628. }
  14629. else
  14630. {
  14631. city += item + "三字码未收入/";
  14632. }
  14633. }
  14634. city = city.TrimEnd('/');
  14635. }
  14636. catch (Exception e)
  14637. {
  14638. city = "黑屏代码格式不正确!";
  14639. }
  14640. }
  14641. }
  14642. else
  14643. {
  14644. city = "未录入黑屏代码";
  14645. }
  14646. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  14647. {
  14648. Date = x.Date,
  14649. Days = x.Days,
  14650. Diffgroup = x.Diffgroup,
  14651. Diid = x.Diid,
  14652. Traffic_First = x.Traffic_First,
  14653. Traffic_Second = x.Traffic_Second,
  14654. Trip = x.Trip,
  14655. WeekDay = x.WeekDay,
  14656. Id = x.Id
  14657. }).ToList();
  14658. jw.Data = new
  14659. {
  14660. groupList = groupList.Select(x => new
  14661. {
  14662. x.Id,
  14663. x.TeamName,
  14664. x.TourCode
  14665. }).ToList(),
  14666. groupInfo = new
  14667. {
  14668. group.VisitDays,
  14669. group.TourCode,
  14670. group.VisitPNumber,
  14671. group.TeamName,
  14672. city
  14673. },
  14674. OpTravelList
  14675. };
  14676. jw.Code = 200;
  14677. jw.Msg = "操作成功!";
  14678. return Ok(jw);
  14679. }
  14680. /// <summary>
  14681. /// 删除团组行程单
  14682. /// </summary>
  14683. /// <returns></returns>
  14684. [HttpPost]
  14685. public IActionResult DelTravel(DelOpTravelDto dto)
  14686. {
  14687. var jw = JsonView(false);
  14688. if (dto.UserId <= 0 || dto.Diid <= 0)
  14689. {
  14690. jw.Msg = "请输入正确的参数!";
  14691. return Ok(jw);
  14692. }
  14693. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  14694. .SetColumns(x => new Grp_TravelList
  14695. {
  14696. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  14697. DeleteUserId = dto.UserId,
  14698. IsDel = 1,
  14699. }).ExecuteCommand();
  14700. jw = JsonView(true);
  14701. return Ok(jw);
  14702. }
  14703. /// <summary>
  14704. /// 行程单保存
  14705. /// </summary>
  14706. /// <returns></returns>
  14707. [HttpPost]
  14708. public IActionResult TravelSave(TravelSaveDto dto)
  14709. {
  14710. var jw = JsonView(false);
  14711. if (dto.Arr.Count > 0)
  14712. {
  14713. try
  14714. {
  14715. var travelList_DB = _sqlSugar.Queryable<Grp_TravelList>()
  14716. .Where(x => dto.Arr.Select(x => x.Id).Contains(x.Id))
  14717. .ToList();
  14718. _sqlSugar.BeginTran();
  14719. foreach (var item in dto.Arr)
  14720. {
  14721. if (item.Id == 0)
  14722. {
  14723. throw new Exception("请传入正确的Id");
  14724. }
  14725. //比较上一次的差异
  14726. var findTravel = travelList_DB.Find(x => x.Id == item.Id);
  14727. if (findTravel != null)
  14728. {
  14729. item.Trip = item.Trip.Replace("[++]", string.Empty);
  14730. findTravel.Trip = findTravel.Trip.Replace("[++]", string.Empty);
  14731. item.Trip = CheckStr(findTravel.Trip, item.Trip);
  14732. }
  14733. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  14734. .SetColumns(x => new Grp_TravelList
  14735. {
  14736. Trip = item.Trip
  14737. }).ExecuteCommand();
  14738. }
  14739. _sqlSugar.CommitTran();
  14740. jw = JsonView(true);
  14741. }
  14742. catch (Exception ex)
  14743. {
  14744. _sqlSugar.RollbackTran();
  14745. jw.Msg = "程序异常!" + ex.Message;
  14746. }
  14747. }
  14748. else
  14749. {
  14750. jw.Msg = "请传入正确的参数!";
  14751. }
  14752. return Ok(jw);
  14753. }
  14754. private static string CheckStr(string original, string changed)
  14755. {
  14756. // 创建diff_match_patch对象
  14757. var dmp = new diff_match_patch();
  14758. // 计算差异
  14759. List<Diff> diffs = dmp.diff_main(original, changed);
  14760. // 清理和合并差异
  14761. dmp.diff_cleanupSemantic(diffs);
  14762. // 使用StringBuilder构建最终的字符串
  14763. var finalString = new StringBuilder();
  14764. // 输出差异结果,并构建变动后的字符串
  14765. foreach (Diff diff in diffs)
  14766. {
  14767. switch (diff.operation)
  14768. {
  14769. case Operation.EQUAL:
  14770. // 相等的部分,直接添加到最终字符串
  14771. finalString.Append(diff.text);
  14772. break;
  14773. case Operation.INSERT:
  14774. // 插入的部分,添加标记并添加到最终字符串
  14775. finalString.Append("[++]" + diff.text + "[++]");
  14776. break;
  14777. case Operation.DELETE:
  14778. // 删除的部分,不添加到最终字符串
  14779. //finalString.Append("[++]" + diff.text + "[++]");
  14780. break;
  14781. }
  14782. }
  14783. // 输出变动后的字符串
  14784. return finalString.ToString();
  14785. }
  14786. private class tagContent
  14787. {
  14788. public DateTime Date { get; set; }
  14789. public string StartTag { get; set; }
  14790. public string EndTag { get; set; }
  14791. public string Content { get; set; }
  14792. public static int tagLength { get { return 3; } }
  14793. public static Tuple<string, string> TagFormat { get { return new Tuple<string, string>("【#", "#】"); } }
  14794. public string QueryTag { get { return this.StartTag + this.EndTag; } }
  14795. public bool IsFinally { get; set; }
  14796. }
  14797. private static List<string> ExtractContentBetweenTags(string input, string tag)
  14798. {
  14799. var results = new List<string>();
  14800. // 构造正则表达式,匹配形如 [++]内容[++] 的部分
  14801. string pattern = $@"{Regex.Escape(tag)}(.*?){Regex.Escape(tag)}";
  14802. // 添加 RegexOptions.Singleline 选项使 . 匹配包括换行符在内的所有字符
  14803. MatchCollection matches = Regex.Matches(input, pattern, RegexOptions.Singleline);
  14804. string[] strValueArr = new string[1];
  14805. foreach (System.Text.RegularExpressions.Match match in matches)
  14806. {
  14807. var strValue = match.Groups[1].Value;
  14808. strValueArr = Regex.Split(strValue, @"\r\n|\n");
  14809. }
  14810. results.AddRange(strValueArr.Where(x => !string.IsNullOrWhiteSpace(x)));
  14811. return results;
  14812. }
  14813. /// <summary>
  14814. /// 导出行程单
  14815. /// </summary>
  14816. /// <param name="dto"></param>
  14817. /// <returns></returns>
  14818. [HttpPost]
  14819. public IActionResult ExportTravel(ExportTravelDto dto)
  14820. {
  14821. var jw = JsonView(false);
  14822. jw.Data = "";
  14823. int diid = 0;
  14824. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  14825. if (Find == null)
  14826. {
  14827. jw.Msg = "请选择正确的团组!";
  14828. return Ok(jw);
  14829. }
  14830. else
  14831. {
  14832. diid = Find.Id;
  14833. }
  14834. //数据源
  14835. var _travelList = new List<Grp_TravelList>();
  14836. DataTable dtBlack = null;
  14837. try
  14838. {
  14839. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  14840. }
  14841. catch (Exception)
  14842. {
  14843. jw.Msg = "机票黑屏代码有误!";
  14844. return Ok(jw);
  14845. }
  14846. string CityStr = string.Empty;
  14847. if (dtBlack.Rows.Count == 0)
  14848. {
  14849. jw.Msg = "机票黑屏代码有误!";
  14850. return Ok(jw);
  14851. }
  14852. else
  14853. {
  14854. foreach (DataRow row in dtBlack.Rows)
  14855. {
  14856. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  14857. {
  14858. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  14859. return Ok(jw);
  14860. }
  14861. }
  14862. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  14863. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  14864. }
  14865. // 指定的文字
  14866. var targetTextDic = new Dictionary<string, List<string>>();
  14867. //创建数据源Table
  14868. var dtSource = new DataTable();
  14869. dtSource.Columns.Add("Days", typeof(string));
  14870. dtSource.Columns.Add("Date", typeof(string));
  14871. dtSource.Columns.Add("Week", typeof(string));
  14872. dtSource.Columns.Add("Traffic", typeof(string));
  14873. dtSource.Columns.Add("Trip", typeof(string));
  14874. //获取数据,放到datatable
  14875. foreach (var item in _travelList)
  14876. {
  14877. targetTextDic.Add(item.Date, ExtractContentBetweenTags(item.Trip, "[++]"));
  14878. item.Trip = item.Trip.Replace(tagContent.TagFormat.Item1, string.Empty)
  14879. .Replace(tagContent.TagFormat.Item2, string.Empty)
  14880. .Replace("[++]", string.Empty);
  14881. DataRow dr = dtSource.NewRow();
  14882. dr["Days"] = item.Days;
  14883. dr["Date"] = item.Date;
  14884. dr["Week"] = item.WeekDay;
  14885. dr["Traffic"] = item.Traffic_First
  14886. + "\r\n"
  14887. + item.Traffic_Second;
  14888. dr["Trip"] = item.Trip;
  14889. dtSource.Rows.Add(dr);
  14890. }
  14891. var dic = new Dictionary<string, string>
  14892. {
  14893. { "Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()) },
  14894. { "City", CityStr },
  14895. { "Days", Find.VisitDays.ToString() },
  14896. { "DeleCode", Find.TourCode },
  14897. { "Pnum", Find.VisitPNumber.ToString() }
  14898. };
  14899. //模板路径
  14900. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  14901. //载入模板
  14902. Document doc = null;
  14903. DocumentBuilder builder = null;
  14904. try
  14905. {
  14906. //载入模板
  14907. doc = new Document(tempPath);
  14908. builder = new DocumentBuilder(doc);
  14909. }
  14910. catch (Exception)
  14911. {
  14912. jw.Msg = "模板位置不存在!";
  14913. return Ok(jw);
  14914. }
  14915. foreach (var key in dic.Keys)
  14916. {
  14917. Bookmark bookmark = doc.Range.Bookmarks[key];
  14918. if (bookmark != null)
  14919. {
  14920. builder.MoveToBookmark(key);
  14921. builder.Write(dic[key]);
  14922. }
  14923. }
  14924. //获取word里所有表格
  14925. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  14926. //获取所填表格的序数
  14927. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  14928. try
  14929. {
  14930. //循环赋值
  14931. for (int i = 0; i < dtSource.Rows.Count; i++)
  14932. {
  14933. builder.MoveToCell(0, i + 1, 0, 0);
  14934. builder.Write(dtSource.Rows[i]["Days"].ToString());
  14935. builder.MoveToCell(0, i + 1, 1, 0);
  14936. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  14937. builder.MoveToCell(0, i + 1, 2, 0);
  14938. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  14939. var trip = dtSource.Rows[i]["Trip"].ToString();
  14940. builder.MoveToCell(0, i + 1, 3, 0);
  14941. builder.Write(trip);
  14942. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  14943. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  14944. // 获取特定索引的段落
  14945. Paragraph paragraph = (Paragraph)paragraphs[0];
  14946. Run run = paragraph.Runs[0];
  14947. Aspose.Words.Font font = run.Font;
  14948. font.Name = "黑体";
  14949. //设置双休红色
  14950. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  14951. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  14952. paragraph = (Paragraph)paragraphs[1];
  14953. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  14954. {
  14955. run = paragraph.Runs[0];
  14956. font = run.Font;
  14957. font.Color = Color.Red;
  14958. }
  14959. }
  14960. }
  14961. catch (Exception ex)
  14962. {
  14963. }
  14964. //删除多余行
  14965. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  14966. {
  14967. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  14968. }
  14969. var targetTextList = new List<string>();
  14970. // 遍历文档中的表格
  14971. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  14972. {
  14973. foreach (Aspose.Words.Tables.Row row in table.Rows)
  14974. {
  14975. var cellIndex = 0;
  14976. foreach (Cell cell in row.Cells)
  14977. {
  14978. if (cellIndex == 1 && row.Cells.Count == 4)
  14979. {
  14980. foreach (var target in targetTextDic.Keys)
  14981. {
  14982. if (cell.GetText().Contains(target))
  14983. {
  14984. targetTextList = targetTextDic[target];
  14985. break;
  14986. }
  14987. }
  14988. }
  14989. // 遍历单元格中的所有段落
  14990. foreach (Paragraph paragraph in cell.Paragraphs)
  14991. {
  14992. // 使用临时列表存储原始 Runs,避免修改时影响遍历
  14993. var runs = new List<Run>();
  14994. foreach (Run run in paragraph.Runs)
  14995. {
  14996. runs.Add(run);
  14997. }
  14998. foreach (Run run in runs)
  14999. {
  15000. foreach (var targetText in targetTextList)
  15001. {
  15002. // 检查文字是否包含指定文字
  15003. if (run.Text.Contains(targetText))
  15004. {
  15005. // 将包含的部分设置为红色
  15006. HighlightText(run, targetText, Color.Red);
  15007. }
  15008. }
  15009. }
  15010. }
  15011. cellIndex++;
  15012. }
  15013. }
  15014. }
  15015. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  15016. if (!Directory.Exists(savePath))
  15017. {
  15018. try
  15019. {
  15020. Directory.CreateDirectory(savePath);
  15021. }
  15022. catch
  15023. {
  15024. }
  15025. }
  15026. string path = savePath + Find.TeamName + "出访日程";
  15027. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  15028. try
  15029. {
  15030. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  15031. string postfix = ".docx";
  15032. if (dto.IsPDF == 1)
  15033. {
  15034. saveFormat = Aspose.Words.SaveFormat.Pdf;
  15035. postfix = ".pdf";
  15036. }
  15037. doc.Save(path + postfix, saveFormat);
  15038. jw = JsonView(true, "导出成功", ftpPath + postfix);
  15039. }
  15040. catch (Exception)
  15041. {
  15042. jw = JsonView(false);
  15043. }
  15044. return Ok(jw);
  15045. }
  15046. /// <summary>
  15047. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  15048. /// </summary>
  15049. /// <param name="num"></param>
  15050. /// <returns></returns>
  15051. static string GetNum(string num)
  15052. {
  15053. string str = "";
  15054. switch (num)
  15055. {
  15056. case "1":
  15057. str = "一";
  15058. break;
  15059. case "2":
  15060. str = "二";
  15061. break;
  15062. case "3":
  15063. str = "三";
  15064. break;
  15065. case "4":
  15066. str = "四";
  15067. break;
  15068. case "5":
  15069. str = "五";
  15070. break;
  15071. case "6":
  15072. str = "六";
  15073. break;
  15074. case "7":
  15075. str = "七";
  15076. break;
  15077. case "8":
  15078. str = "八";
  15079. break;
  15080. case "9":
  15081. str = "九";
  15082. break;
  15083. case "10":
  15084. str = "十";
  15085. break;
  15086. case "11":
  15087. str = "十一";
  15088. break;
  15089. case "12":
  15090. str = "十二";
  15091. break;
  15092. case "一":
  15093. str = "1";
  15094. break;
  15095. case "二":
  15096. str = "2";
  15097. break;
  15098. case "三":
  15099. str = "3";
  15100. break;
  15101. case "四":
  15102. str = "4";
  15103. break;
  15104. case "五":
  15105. str = "5";
  15106. break;
  15107. case "六":
  15108. str = "6";
  15109. break;
  15110. case "七":
  15111. str = "7";
  15112. break;
  15113. case "八":
  15114. str = "8";
  15115. break;
  15116. case "九":
  15117. str = "9";
  15118. break;
  15119. case "十":
  15120. str = "10";
  15121. break;
  15122. case "十一":
  15123. str = "11";
  15124. break;
  15125. case "十二":
  15126. str = "12";
  15127. break;
  15128. }
  15129. return str;
  15130. }
  15131. /// <summary>
  15132. /// 高亮包含指定文字的部分
  15133. /// </summary>
  15134. /// <param name="run"></param>
  15135. /// <param name="targetText"></param>
  15136. /// <param name="color"></param>
  15137. static void HighlightText(Run run, string targetText, Color color)
  15138. {
  15139. string text = run.Text;
  15140. int startIndex = text.IndexOf(targetText, StringComparison.Ordinal);
  15141. if (startIndex >= 0)
  15142. {
  15143. Paragraph parentParagraph = (Paragraph)run.ParentNode;
  15144. // 前部分
  15145. if (startIndex > 0)
  15146. {
  15147. Run beforeRun = (Run)run.Clone(true);
  15148. beforeRun.Text = text.Substring(0, startIndex);
  15149. parentParagraph.InsertBefore(beforeRun, run);
  15150. }
  15151. // 匹配部分
  15152. Run matchRun = (Run)run.Clone(true);
  15153. matchRun.Text = text.Substring(startIndex, targetText.Length);
  15154. matchRun.Font.Color = color;
  15155. parentParagraph.InsertBefore(matchRun, run);
  15156. // 后部分
  15157. if (startIndex + targetText.Length < text.Length)
  15158. {
  15159. Run afterRun = (Run)run.Clone(true);
  15160. afterRun.Text = text.Substring(startIndex + targetText.Length);
  15161. parentParagraph.InsertBefore(afterRun, run);
  15162. }
  15163. // 删除原始Run
  15164. run.Remove();
  15165. }
  15166. }
  15167. #endregion
  15168. #endregion
  15169. #region 团组成本
  15170. /// <summary>
  15171. /// 团组成本数据初始化
  15172. /// </summary>
  15173. /// <param name="dto"></param>
  15174. /// <returns></returns>
  15175. [HttpPost]
  15176. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  15177. {
  15178. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  15179. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  15180. WHEN COUNT(*) >= 0 THEN 'True'
  15181. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  15182. Where TeamName != '' And IsDel = 0 Order By a.VisitStartDate Desc
  15183. ").ToList(); //团组列表
  15184. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  15185. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  15186. var visaCountryInfoArr = new List<Res_CountryFeeCost>();
  15187. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  15188. if (groupinfoValue != null)
  15189. {
  15190. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  15191. var spArr = new string[1] { countryArr };
  15192. if (countryArr.Contains("|"))
  15193. {
  15194. spArr = countryArr.Split("|");
  15195. }
  15196. else if (countryArr.Contains("、"))
  15197. {
  15198. spArr = countryArr.Split("、");
  15199. }
  15200. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  15201. {
  15202. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  15203. if (dbQueryCountry != null)
  15204. {
  15205. visaCountryInfoArr.Add(dbQueryCountry);
  15206. }
  15207. }
  15208. }
  15209. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  15210. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  15211. #region 屏蔽黑屏代码生成
  15212. //var create = _GroupCostRepository.
  15213. // CreateGroupCostByBlackCode(dto.Diid);
  15214. //if (groupCost.Count == 0 && create.Code == 0)
  15215. //{
  15216. // groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  15217. //}
  15218. #endregion
  15219. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  15220. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  15221. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  15222. groupCostMap = groupCostMap.Select(x =>
  15223. {
  15224. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  15225. {
  15226. x.Date = dataForamt.ToString("yyyy-MM-dd");
  15227. }
  15228. return x;
  15229. }).ToList();
  15230. //GroupCostParameter.Add(new
  15231. // Grp_GroupCostParameter());
  15232. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  15233. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == diid && x.IsDel == 0).Count() > 0;
  15234. var groupModuleOperators = GeneralMethod.GetGroupModuleOperators(diid);
  15235. return Ok(JsonView(new
  15236. {
  15237. groupList,
  15238. groupInfo,
  15239. groupChecks,
  15240. groupCost = groupCostMap,
  15241. hotelNumber,
  15242. GroupCostParameter = GroupCostParameterMap,
  15243. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  15244. {
  15245. x.VisaCountry,
  15246. x.VisaPrice,
  15247. x.Id,
  15248. IsVisaExemption = x.IsVisaExemption == 1 ? "否" : "是", //免签
  15249. IsElectronicSignature = x.IsElectronicSignature == 1 ? "否" : "是", //电子签
  15250. IsVisaOnArrival = x.IsVisaOnArrival == 1 ? "否" : "是", //落地签
  15251. x.VisaTime, // 一般签证时间
  15252. x.PettyBusinessAgencyFee, //小公务代办费
  15253. x.GrandBusinessAgencyFee //大公务代办费
  15254. }).ToList(),
  15255. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  15256. blackCodeIsTrue = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).Any(), //create.Code == 0 ? true : false,
  15257. hotelIsTrue,
  15258. groupModuleOperators
  15259. }));
  15260. }
  15261. /// <summary>
  15262. /// 团组成本信息保存
  15263. /// </summary>
  15264. /// <param name="dto"></param>
  15265. /// <returns></returns>
  15266. [HttpPost]
  15267. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  15268. {
  15269. if (dto.Diid <= 0 || dto.Userid <= 0)
  15270. {
  15271. return Ok(JsonView(false));
  15272. }
  15273. JsonView jw = null;
  15274. bool isTrue = false;
  15275. #region 复制团组成本
  15276. //if (dto.Diid == 2581)
  15277. //{
  15278. // dto.Diid = 2599;
  15279. // dto.CheckBoxs.ForEach(x =>
  15280. // {
  15281. // x.Diid = 2599;
  15282. // });
  15283. // dto.GroupCosts.ForEach(x =>
  15284. // {
  15285. // x.Diid = 2599;
  15286. // });
  15287. // dto.CostTypeHotelNumbers.ForEach(x =>
  15288. // {
  15289. // x.Diid = 2599;
  15290. // });
  15291. // dto.GroupCostParameters.ForEach(x =>
  15292. // {
  15293. // x.DiId = 2599;
  15294. // });
  15295. //}
  15296. #endregion
  15297. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  15298. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  15299. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  15300. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  15301. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  15302. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  15303. try
  15304. {
  15305. _sqlSugar.BeginTran();
  15306. isTrue = await _GroupCostRepository.
  15307. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  15308. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  15309. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  15310. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  15311. _sqlSugar.CommitTran();
  15312. jw = JsonView(true, "保存成功!", isTrue);
  15313. }
  15314. catch (Exception)
  15315. {
  15316. _sqlSugar.RollbackTran();
  15317. jw = JsonView(false);
  15318. }
  15319. return Ok(jw);
  15320. }
  15321. /// <summary>
  15322. /// 复制团组成本信息
  15323. /// </summary>
  15324. /// <param name="dto"></param>
  15325. /// <returns></returns>
  15326. [HttpPost]
  15327. public async Task<IActionResult> CopyGroupCost(CopyGroupCostDto dto)
  15328. {
  15329. if (dto.Diid <= 0 || dto.Userid <= 0 || dto.ToGroupId <= 0)
  15330. {
  15331. return Ok(JsonView(false, "参数有误!"));
  15332. }
  15333. #region 复制团组成本
  15334. dto.Diid = dto.ToGroupId;
  15335. dto.CheckBoxs.ForEach(x =>
  15336. {
  15337. x.Diid = dto.ToGroupId;
  15338. });
  15339. dto.GroupCosts.ForEach(x =>
  15340. {
  15341. x.Diid = dto.ToGroupId;
  15342. });
  15343. dto.CostTypeHotelNumbers.ForEach(x =>
  15344. {
  15345. x.Diid = dto.ToGroupId;
  15346. });
  15347. dto.GroupCostParameters.ForEach(x =>
  15348. {
  15349. x.DiId = dto.ToGroupId;
  15350. });
  15351. #endregion
  15352. JsonView jw = null;
  15353. bool isTrue = false;
  15354. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  15355. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  15356. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  15357. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  15358. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  15359. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  15360. try
  15361. {
  15362. _sqlSugar.BeginTran();
  15363. isTrue = await _GroupCostRepository.
  15364. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  15365. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  15366. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  15367. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  15368. _sqlSugar.CommitTran();
  15369. jw = JsonView(true, "保存成功!", isTrue);
  15370. }
  15371. catch (Exception)
  15372. {
  15373. _sqlSugar.RollbackTran();
  15374. jw = JsonView(false);
  15375. }
  15376. return Ok(jw);
  15377. }
  15378. /// <summary>
  15379. /// 司兼导数据
  15380. /// </summary>
  15381. /// <param name="dto"></param>
  15382. /// <returns></returns>
  15383. [HttpPost]
  15384. public IActionResult GetCarGuides(CarGuidesDto dto)
  15385. {
  15386. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  15387. return Ok(JsonView(true, "获取成功!", Data));
  15388. }
  15389. /// <summary>
  15390. /// 导游数据
  15391. /// </summary>
  15392. /// <param name="dto"></param>
  15393. /// <returns></returns>
  15394. [HttpPost]
  15395. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  15396. {
  15397. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  15398. // 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
  15399. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  15400. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  15401. return Ok(JsonView(true, "获取成功!", Data));
  15402. }
  15403. /// <summary>
  15404. /// 成本车数据
  15405. /// </summary>
  15406. /// <param name="dto"></param>
  15407. /// <returns></returns>
  15408. [HttpPost]
  15409. public IActionResult GetCarInfo(CarGuidesDto dto)
  15410. {
  15411. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  15412. return Ok(JsonView(true, "获取成功!", Data));
  15413. }
  15414. /// <summary>
  15415. /// 景点数据
  15416. /// </summary>
  15417. /// <param name="dto"></param>
  15418. /// <returns></returns>
  15419. [HttpPost]
  15420. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  15421. {
  15422. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  15423. return Ok(JsonView(true, "获取成功!", Data));
  15424. }
  15425. /// <summary>
  15426. /// 成本通知
  15427. /// </summary>
  15428. /// <param name="dto"></param>
  15429. /// <returns></returns>
  15430. [HttpPost]
  15431. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  15432. {
  15433. if (dto.Diid < 0)
  15434. {
  15435. return Ok(JsonView(false));
  15436. }
  15437. JsonView jw;
  15438. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  15439. if (GroupCostParameter != null)
  15440. {
  15441. int IsShare = 0;
  15442. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  15443. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  15444. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  15445. string msg = string.Empty;
  15446. if (isTrue)
  15447. {
  15448. if (IsShare == 0)
  15449. {
  15450. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  15451. }
  15452. else
  15453. {
  15454. #region 企微通知对应岗位用户
  15455. try
  15456. {
  15457. await AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  15458. }
  15459. catch (Exception)
  15460. {
  15461. }
  15462. #endregion
  15463. msg = "通知成功,其他模块操作人员可见此成本信息!";
  15464. }
  15465. jw = JsonView(isTrue, msg, new { IsShare });
  15466. }
  15467. else
  15468. {
  15469. msg = "修改失败!";
  15470. jw = JsonView(isTrue, msg);
  15471. }
  15472. }
  15473. else
  15474. {
  15475. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  15476. }
  15477. return Ok(jw);
  15478. }
  15479. /// <summary>
  15480. /// 导出报价单
  15481. /// </summary>
  15482. /// <param name="dto"></param>
  15483. /// <returns></returns>
  15484. [HttpPost]
  15485. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  15486. {
  15487. if (dto.Diid == 0)
  15488. {
  15489. return Ok(JsonView(false, "请传递团组id"));
  15490. }
  15491. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  15492. if (deleInfo.Code != 0)
  15493. {
  15494. return Ok(JsonView(false, "团组信息查询失败!"));
  15495. }
  15496. var di = deleInfo.Data as DelegationInfoWebView;
  15497. if (di != null)
  15498. {
  15499. di.TeamName = di.TeamName.Replace("|", "、");
  15500. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  15501. //文件名
  15502. string strFileName = di.TeamName + "-收款账单.doc";
  15503. //获取模板
  15504. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  15505. //载入模板
  15506. Document doc = new Document(tmppath);
  15507. decimal TotalPrice = 0.00M;
  15508. string itemStr = string.Empty;
  15509. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  15510. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  15511. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  15512. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  15513. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  15514. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  15515. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  15516. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  15517. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  15518. foreach (var cost in groupCostType)
  15519. {
  15520. var List = cost.ToList();
  15521. if (cost.Key == "A")
  15522. {
  15523. foreach (var ListItem in List)
  15524. {
  15525. if (ListItem.number > 0)
  15526. {
  15527. if (ListItem.code.Contains("TBR"))
  15528. {
  15529. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  15530. }
  15531. else
  15532. {
  15533. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  15534. }
  15535. TotalPrice += (ListItem.number * ListItem.price);
  15536. }
  15537. }
  15538. }
  15539. else
  15540. {
  15541. itemStr = itemStr.Insert(0, "A段\r\n");
  15542. itemStr += "B段\r\n";
  15543. foreach (var ListItem in List)
  15544. {
  15545. if (ListItem.number > 0)
  15546. {
  15547. if (ListItem.code.Contains("TBR"))
  15548. {
  15549. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  15550. }
  15551. else
  15552. {
  15553. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  15554. }
  15555. TotalPrice += (ListItem.number * ListItem.price);
  15556. }
  15557. }
  15558. }
  15559. }
  15560. #region 替换Word模板书签内容
  15561. Dictionary<string, string> marks = new Dictionary<string, string>();
  15562. marks.Add("To", di.ClientUnit);//付款方
  15563. marks.Add("ToTel", di.TellPhone);//付款方电话
  15564. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  15565. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  15566. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  15567. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  15568. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  15569. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  15570. marks.Add("PayItemContent", itemStr);//详细信息
  15571. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  15572. #endregion
  15573. ////注
  15574. //if (doc.Range.Bookmarks["Attention"] != null)
  15575. //{
  15576. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  15577. // mark.Text = frList[0].Attention;
  15578. //}
  15579. foreach (var item in marks.Keys)
  15580. {
  15581. if (doc.Range.Bookmarks[item] != null)
  15582. {
  15583. Bookmark mark = doc.Range.Bookmarks[item];
  15584. mark.Text = marks[item];
  15585. }
  15586. }
  15587. byte[] bytes = null;
  15588. using (MemoryStream stream = new MemoryStream())
  15589. {
  15590. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  15591. bytes = stream.ToArray();
  15592. }
  15593. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  15594. return Ok(JsonView(true, "", new
  15595. {
  15596. Data = bytes,
  15597. strFileName,
  15598. }));
  15599. }
  15600. else
  15601. {
  15602. return Ok(JsonView(false, "团组信息不存在!"));
  15603. }
  15604. }
  15605. /// <summary>
  15606. /// 导出团组成本
  15607. /// </summary>
  15608. /// <param name="dto"></param>
  15609. /// <returns></returns>
  15610. [HttpPost]
  15611. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  15612. {
  15613. var jw = JsonView(false);
  15614. if (dto.Diid == 0)
  15615. {
  15616. return Ok(JsonView(false, "请传递团组id"));
  15617. }
  15618. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  15619. if (deleInfo.Code != 0)
  15620. {
  15621. return Ok(JsonView(false, "团组信息查询失败!"));
  15622. }
  15623. var di = deleInfo.Data as DelegationInfoWebView;
  15624. if (di == null)
  15625. {
  15626. return Ok(JsonView(false, "团组信息查询失败!"));
  15627. }
  15628. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  15629. WorkbookDesigner designer = new WorkbookDesigner();
  15630. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  15631. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  15632. List<int> hideColumnList = new List<int>();
  15633. var ColumnSetting = new[]
  15634. {
  15635. new { tag = "VF", Index = 4, P = "CarCost" },
  15636. new { tag = "VN", Index = 5, P = "CarNumber" },
  15637. new { tag = "VRD", Index = 6, P = "CarTiming" },
  15638. new { tag = "T/G S", Index = 7, P = "TGS" },
  15639. new { tag = "TGWH", Index = 8, P = "TGWH" },
  15640. new { tag = "T/G OF", Index = 9, P = "TGOF" },
  15641. new { tag = "T/G M", Index = 10, P = "TGM" },
  15642. new { tag = "T/G A", Index = 11, P = "TGA" },
  15643. new { tag = "T/G TF", Index = 12, P = "TGTF" },
  15644. new { tag = "T/G EF", Index = 13, P = "TGEF" },
  15645. new { tag = "C/F S", Index = 14, P = "CFS" },
  15646. new { tag = "C/F M", Index = 15, P = "CFM" },
  15647. new { tag = "C/F OF", Index = 16, P = "CFOF" },
  15648. new { tag = "B", Index = 17, P = "B" },
  15649. new { tag = "L", Index = 18, P = "L" },
  15650. new { tag = "D", Index = 19, P = "D" },
  15651. new { tag = "TBR", Index = 20, P = "TBR" },
  15652. new { tag = "SGR", Index = 21, P = "SGR" },
  15653. new { tag = "JS/ES", Index = 22, P = "JS_ES" },
  15654. new { tag = "Suite", Index = 23, P = "Suite" },
  15655. new { tag = "ACCO N", Index = 24, P = "ACCON" },
  15656. new { tag = "T/V", Index = 25, P = "TV" },
  15657. new { tag = "1/L", Index = 26, P = "iL" },
  15658. new { tag = "I/F", Index = 27, P = "IF" },
  15659. new { tag = "EF", Index = 28, P = "EF" },
  15660. new { tag = "B/R/F", Index = 29, P = "B_R_F" },
  15661. new { tag = "TE", Index = 30, P = "TE" },
  15662. new { tag = "T/G T", Index = 31, P = "TGTips" },
  15663. new { tag = "DRV T", Index = 32, P = "DRVTips" },
  15664. new { tag = "P/C", Index = 33, P = "PC" },
  15665. new { tag = "T/L F", Index = 34, P = "TLF" },
  15666. new { tag = "E/C T", Index = 35, P = "ECT" }
  15667. };
  15668. Func<string, bool> isEmpty = (str) =>
  15669. {
  15670. if (decimal.TryParse(str, out decimal str_De) && str_De == 0)
  15671. {
  15672. return true;
  15673. }
  15674. if (string.IsNullOrWhiteSpace(str))
  15675. {
  15676. return true;
  15677. }
  15678. return false;
  15679. };
  15680. for (int i = 0; i < List_GC.Count; i++)
  15681. {
  15682. GroupCost_Excel gc = new GroupCost_Excel();
  15683. gc.Id = List_GC[i].Id;
  15684. gc.Diid = List_GC[i].Diid.ToString();
  15685. gc.DAY = List_GC[i].DAY;
  15686. string week = "";
  15687. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  15688. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  15689. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  15690. gc.ITIN = List_GC[i].ITIN;
  15691. gc.CarType = List_GC[i].CarType;
  15692. gc.CarTiming = isEmpty(List_GC[i].CarTiming.ToString()) ? "" : List_GC[i].CarTiming.ToString();
  15693. gc.CarCost = isEmpty(List_GC[i].CarCost.ToString()) ? "" : List_GC[i].CarCost.ToString();
  15694. gc.CarNumber = isEmpty(List_GC[i].CarNumber.ToString()) ? "" : List_GC[i].CarNumber.ToString();
  15695. gc.TGS = isEmpty(List_GC[i].TGS.ToString()) ? "" : List_GC[i].TGS.ToString();
  15696. gc.TGWH = isEmpty(List_GC[i].TGWH.ToString()) ? "" : List_GC[i].TGWH.ToString();
  15697. gc.TGN = isEmpty(List_GC[i].TGN.ToString()) ? "" : List_GC[i].TGN.ToString();
  15698. gc.TGOF = isEmpty(List_GC[i].TGOF.ToString()) ? "" : List_GC[i].TGOF.ToString();
  15699. gc.TGM = isEmpty(List_GC[i].TGM.ToString()) ? "" : List_GC[i].TGM.ToString();
  15700. gc.TGA = isEmpty(List_GC[i].TGA.ToString()) ? "" : List_GC[i].TGA.ToString();
  15701. gc.TGTF = isEmpty(List_GC[i].TGTF.ToString()) ? "" : List_GC[i].TGTF.ToString();
  15702. gc.TGEF = isEmpty(List_GC[i].TGEF.ToString()) ? "" : List_GC[i].TGEF.ToString();
  15703. gc.CFS = isEmpty(List_GC[i].CFS.ToString()) ? "" : List_GC[i].CFS.ToString();
  15704. gc.CFM = isEmpty(List_GC[i].CFM.ToString()) ? "" : List_GC[i].CFM.ToString();
  15705. gc.CFOF = isEmpty(List_GC[i].CFOF.ToString()) ? "" : List_GC[i].CFOF.ToString();
  15706. gc.B = isEmpty(List_GC[i].B.ToString()) ? "" : List_GC[i].B.ToString();
  15707. gc.L = isEmpty(List_GC[i].L.ToString()) ? "" : List_GC[i].L.ToString();
  15708. gc.D = isEmpty(List_GC[i].D.ToString()) ? "" : List_GC[i].D.ToString();
  15709. gc.TBR = isEmpty(List_GC[i].TBR.ToString()) ? "" : List_GC[i].TBR.ToString();
  15710. gc.SGR = isEmpty(List_GC[i].SGR.ToString()) ? "" : List_GC[i].SGR.ToString();
  15711. gc.JS_ES = isEmpty(List_GC[i].JS_ES.ToString()) ? "" : List_GC[i].JS_ES.ToString();
  15712. gc.Suite = isEmpty(List_GC[i].Suite.ToString()) ? "" : List_GC[i].Suite.ToString();
  15713. gc.ACCON = isEmpty(List_GC[i].ACCON.ToString()) ? "" : List_GC[i].ACCON.ToString();
  15714. gc.TV = isEmpty(List_GC[i].TV.ToString()) ? "" : List_GC[i].TV.ToString();
  15715. gc.iL = isEmpty(List_GC[i].iL.ToString()) ? "" : List_GC[i].iL.ToString();
  15716. gc.IF = isEmpty(List_GC[i].IF.ToString()) ? "" : List_GC[i].IF.ToString();
  15717. gc.EF = isEmpty(List_GC[i].EF.ToString()) ? "" : List_GC[i].EF.ToString();
  15718. gc.B_R_F = isEmpty(List_GC[i].B_R_F.ToString()) ? "" : List_GC[i].B_R_F.ToString();
  15719. gc.TE = isEmpty(List_GC[i].TE.ToString()) ? "" : List_GC[i].TE.ToString();
  15720. gc.TGTips = isEmpty(List_GC[i].TGTips.ToString()) ? "" : List_GC[i].TGTips.ToString();
  15721. gc.DRVTips = isEmpty(List_GC[i].DRVTips.ToString()) ? "" : List_GC[i].DRVTips.ToString();
  15722. gc.PC = isEmpty(List_GC[i].PC.ToString()) ? "" : List_GC[i].PC.ToString();
  15723. gc.TLF = isEmpty(List_GC[i].TLF.ToString()) ? "" : List_GC[i].TLF.ToString();
  15724. gc.ECT = isEmpty(List_GC[i].ECT.ToString()) ? "" : List_GC[i].ECT.ToString();
  15725. gc.EFR = List_GC[i].EFR;
  15726. List_GC1.Add(gc);
  15727. }
  15728. if (List_GC1.Count > 0)
  15729. {
  15730. var p = List_GC1[0];
  15731. var prs = p.GetType().GetProperties();
  15732. foreach (var item in prs)
  15733. {
  15734. var tp = item.PropertyType;
  15735. if (tp == typeof(int))
  15736. {
  15737. var val = List_GC1.Sum(x => (int)x.GetType().GetProperty(item.Name).GetValue(x));
  15738. if (val == 0)
  15739. {
  15740. var columnSetting = ColumnSetting.FirstOrDefault(x => x.P == item.Name);
  15741. if (columnSetting != null)
  15742. {
  15743. hideColumnList.Add(columnSetting.Index);
  15744. }
  15745. }
  15746. }
  15747. if (tp == typeof(decimal))
  15748. {
  15749. var val = List_GC1.Sum(x => (decimal)x.GetType().GetProperty(item.Name).GetValue(x));
  15750. if (val == 0)
  15751. {
  15752. var columnSetting = ColumnSetting.FirstOrDefault(x => x.P == item.Name);
  15753. if (columnSetting != null)
  15754. {
  15755. hideColumnList.Add(columnSetting.Index);
  15756. }
  15757. }
  15758. }
  15759. if (tp == typeof(string))
  15760. {
  15761. var val = List_GC1.Sum(x =>
  15762. {
  15763. var str = (string)x.GetType().GetProperty(item.Name).GetValue(x);
  15764. if (decimal.TryParse(str, out decimal str_De))
  15765. {
  15766. return str_De;
  15767. }
  15768. else
  15769. {
  15770. return string.IsNullOrEmpty((string)x.GetType().GetProperty(item.Name).GetValue(x)) ? 0 : 1;
  15771. }
  15772. });
  15773. if (val == 0)
  15774. {
  15775. var columnSetting = ColumnSetting.FirstOrDefault(x => x.P == item.Name);
  15776. if (columnSetting != null)
  15777. {
  15778. hideColumnList.Add(columnSetting.Index);
  15779. }
  15780. }
  15781. }
  15782. }
  15783. }
  15784. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  15785. dt.TableName = "TB";
  15786. //报表标题等不用dt的值
  15787. designer.SetDataSource("TeamName", dto.title.TeamName);
  15788. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  15789. designer.SetDataSource("Tax", dto.title.Tax);
  15790. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  15791. designer.SetDataSource("Currency", dto.title.Currency);
  15792. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  15793. designer.SetDataSource("Rate", dto.title.Rate);
  15794. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  15795. var Aparams = hotels.Find(x => x.Type == "Default");
  15796. if (Aparams == null)
  15797. {
  15798. return Ok(jw);
  15799. }
  15800. //酒店数量
  15801. var txtSGRNumber = Aparams.SGR.ToString();
  15802. var txtTBRNumber = Aparams.TBR.ToString();
  15803. var txtJSESNumber = Aparams.JSES.ToString();
  15804. var txtSUITENumbe = Aparams.SUITE.ToString();
  15805. if (dto.costType == "B")
  15806. {
  15807. Aparams = hotels.Find(x => x.Type == "A");
  15808. var Bparams = hotels.Find(x => x.Type == "B");
  15809. if (Aparams == null || Bparams == null)
  15810. {
  15811. return Ok(jw);
  15812. }
  15813. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  15814. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  15815. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  15816. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  15817. }
  15818. designer.SetDataSource("SGRNumber", txtSGRNumber);
  15819. designer.SetDataSource("TBRNumber", txtTBRNumber);
  15820. designer.SetDataSource("JSESNumber", txtJSESNumber);
  15821. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  15822. var ws = designer.Workbook.Worksheets[1];
  15823. int Row = List_GC.Count;
  15824. int startIndex = 0;
  15825. int HideRows = 0;
  15826. Row = 0;
  15827. List<int> hideRowsList = new List<int>();
  15828. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  15829. #region A段left数据
  15830. var left = dto.leftInfo.Find(x => x.Type == "A");
  15831. if (left == null)
  15832. {
  15833. return Ok(jw);
  15834. }
  15835. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  15836. if (leftBindData != null)
  15837. {
  15838. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  15839. designer.SetDataSource("VisaRS", leftBindData.rs);
  15840. designer.SetDataSource("VisaXS", leftBindData.xs);
  15841. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15842. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15843. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15844. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15845. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15846. }
  15847. else
  15848. {
  15849. hideRowsList.Add(Row + startIndex + HideRows);
  15850. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15851. }
  15852. HideRows += 2;
  15853. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  15854. if (leftBindData != null)
  15855. {
  15856. designer.SetDataSource("BXDRCB", leftBindData.cb);
  15857. designer.SetDataSource("BXRS", leftBindData.rs);
  15858. designer.SetDataSource("BXXS", leftBindData.xs);
  15859. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15860. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15861. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15862. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15863. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15864. }
  15865. else
  15866. {
  15867. hideRowsList.Add(Row + startIndex + HideRows);
  15868. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15869. }
  15870. HideRows += 2;
  15871. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  15872. if (leftBindData != null)
  15873. {
  15874. designer.SetDataSource("HSDRCB", leftBindData.cb);
  15875. designer.SetDataSource("HSRS", leftBindData.rs);
  15876. designer.SetDataSource("HSXS", leftBindData.xs);
  15877. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15878. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15879. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15880. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15881. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15882. }
  15883. else
  15884. {
  15885. hideRowsList.Add(Row + startIndex + HideRows);
  15886. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15887. }
  15888. HideRows += 2;
  15889. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  15890. if (leftBindData != null)
  15891. {
  15892. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  15893. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  15894. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  15895. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15896. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15897. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15898. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15899. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15900. }
  15901. else
  15902. {
  15903. hideRowsList.Add(Row + startIndex + HideRows);
  15904. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15905. }
  15906. HideRows += 2;
  15907. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  15908. if (leftBindData != null)
  15909. {
  15910. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  15911. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  15912. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  15913. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15914. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15915. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15916. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15917. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15918. }
  15919. else
  15920. {
  15921. hideRowsList.Add(Row + startIndex + HideRows);
  15922. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15923. }
  15924. HideRows += 2;
  15925. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  15926. if (leftBindData != null)
  15927. {
  15928. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  15929. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  15930. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  15931. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15932. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15933. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15934. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15935. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15936. }
  15937. else
  15938. {
  15939. hideRowsList.Add(Row + startIndex + HideRows);
  15940. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15941. }
  15942. HideRows += 2;
  15943. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  15944. if (leftBindData != null)
  15945. {
  15946. ////TBR
  15947. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  15948. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  15949. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  15950. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15951. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15952. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15953. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15954. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15955. }
  15956. else
  15957. {
  15958. hideRowsList.Add(Row + startIndex + HideRows);
  15959. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15960. }
  15961. HideRows += 2;
  15962. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  15963. if (leftBindData != null)
  15964. {
  15965. ////SGR
  15966. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  15967. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  15968. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  15969. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15970. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15971. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15972. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15973. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15974. }
  15975. else
  15976. {
  15977. hideRowsList.Add(Row + startIndex + HideRows);
  15978. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15979. }
  15980. HideRows += 2;
  15981. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  15982. if (leftBindData != null)
  15983. {
  15984. ////JS/ES
  15985. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  15986. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  15987. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  15988. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15989. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15990. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15991. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15992. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15993. }
  15994. else
  15995. {
  15996. hideRowsList.Add(Row + startIndex + HideRows);
  15997. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15998. }
  15999. HideRows += 2;
  16000. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  16001. if (leftBindData != null)
  16002. {
  16003. ////SUITE
  16004. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  16005. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  16006. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  16007. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16008. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16009. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16010. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16011. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16012. }
  16013. else
  16014. {
  16015. hideRowsList.Add(Row + startIndex + HideRows);
  16016. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  16017. }
  16018. HideRows += 2;
  16019. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  16020. if (leftBindData != null)
  16021. {
  16022. designer.SetDataSource("DJDRCB", leftBindData.cb);
  16023. designer.SetDataSource("DJRS", leftBindData.rs);
  16024. designer.SetDataSource("DJXS", leftBindData.xs);
  16025. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16026. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16027. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16028. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16029. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16030. }
  16031. else
  16032. {
  16033. hideRowsList.Add(Row + startIndex + HideRows);
  16034. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  16035. }
  16036. HideRows += 2;
  16037. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  16038. if (leftBindData != null)
  16039. {
  16040. designer.SetDataSource("HCPCB", leftBindData.cb);
  16041. designer.SetDataSource("HCPRS", leftBindData.rs);
  16042. designer.SetDataSource("HCPXS", leftBindData.xs);
  16043. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16044. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16045. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16046. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16047. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16048. }
  16049. else
  16050. {
  16051. hideRowsList.Add(Row + startIndex + HideRows);
  16052. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  16053. }
  16054. HideRows += 2;
  16055. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  16056. if (leftBindData != null)
  16057. {
  16058. designer.SetDataSource("CPCB", leftBindData.cb);
  16059. designer.SetDataSource("CPRS", leftBindData.rs);
  16060. designer.SetDataSource("CPXS", leftBindData.xs);
  16061. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16062. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16063. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16064. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16065. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16066. }
  16067. else
  16068. {
  16069. hideRowsList.Add(Row + startIndex + HideRows);
  16070. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  16071. }
  16072. HideRows += 2;
  16073. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  16074. if (leftBindData != null)
  16075. {
  16076. designer.SetDataSource("GWDRCD", leftBindData.cb);
  16077. designer.SetDataSource("GWRS", leftBindData.rs);
  16078. designer.SetDataSource("GWXS", leftBindData.xs);
  16079. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16080. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16081. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16082. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16083. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16084. }
  16085. else
  16086. {
  16087. hideRowsList.Add(Row + startIndex + HideRows);
  16088. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  16089. }
  16090. HideRows += 2;
  16091. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  16092. if (leftBindData != null)
  16093. {
  16094. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  16095. designer.SetDataSource("LYJRS", leftBindData.rs);
  16096. designer.SetDataSource("LYJXS", leftBindData.xs);
  16097. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16098. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16099. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16100. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16101. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16102. }
  16103. else
  16104. {
  16105. hideRowsList.Add(Row + startIndex + HideRows);
  16106. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  16107. }
  16108. #endregion
  16109. #region A段Right信息
  16110. var right = dto.rightInfo.Find(x => x.Type == "A");
  16111. if (right == null)
  16112. {
  16113. return Ok(jw);
  16114. }
  16115. HideRows += 4;
  16116. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  16117. if (rightBindData != null)
  16118. {
  16119. //经济舱 + 双人间 TBR
  16120. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  16121. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  16122. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16123. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  16124. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16125. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16126. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16127. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16128. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16129. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16130. }
  16131. else
  16132. {
  16133. hideRowsList.Add(Row + startIndex + HideRows);
  16134. }
  16135. HideRows += 2;
  16136. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  16137. if (rightBindData != null)
  16138. {
  16139. //经济舱 + 单人间 SGR
  16140. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  16141. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  16142. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16143. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  16144. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16145. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16146. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16147. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16148. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16149. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16150. }
  16151. else
  16152. {
  16153. hideRowsList.Add(Row + startIndex + HideRows);
  16154. }
  16155. HideRows += 2;
  16156. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  16157. if (rightBindData != null)
  16158. {
  16159. //公务舱 + 单人间 SGR
  16160. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  16161. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  16162. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16163. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  16164. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16165. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16166. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16167. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16168. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16169. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16170. }
  16171. else
  16172. {
  16173. hideRowsList.Add(Row + startIndex + HideRows);
  16174. }
  16175. HideRows += 2;
  16176. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  16177. if (rightBindData != null)
  16178. {
  16179. //公务舱 + 小套房 JSES
  16180. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  16181. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  16182. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16183. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  16184. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16185. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16186. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16187. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16188. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16189. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16190. }
  16191. else
  16192. {
  16193. hideRowsList.Add(Row + startIndex + HideRows);
  16194. }
  16195. HideRows += 2;
  16196. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  16197. if (rightBindData != null)
  16198. {
  16199. //公务舱 + 小套房 JSES
  16200. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  16201. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  16202. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16203. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  16204. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16205. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16206. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16207. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16208. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16209. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16210. }
  16211. else
  16212. {
  16213. hideRowsList.Add(Row + startIndex + HideRows);
  16214. }
  16215. HideRows += 2;
  16216. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  16217. if (rightBindData != null)
  16218. {
  16219. //经济舱 + 大套房
  16220. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  16221. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  16222. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16223. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  16224. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16225. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16226. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16227. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16228. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16229. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16230. }
  16231. else
  16232. {
  16233. hideRowsList.Add(Row + startIndex + HideRows);
  16234. }
  16235. HideRows += 2;
  16236. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  16237. if (rightBindData != null)
  16238. {
  16239. //头等舱 + 小套房 JSES
  16240. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  16241. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  16242. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16243. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  16244. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16245. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16246. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16247. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16248. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16249. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16250. }
  16251. else
  16252. {
  16253. hideRowsList.Add(Row + startIndex + HideRows);
  16254. }
  16255. HideRows += 2;
  16256. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  16257. if (rightBindData != null)
  16258. {
  16259. //头等舱 + 大套房
  16260. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  16261. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  16262. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16263. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  16264. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16265. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16266. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16267. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16268. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16269. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16270. }
  16271. else
  16272. {
  16273. hideRowsList.Add(Row + startIndex + HideRows);
  16274. }
  16275. #endregion
  16276. #region B段标题清空
  16277. designer.SetDataSource("CostBDRCB", "");
  16278. designer.SetDataSource("CostBRS", "");
  16279. designer.SetDataSource("CostBXS", "");
  16280. designer.SetDataSource("CostBZCB", "");
  16281. designer.SetDataSource("CostBDRBJ", "");
  16282. designer.SetDataSource("CostBZBJ", "");
  16283. designer.SetDataSource("CostBDRLR", "");
  16284. designer.SetDataSource("CostBZLR", "");
  16285. designer.SetDataSource("CostBDRCBOM", "");
  16286. designer.SetDataSource("CostBRSOM", "");
  16287. designer.SetDataSource("CostBZCBOM", "");
  16288. designer.SetDataSource("CostBDRBJOM", "");
  16289. designer.SetDataSource("CostBZBJOM", "");
  16290. designer.SetDataSource("CostBDRLROM", "");
  16291. designer.SetDataSource("CostBZLROM", "");
  16292. #endregion
  16293. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  16294. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  16295. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  16296. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  16297. designer.SetDataSource("DJName", "地接(CNY)");
  16298. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  16299. designer.SetDataSource("CPName", "地接-船票(CNY)");
  16300. designer.SetDataSource("GWName", "公务(CNY)");
  16301. designer.SetDataSource("YQHName", "邀请函(CNY)");
  16302. designer.SetDataSource("LYJName", "零用金(CNY)");
  16303. designer.SetDataSource("HSName", "核酸检测(CNY)");
  16304. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  16305. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  16306. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  16307. designer.SetDataSource("BXName", "保险(CNY)");
  16308. designer.SetDataSource("VisaName", "签证(CNY)");
  16309. #region B段基本数据
  16310. if (dto.costType == "B")
  16311. {
  16312. left = dto.leftInfo.Find(x => x.Type == "B");
  16313. if (left == null)
  16314. {
  16315. return Ok(jw);
  16316. }
  16317. #region B段left数据
  16318. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  16319. if (leftBindData != null)
  16320. {
  16321. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  16322. designer.SetDataSource("BHSRS", leftBindData.rs);
  16323. designer.SetDataSource("BHSXS", leftBindData.xs);
  16324. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16325. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16326. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16327. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16328. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16329. }
  16330. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  16331. if (leftBindData != null)
  16332. {
  16333. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  16334. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  16335. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  16336. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16337. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16338. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16339. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16340. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16341. }
  16342. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  16343. if (leftBindData != null)
  16344. {
  16345. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  16346. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  16347. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  16348. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16349. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16350. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16351. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16352. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16353. }
  16354. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  16355. if (leftBindData != null)
  16356. {
  16357. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  16358. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  16359. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  16360. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16361. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16362. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16363. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16364. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16365. }
  16366. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  16367. if (leftBindData != null)
  16368. {
  16369. designer.SetDataSource("BHCPCB", leftBindData.cb);
  16370. designer.SetDataSource("BHCPRS", leftBindData.rs);
  16371. designer.SetDataSource("BHCPXS", leftBindData.xs);
  16372. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16373. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16374. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16375. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16376. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16377. }
  16378. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  16379. if (leftBindData != null)
  16380. {
  16381. designer.SetDataSource("BCPCB", leftBindData.cb);
  16382. designer.SetDataSource("BCPRS", leftBindData.rs);
  16383. designer.SetDataSource("BCPXS", leftBindData.xs);
  16384. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16385. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16386. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16387. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16388. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16389. }
  16390. //TBR
  16391. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  16392. if (leftBindData != null)
  16393. {
  16394. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  16395. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  16396. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  16397. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16398. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16399. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16400. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16401. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16402. }
  16403. //SGR
  16404. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  16405. if (leftBindData != null)
  16406. {
  16407. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  16408. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  16409. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  16410. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16411. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16412. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16413. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16414. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16415. }
  16416. //JS/ES
  16417. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  16418. if (leftBindData != null)
  16419. {
  16420. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  16421. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  16422. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  16423. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16424. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16425. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16426. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16427. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16428. }
  16429. //SUITE
  16430. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  16431. if (leftBindData != null)
  16432. {
  16433. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  16434. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  16435. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  16436. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16437. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16438. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16439. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16440. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16441. }
  16442. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  16443. if (leftBindData != null)
  16444. {
  16445. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  16446. designer.SetDataSource("BDJRS", leftBindData.rs);
  16447. designer.SetDataSource("BDJXS", leftBindData.xs);
  16448. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16449. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16450. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16451. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16452. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16453. }
  16454. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  16455. if (leftBindData != null)
  16456. {
  16457. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  16458. designer.SetDataSource("BGWRS", leftBindData.rs);
  16459. designer.SetDataSource("BGWXS", leftBindData.xs);
  16460. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16461. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16462. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16463. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16464. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16465. }
  16466. #region 优化方案
  16467. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  16468. //excelBind.Add("零用金", new {
  16469. //cb="",
  16470. //rs="",
  16471. //xs ="",
  16472. //zcb = "",
  16473. //});
  16474. #endregion
  16475. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  16476. if (leftBindData != null)
  16477. {
  16478. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  16479. designer.SetDataSource("BLYJRS", leftBindData.rs);
  16480. designer.SetDataSource("BLYJXS", leftBindData.xs);
  16481. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16482. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16483. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16484. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16485. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16486. }
  16487. #endregion
  16488. #region B段Right信息
  16489. right = dto.rightInfo.Find(x => x.Type == "B");
  16490. if (right == null)
  16491. {
  16492. return Ok(jw);
  16493. }
  16494. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  16495. if (rightBindData != null)
  16496. {
  16497. //经济舱 + 双人间 TBR
  16498. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  16499. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  16500. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16501. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  16502. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16503. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16504. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16505. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16506. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16507. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16508. }
  16509. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  16510. if (rightBindData != null)
  16511. {
  16512. //经济舱 + 单人间 SGR
  16513. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  16514. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  16515. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16516. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  16517. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16518. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16519. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16520. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16521. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16522. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16523. }
  16524. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  16525. if (rightBindData != null)
  16526. {
  16527. //公务舱 + 单人间 SGR
  16528. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  16529. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  16530. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16531. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  16532. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16533. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16534. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16535. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16536. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16537. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16538. }
  16539. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  16540. if (rightBindData != null)
  16541. {
  16542. //公务舱 + 小套房 JSES
  16543. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  16544. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  16545. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16546. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  16547. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16548. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16549. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16550. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16551. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16552. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16553. }
  16554. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  16555. if (rightBindData != null)
  16556. {
  16557. //公务舱 + 小套房 JSES
  16558. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  16559. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  16560. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16561. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  16562. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16563. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16564. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16565. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16566. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16567. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16568. }
  16569. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  16570. if (rightBindData != null)
  16571. {
  16572. //经济舱 + 大套房
  16573. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  16574. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  16575. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16576. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  16577. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16578. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16579. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16580. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16581. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16582. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16583. }
  16584. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  16585. if (rightBindData != null)
  16586. {
  16587. //头等舱 + 小套房 JSES
  16588. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  16589. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  16590. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16591. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  16592. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16593. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16594. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16595. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16596. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16597. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16598. }
  16599. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  16600. if (rightBindData != null)
  16601. {
  16602. //头等舱 + 大套房
  16603. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  16604. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  16605. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16606. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  16607. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16608. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16609. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16610. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16611. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16612. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16613. }
  16614. #endregion
  16615. #region 标题
  16616. designer.SetDataSource("CostBDRCB", "单人成本");
  16617. designer.SetDataSource("CostBRS", "人数");
  16618. designer.SetDataSource("CostBXS", "系数");
  16619. designer.SetDataSource("CostBZCB", "总成本");
  16620. designer.SetDataSource("CostBDRBJ", "单人报价");
  16621. designer.SetDataSource("CostBZBJ", "总报价");
  16622. designer.SetDataSource("CostBDRLR", "单人利润");
  16623. designer.SetDataSource("CostBZLR", "总利润");
  16624. designer.SetDataSource("CostBDRCBOM", "单人成本");
  16625. designer.SetDataSource("CostBRSOM", "人数");
  16626. designer.SetDataSource("CostBZCBOM", "总成本");
  16627. designer.SetDataSource("CostBDRBJOM", "单人报价");
  16628. designer.SetDataSource("CostBZBJOM", "总报价");
  16629. designer.SetDataSource("CostBDRLROM", "单人利润");
  16630. designer.SetDataSource("CostBZLROM", "总利润");
  16631. #endregion
  16632. }
  16633. #endregion
  16634. designer.SetDataSource("TzZCB2", TzZCB2);
  16635. designer.SetDataSource("TzZBJ2", TzZBJ2);
  16636. designer.SetDataSource("TzZLR2", TzZLR2);
  16637. string[] dataSourceKeys = new string[]
  16638. {
  16639. "VF",
  16640. "TGS",
  16641. "TGOF",
  16642. "TGM",
  16643. "TGA",
  16644. "TGTF",
  16645. "TGEF",
  16646. "CFM",
  16647. "CFOF",
  16648. "B",
  16649. "L",
  16650. "D",
  16651. "TBR",
  16652. "SGR",
  16653. "JSES",
  16654. "Suite",
  16655. "TV",
  16656. "1L",
  16657. "IF",
  16658. "EF",
  16659. "BRF",
  16660. "TE",
  16661. "TGT",
  16662. "DRVT",
  16663. "PC",
  16664. "TLF",
  16665. "ECT"
  16666. };
  16667. foreach (var item in dataSourceKeys)
  16668. {
  16669. Func<TitleModel, bool> expr = x => x.label.Replace(" ", "").Replace("/", "") == item
  16670. || x.label.Replace(" ", "").Replace("/", "").ToUpper() == item.ToUpper();
  16671. var find = dto.titleModel.FirstOrDefault(expr);
  16672. if (find != null)
  16673. {
  16674. designer.SetDataSource(item, find.text);
  16675. }
  16676. else
  16677. {
  16678. designer.SetDataSource(item, 0);
  16679. }
  16680. }
  16681. designer.SetDataSource(dt);
  16682. //根据数据源处理生成报表内容
  16683. designer.Process();
  16684. designer.Workbook.Worksheets[0].Name = "费用明细";
  16685. designer.Workbook.Worksheets[1].Name = "费用总核算";
  16686. Worksheet sheet = designer.Workbook.Worksheets[0];
  16687. #region 隐藏舱位
  16688. var settingAir = new[]
  16689. {
  16690. new { key = "经济舱", index = 7 },
  16691. new { key = "公务舱", index = 19 },
  16692. new { key = "头等舱", index = 11 }
  16693. };
  16694. var airType = _sqlSugar.Queryable<Grp_TourClientList>()
  16695. .LeftJoin<Sys_SetData>((c, s) => s.IsDel == 0 && c.ShippingSpaceTypeId == s.Id)
  16696. .Where((c, s) => c.IsDel == 0 && c.DiId == di.Id)
  16697. .Select((c, s) => s.Name)
  16698. .ToList()
  16699. .GroupBy(x => x)
  16700. .Select(x => x.Key);
  16701. foreach (var item in settingAir)
  16702. {
  16703. if (!airType.Contains(item.key))
  16704. {
  16705. hideRowsList.Add(item.index);
  16706. }
  16707. }
  16708. #endregion
  16709. foreach (var Rowindex in hideRowsList)
  16710. {
  16711. ws.Cells.HideRows(Rowindex, 2);
  16712. }
  16713. ws = designer.Workbook.Worksheets[0];
  16714. foreach (var Column in hideColumnList)
  16715. {
  16716. ws.Cells.HideColumns(Column, 1);
  16717. }
  16718. byte[] bytes = null;
  16719. string strFileName = di.TeamName + "-团组-成本.xls";
  16720. using (MemoryStream stream = new MemoryStream())
  16721. {
  16722. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  16723. bytes = stream.ToArray();
  16724. }
  16725. return Ok(JsonView(true, "", new
  16726. {
  16727. Data = bytes,
  16728. strFileName,
  16729. }));
  16730. }
  16731. /// <summary>
  16732. /// 导出客户报表
  16733. /// </summary>
  16734. /// <returns></returns>
  16735. [HttpPost]
  16736. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  16737. {
  16738. var jw = JsonView(false);
  16739. if (dto.Diid == 0)
  16740. {
  16741. return Ok(JsonView(false, "请传递团组id"));
  16742. }
  16743. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  16744. if (deleInfo.Code != 0)
  16745. {
  16746. return Ok(JsonView(false, "团组信息查询失败!"));
  16747. }
  16748. var di = deleInfo.Data as DelegationInfoWebView;
  16749. if (di == null)
  16750. {
  16751. return Ok(JsonView(false, "团组信息查询失败!"));
  16752. }
  16753. //文件名
  16754. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  16755. //获取模板
  16756. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  16757. //载入模板
  16758. Document doc = new Document(tmppath);
  16759. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  16760. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  16761. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  16762. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  16763. var AParameter = ParameterList.Find(x => x.CostType == "A");
  16764. var BParameter = ParameterList.Find(x => x.CostType == "B");
  16765. if (AParameter == null)
  16766. {
  16767. return Ok(JsonView(false, "系数不存在!"));
  16768. }
  16769. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  16770. , TzAirDesc, TzZCost;
  16771. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  16772. = TzAirDesc = TzZCost = string.Empty;
  16773. TzNumber = AParameter.CostTypenumber.ToString();
  16774. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  16775. CarGuides1 = dto.CarGuides1;
  16776. Meal = dto.Meal;
  16777. SubsidizedMeals = dto.SubsidizedMeals;
  16778. NightRepair = dto.NightRepair;
  16779. AttractionsTickets = dto.AttractionsTickets;
  16780. MiscellaneousFees = dto.MiscellaneousFees;
  16781. ATip = dto.ATip;
  16782. TzHotelDesc = "";
  16783. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  16784. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  16785. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  16786. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  16787. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  16788. TzAirDesc = "";
  16789. TzZCost = dto.TzZCost;
  16790. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  16791. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  16792. var index = 1;
  16793. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  16794. foreach (var item in TzHotelDescArr)
  16795. {
  16796. if (AinfoArr != null)
  16797. {
  16798. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  16799. if (Ainfo != null)
  16800. {
  16801. if (int.Parse(Ainfo.rs) <= 0)
  16802. {
  16803. continue;
  16804. }
  16805. var hotelText = string.Empty;
  16806. switch (item)
  16807. {
  16808. case "SGR":
  16809. hotelText = "单人间";
  16810. break;
  16811. case "JSES":
  16812. hotelText = "小套房";
  16813. break;
  16814. case "SUITE":
  16815. hotelText = "套房";
  16816. break;
  16817. case "TBR":
  16818. hotelText = "双人间";
  16819. break;
  16820. }
  16821. if (item != "TBR")
  16822. {
  16823. 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";
  16824. }
  16825. else
  16826. {
  16827. 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";
  16828. }
  16829. index++;
  16830. }
  16831. }
  16832. }
  16833. index = 1;
  16834. foreach (var item in TzAirDescArr)
  16835. {
  16836. if (AinfoArr != null)
  16837. {
  16838. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  16839. if (Ainfo != null)
  16840. {
  16841. if (int.Parse(Ainfo.rs) <= 0)
  16842. {
  16843. continue;
  16844. }
  16845. 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";
  16846. index++;
  16847. }
  16848. }
  16849. }
  16850. if (dto.costType == "B")
  16851. {
  16852. if (BParameter == null)
  16853. {
  16854. return Ok(JsonView(false, "B段系数不存在!"));
  16855. }
  16856. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  16857. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  16858. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  16859. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  16860. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  16861. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  16862. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  16863. foreach (var item in TzHotelDescArr)
  16864. {
  16865. if (AinfoArr != null)
  16866. {
  16867. TzHotelDesc += "B段信息 \r\n";
  16868. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  16869. if (Ainfo != null)
  16870. {
  16871. if (int.Parse(Ainfo.rs) <= 0)
  16872. {
  16873. continue;
  16874. }
  16875. var hotelText = string.Empty;
  16876. switch (item)
  16877. {
  16878. case "SGR":
  16879. hotelText = "单人间";
  16880. break;
  16881. case "JSES":
  16882. hotelText = "小套房";
  16883. break;
  16884. case "SUITE":
  16885. hotelText = "套房";
  16886. break;
  16887. case "TBR":
  16888. hotelText = "双人间";
  16889. break;
  16890. }
  16891. if (item != "TBR")
  16892. {
  16893. 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";
  16894. }
  16895. else
  16896. {
  16897. 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";
  16898. }
  16899. index++;
  16900. }
  16901. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  16902. }
  16903. }
  16904. index = 1;
  16905. foreach (var item in TzAirDescArr)
  16906. {
  16907. if (AinfoArr != null)
  16908. {
  16909. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  16910. if (Ainfo != null)
  16911. {
  16912. if (int.Parse(Ainfo.rs) <= 0)
  16913. {
  16914. continue;
  16915. }
  16916. 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";
  16917. index++;
  16918. }
  16919. }
  16920. }
  16921. }
  16922. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  16923. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  16924. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  16925. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  16926. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  16927. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  16928. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  16929. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  16930. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  16931. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  16932. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  16933. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  16934. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  16935. DickeyValue.Add("Visa", Visa); // 签证单人报价
  16936. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  16937. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  16938. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  16939. DickeyValue.Add("TzZCost", TzZCost);
  16940. foreach (var key in DickeyValue.Keys)
  16941. {
  16942. if (doc.Range.Bookmarks[key] != null)
  16943. {
  16944. Bookmark mark = doc.Range.Bookmarks[key];
  16945. mark.Text = DickeyValue[key];
  16946. }
  16947. }
  16948. byte[] bytes = null;
  16949. string strFileName = di.TeamName + "-客户报价.doc";
  16950. using (MemoryStream stream = new MemoryStream())
  16951. {
  16952. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  16953. bytes = stream.ToArray();
  16954. }
  16955. return Ok(JsonView(true, "", new
  16956. {
  16957. Data = bytes,
  16958. strFileName,
  16959. }));
  16960. }
  16961. /// <summary>
  16962. /// 团组成本 各模块(酒店,地接,机票)成本提示
  16963. /// </summary>
  16964. /// <param name="dto"></param>
  16965. /// <returns></returns>
  16966. [HttpPost]
  16967. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16968. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  16969. {
  16970. try
  16971. {
  16972. #region 参数验证
  16973. if (dto.DiId < 0)
  16974. {
  16975. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  16976. }
  16977. List<int> cTableIds = new List<int>() {
  16978. 76 ,//酒店预订
  16979. 77 ,//行程
  16980. 79 ,//车/导游地接
  16981. 80 ,//签证
  16982. 81 ,//邀请/公务活
  16983. 82 ,//团组客户保险
  16984. 85 ,//机票预订
  16985. 98 ,//其他款项
  16986. 285 ,//收款退还
  16987. 751 ,//酒店早餐
  16988. 1015 // 超支费用
  16989. };
  16990. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  16991. {
  16992. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  16993. }
  16994. #endregion
  16995. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  16996. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  16997. if (_GroupCostParameters.Count <= 0)
  16998. {
  16999. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  17000. }
  17001. if (_GroupCostParameters[0].IsShare == 0)
  17002. {
  17003. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  17004. }
  17005. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  17006. //处理date为空问题
  17007. if (_GroupCosts.Count > 0)
  17008. {
  17009. for (int i = 0; i < _GroupCosts.Count; i++)
  17010. {
  17011. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  17012. {
  17013. if (i > 0)
  17014. {
  17015. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  17016. }
  17017. }
  17018. }
  17019. }
  17020. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  17021. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  17022. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  17023. string currCode = "";
  17024. #region currCode 验证
  17025. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  17026. if (isInt)
  17027. {
  17028. var currData = currDatas.Find(it => it.Id == intCurrency);
  17029. if (currData != null)
  17030. {
  17031. currCode = currData.Name;
  17032. }
  17033. }
  17034. else
  17035. {
  17036. currCode = _GroupCostParameters[0].Currency.Trim();
  17037. }
  17038. #endregion
  17039. //op,酒店单段模式存储
  17040. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  17041. {
  17042. CurrencyCode = currCode,
  17043. Rate = _GroupCostParameters[0].Rate,
  17044. CostType = _GroupCostParameters[0].CostType,
  17045. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  17046. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  17047. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  17048. };
  17049. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  17050. if (_GroupCostParameters.Count == 2)
  17051. {
  17052. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  17053. }
  17054. foreach (var item in _GroupCostParameters)
  17055. {
  17056. decimal _rate = 1;
  17057. decimal _rate1 = item.Rate;
  17058. decimal _scale = 1;
  17059. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  17060. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  17061. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  17062. //if (userInfo != null)
  17063. //{
  17064. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  17065. // {
  17066. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  17067. // {
  17068. // _scale = 1.00M;
  17069. // }
  17070. // }
  17071. //}
  17072. #endregion
  17073. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  17074. {
  17075. CurrencyCode = currCode,
  17076. Rate = _rate1,
  17077. CostType = item.CostType,
  17078. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  17079. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  17080. CostTypeNumber = item.CostTypenumber
  17081. };
  17082. if (_GroupCostParameters.Count > 1)
  17083. {
  17084. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  17085. }
  17086. else
  17087. {
  17088. modulePromptInfo.CostTypeNumber = item.LYJRS;
  17089. }
  17090. if (dto.CTable == 79)//
  17091. {
  17092. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  17093. modulePromptInfo.TotalCost = item.DJCB;
  17094. }
  17095. List<string> costTypes = new List<string>() { "A", "B" };
  17096. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  17097. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  17098. if (_GroupCostsDuplicates.Count() == 1)
  17099. {
  17100. _GroupCostsTypeData = _GroupCosts;
  17101. }
  17102. else
  17103. {
  17104. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  17105. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  17106. }
  17107. /*
  17108. * 76 酒店预订
  17109. * 77 行程
  17110. * 79 车/导游地接
  17111. * 80 签证
  17112. * 81 邀请/公务活动
  17113. * 82 团组客户保险
  17114. * 85 机票预订
  17115. * 98 其他款项
  17116. * 285 收款退还
  17117. * 751 酒店早餐
  17118. * 1015 超支费用
  17119. */
  17120. switch (dto.CTable)
  17121. {
  17122. case 76: // 酒店预订
  17123. _ModuleSubPromptInfo.AddRange(
  17124. _GroupCostsTypeData.Select(it => new
  17125. {
  17126. it.DAY,
  17127. it.Date,
  17128. it.ACCON,
  17129. it.ITIN,
  17130. it.SGR,
  17131. it.TBR,
  17132. it.JS_ES,
  17133. it.Suite
  17134. })
  17135. );
  17136. break;
  17137. case 79: // 车/导游地接
  17138. _ModuleSubPromptInfo.AddRange(
  17139. _GroupCostsTypeData.Select(it => new
  17140. {
  17141. Date = it.Date, //日期
  17142. CarFee = it.CarCost * _rate * _scale, //车费用
  17143. CarType = it.CarType, //车型
  17144. DriverFee = it.CFS * _rate * _scale, //司机工资
  17145. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  17146. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  17147. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  17148. GuideFee = it.TGS * _rate * _scale, //导游费用
  17149. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  17150. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  17151. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  17152. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  17153. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  17154. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  17155. Breakfast = it.B * _rate * _scale, //早餐费
  17156. Lunch = it.L * _rate * _scale, //午餐费
  17157. Dinner = it.D * _rate * _scale, //晚餐费
  17158. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  17159. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  17160. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  17161. TicketFee = it.EF * _rate * _scale, //门票费
  17162. TicketRemark = it.EFR, //门票费描述
  17163. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  17164. TravelSupplies = it.TE * _rate * _scale, //出行物资
  17165. SpentCash = it.PC * _rate * _scale, //零用金
  17166. LeadersFee = it.TLF * _rate * _scale, //领队费
  17167. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  17168. })
  17169. );
  17170. break;
  17171. case 85: // 机票
  17172. List<dynamic> datas = new List<dynamic>();
  17173. datas.Add(
  17174. new
  17175. {
  17176. AirType = "经济舱",
  17177. AirNum = item.JJCRS,
  17178. AirDRCB = item.JJCCB,
  17179. AirZCB = (item.JJCRS * item.JJCCB)
  17180. }
  17181. );
  17182. datas.Add(
  17183. new
  17184. {
  17185. AirType = "公务舱",
  17186. AirNum = item.GWCRS,
  17187. AirDRCB = item.GWCCB,
  17188. AirZCB = (item.GWCRS * item.GWCCB)
  17189. }
  17190. );
  17191. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  17192. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  17193. modulePromptInfo.Data = new
  17194. {
  17195. airFeeData = datas,
  17196. airInitData = initDatas
  17197. };
  17198. _ModulePromptInfos.Add(modulePromptInfo);
  17199. break;
  17200. default:
  17201. break;
  17202. }
  17203. }
  17204. if (dto.CTable != 85)
  17205. {
  17206. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  17207. _ModulePromptInfos.Add(_ModulePromptInfo);
  17208. }
  17209. _view.ModulePromptInfos = _ModulePromptInfos;
  17210. return Ok(JsonView(true, "操作成功!", _view));
  17211. }
  17212. catch (Exception ex)
  17213. {
  17214. return Ok(JsonView(false, ex.Message));
  17215. }
  17216. }
  17217. /// <summary>
  17218. /// 根据黑屏代码重新生成行程
  17219. /// </summary>
  17220. /// <param name="dto"></param>
  17221. /// <returns></returns>
  17222. [HttpPost]
  17223. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  17224. {
  17225. var jw = JsonView(false, "Error");
  17226. var Create = _sqlSugar.Queryable<Air_TicketBlackCode>()
  17227. .Where(x => x.IsDel == 0 && x.DiId == dto.Diid)
  17228. .Select(x => new
  17229. {
  17230. x.Id,
  17231. x.Title
  17232. })
  17233. .ToList();
  17234. if (Create.Any())
  17235. {
  17236. jw.Msg = "获取成功!";
  17237. jw.Code = 200;
  17238. jw.Data = new
  17239. {
  17240. BlackCodeListSelect = Create,
  17241. blackCodeIsTrue = true
  17242. };
  17243. }
  17244. else
  17245. {
  17246. jw.Code = 400;
  17247. jw.Data = new
  17248. {
  17249. BlackCodeListSelect = Create,
  17250. blackCodeIsTrue = false,
  17251. };
  17252. }
  17253. return Ok(jw);
  17254. }
  17255. /// <summary>
  17256. /// 根据黑屏代码Id重新生成行程
  17257. /// </summary>
  17258. /// <param name="dto"></param>
  17259. /// <returns></returns>
  17260. [HttpPost]
  17261. public IActionResult CraeteGroupCostTravelById(CraeteGroupCostTravelByIdDto dto)
  17262. {
  17263. var jw = JsonView(false, "Error");
  17264. var result = _GroupCostRepository.CreateGroupCostByBlackCode(dto.DiId, dto.BlackCodeId);
  17265. if (result.Code == 0)
  17266. {
  17267. jw.Msg = "获取成功!";
  17268. jw.Code = 200;
  17269. jw.Data = new
  17270. {
  17271. groupCost = result.Data,
  17272. blackCodeIsTrue = true
  17273. };
  17274. }
  17275. else
  17276. {
  17277. jw.Code = 400;
  17278. jw.Data = new
  17279. {
  17280. groupCost = result.Data,
  17281. blackCodeIsTrue = false,
  17282. };
  17283. }
  17284. return Ok(jw);
  17285. }
  17286. /// <summary>
  17287. /// 成本获取OP历史车费用
  17288. /// </summary>
  17289. /// <param name="dto"></param>
  17290. /// <returns></returns>
  17291. [HttpPost]
  17292. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  17293. {
  17294. var jw = JsonView(false);
  17295. try
  17296. {
  17297. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  17298. //获取现有所有车的数据
  17299. if (!dto.Param.IsNullOrWhiteSpace())
  17300. {
  17301. string sql = $@"
  17302. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  17303. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  17304. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  17305. 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
  17306. AND gctggr.ServiceEndTime is not NULL
  17307. ORDER by gctggrc.id DESC
  17308. ";
  17309. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  17310. var numeberResult = await Task.Run(() =>
  17311. {
  17312. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  17313. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  17314. return numberArr;
  17315. });
  17316. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  17317. foreach (var item in numeberResult)
  17318. {
  17319. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  17320. {
  17321. Country = "数据异常!",
  17322. City = string.Empty,
  17323. };
  17324. item.Area = find.Country + " " + find.City;
  17325. }
  17326. dbResult.AddRange(numeberResult);
  17327. if (dto.Param.Contains("、"))
  17328. {
  17329. var sp = dto.Param.Split("、");
  17330. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  17331. .Where(x =>
  17332. {
  17333. return System.Array.Exists(sp, e =>
  17334. {
  17335. bool where = false;
  17336. if (x.Area != null)
  17337. {
  17338. where = x.Area.Contains(e);
  17339. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  17340. {
  17341. return false;
  17342. }
  17343. }
  17344. if (x.PriceName != null && !where)
  17345. {
  17346. where = x.PriceName.Contains(e);
  17347. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  17348. {
  17349. return false;
  17350. }
  17351. }
  17352. return where;
  17353. });
  17354. }).ToList();
  17355. }
  17356. else
  17357. {
  17358. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  17359. .Where(x =>
  17360. {
  17361. bool where = false;
  17362. if (x.Area != null)
  17363. {
  17364. where = x.Area.Contains(dto.Param);
  17365. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  17366. {
  17367. return false;
  17368. }
  17369. }
  17370. if (x.PriceName != null && !where)
  17371. {
  17372. where = x.PriceName.Contains(dto.Param);
  17373. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  17374. {
  17375. return false;
  17376. }
  17377. }
  17378. return where;
  17379. }
  17380. )
  17381. .ToList();
  17382. }
  17383. }
  17384. var view = dbResult.Select(x =>
  17385. {
  17386. decimal dp = 0.00M;
  17387. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  17388. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  17389. if (string.IsNullOrWhiteSpace(x.DatePrice))
  17390. {
  17391. if (startB && endB)
  17392. {
  17393. var timesp = endD.Subtract(startD);
  17394. if ((timesp.Days + 1) != 0)
  17395. {
  17396. dp = x.Price / (timesp.Days + 1);
  17397. }
  17398. }
  17399. }
  17400. else
  17401. {
  17402. dp = x.Price;
  17403. }
  17404. return new
  17405. {
  17406. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  17407. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  17408. x.Area,
  17409. x.id,
  17410. price = x.Price.ToString("F2"),
  17411. x.PriceName,
  17412. x.PriceContent,
  17413. x.TeamName,
  17414. x.DatePrice,
  17415. dayPrice = dp.ToString("F2"),
  17416. };
  17417. }).OrderByDescending(x => x.id).ToList();
  17418. jw = JsonView(true, "获取成功!", view);
  17419. }
  17420. catch (Exception e)
  17421. {
  17422. jw = JsonView(false, e.Message);
  17423. }
  17424. return Ok(jw);
  17425. }
  17426. [HttpPost]
  17427. public async Task<IActionResult> SearchGroupByKeyword(SearchGroupByKeywordDto dto)
  17428. {
  17429. var jw = JsonView(true);
  17430. List<DelegationInfoAndIsTrueView> matches = new List<DelegationInfoAndIsTrueView>();
  17431. #region SQL语句
  17432. //if (string.IsNullOrWhiteSpace(dto.Keyword))
  17433. //{
  17434. // matches = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  17435. // Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  17436. // WHEN COUNT(*) >= 0 THEN 'True'
  17437. // ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  17438. // Where TeamName != '' And IsDel = 0 Order By a.VisitStartDate Desc
  17439. // ")
  17440. // .ToList();
  17441. //}
  17442. //else
  17443. //{
  17444. // string likeKey = string.Empty;
  17445. // foreach (var item in dto.Keyword)
  17446. // {
  17447. // likeKey += "%" + item;
  17448. // }
  17449. // likeKey += "%";
  17450. // matches = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  17451. // Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  17452. // WHEN COUNT(*) >= 0 THEN 'True'
  17453. // ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  17454. // Where TeamName != '' And IsDel = 0 And TeamName LIKE '{likeKey}' Order By a.VisitStartDate Desc
  17455. // ")
  17456. // .ToList();
  17457. //}
  17458. #endregion
  17459. var table = _sqlSugar.Ado.UseStoredProcedure().GetDataTable("SearchGroupByKeyword", new
  17460. {
  17461. @KeyWord = dto.Keyword
  17462. });
  17463. if (table != null && table.Rows.Count > 0)
  17464. {
  17465. foreach (DataRow row in table.Rows)
  17466. {
  17467. matches.Add(new DelegationInfoAndIsTrueView
  17468. {
  17469. Id = row.Field<int>("Id"),
  17470. GroupName = row.Field<string>("GroupName"),
  17471. isTrue = row.Field<string>("isTrue")
  17472. });
  17473. }
  17474. }
  17475. if (matches.Any())
  17476. {
  17477. jw.Data = matches;
  17478. }
  17479. else
  17480. {
  17481. jw.Code = 201;
  17482. jw.Msg = "empty list";
  17483. jw.Data = new List<string>(1);
  17484. }
  17485. return Ok(jw);
  17486. }
  17487. /// <summary>
  17488. /// 报价Word下载
  17489. /// </summary>
  17490. /// <param name="dto"></param>
  17491. /// <returns></returns>
  17492. [HttpPost]
  17493. public async Task<IActionResult> GroupQuotationsFileDown(GroupQuotationsFileDownDto dto)
  17494. {
  17495. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  17496. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  17497. if (di == null)
  17498. {
  17499. return Ok(JsonView(false, "团组不存在!"));
  17500. }
  17501. var mainPrice = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  17502. if (mainPrice == null || mainPrice.IsShare == 0)
  17503. {
  17504. return Ok(JsonView(false, "团组成本不存在!"));
  17505. }
  17506. var costTypeHotelNumbers = await _sqlSugar.Queryable<Grp_CostTypeHotelNumber>()
  17507. .FirstAsync(x => x.Type == "Default" && x.Diid == dto.Diid && x.IsDel == 0);
  17508. if (costTypeHotelNumbers == null)
  17509. {
  17510. return Ok(JsonView(false, "团组成本不存在!"));
  17511. }
  17512. //文件名
  17513. string strFileName = di.TeamName + "-收款账单.doc";
  17514. //获取模板
  17515. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  17516. //载入模板
  17517. Document doc = new Document(tmppath);
  17518. decimal allPrice = 0.00M;
  17519. string itemStr = string.Empty;
  17520. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  17521. airSouer.Add("经济舱TBR", "经济舱及酒店双人间");
  17522. airSouer.Add("经济舱SGR", "经济舱及酒店单人间");
  17523. airSouer.Add("公务舱SGR", "公务舱及酒店单人间");
  17524. airSouer.Add("公务舱JSES", "公务舱及酒店小套房");
  17525. airSouer.Add("公务舱SUITE", "公务舱及酒店套房");
  17526. airSouer.Add("经济舱SUITE", "经济舱及酒店套房");
  17527. airSouer.Add("头等舱JSES", "头等舱及酒店小套房");
  17528. airSouer.Add("头等舱SUITE", "头等舱及酒店套房");
  17529. airSouer.Add("经济舱JSES", "经济舱及酒店小套房");
  17530. var priceDataList = new List<(string rsName, string cbName, string xsName, string prefix)>
  17531. {
  17532. ("VisaRS", "VisaCB", "VisaXS", "qz"),
  17533. ("BXRS", "BXCB", "BXXS", "bx"),
  17534. ("HCPRS", "HCPCB", "HCPXS", "hcp"),
  17535. ("JJCRS", "JJCCB", "JJCXS", "jjc"),
  17536. ("GWCRS", "GWCCB", "GWCXS", "gwc"),
  17537. ("TDCRS", "TDCCB", "TDCXS", "tdc"),
  17538. ("CPRS", "CPCB", "CPXS", "cp"),
  17539. ("HSRS", "HSCB", "HSXS", "hsjc"),
  17540. ("TBRNumber", "TBRCB", "TBRXS", "tbr"),
  17541. ("SGRNumber", "SGRCB", "SGRXS", "sgr"),
  17542. ("JSESNumber", "JSESCB", "JSESXS", "jses"),
  17543. ("SUITENumber", "SUITECB", "SUITEXS", "suite"),
  17544. ("DJRS", "DJCB", "DJXS", "dj"),
  17545. ("GWRS", "GWCB", "GWXS", "gw"),
  17546. ("LYJRS", "LYJCB", "LYJXS", "lyj"),
  17547. };
  17548. var OtherCostPropertyBJ = new string[] { "qz", "hcp", "cp", "bx", "hsjc", "dj", "gw", "lyj" };
  17549. var rightSum = 0.00M;
  17550. foreach (var (rsName, cbName, xsName, prefix) in priceDataList)
  17551. {
  17552. var rsValue = (int)mainPrice.GetType().GetProperty(rsName).GetValue(mainPrice);
  17553. var cbValue = (decimal)mainPrice.GetType().GetProperty(cbName).GetValue(mainPrice);
  17554. var xsValue = (decimal)mainPrice.GetType().GetProperty(xsName).GetValue(mainPrice);
  17555. if (prefix == "tbr")
  17556. {
  17557. rsValue *= 2;
  17558. cbValue /= 2;
  17559. }
  17560. if (OtherCostPropertyBJ.Contains(prefix))
  17561. {
  17562. rightSum += cbValue * xsValue;
  17563. }
  17564. }
  17565. var hotelRooms = new Dictionary<string, int>
  17566. {
  17567. { "SGR", costTypeHotelNumbers.SGR },
  17568. { "TBR", costTypeHotelNumbers.TBR },
  17569. { "JSES", costTypeHotelNumbers.JSES },
  17570. { "SUITE", costTypeHotelNumbers.SUITE }
  17571. };
  17572. var flights = new Dictionary<string, int>
  17573. {
  17574. { "经济舱", mainPrice.JJCRS },
  17575. { "公务舱", mainPrice.GWCRS },
  17576. { "头等舱", mainPrice.TDCRS }
  17577. };
  17578. var flightRoomMatchingRules = new Dictionary<string, string[]>
  17579. {
  17580. { "经济舱", new[] { "TBR", "SGR", "JSES", "SUITE" } },
  17581. { "公务舱", new[] { "SUITE", "JSES", "SGR" } },
  17582. { "头等舱", new[] { "SUITE", "JSES" } }
  17583. };
  17584. var result = new Dictionary<string, int>();
  17585. List<AirHotelPrice> airHotelPriceList = new List<AirHotelPrice>();
  17586. foreach (var flight in flights.Keys)
  17587. {
  17588. // 获取当前舱位的匹配规则
  17589. if (flightRoomMatchingRules.TryGetValue(flight, out string[] roomTypes))
  17590. {
  17591. MatchRooms(ref hotelRooms, ref flights, roomTypes, flight, ref result);
  17592. }
  17593. }
  17594. #region right计算
  17595. if (result.Keys.Contains("经济舱TBR") && result["经济舱TBR"] > 0)
  17596. {
  17597. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  17598. var hotel = (mainPrice.TBRCB * mainPrice.TBRXS) / 2;
  17599. airHotelPriceList.Add(new
  17600. AirHotelPrice
  17601. {
  17602. Name = "经济舱TBR",
  17603. Price = rightSum + air + hotel,
  17604. Count = result["经济舱TBR"] * 2
  17605. });
  17606. allPrice += (rightSum + air + hotel) * result["经济舱TBR"] * 2;
  17607. }
  17608. if (result.Keys.Contains("经济舱SGR") && result["经济舱SGR"] > 0)
  17609. {
  17610. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  17611. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  17612. airHotelPriceList.Add(new
  17613. AirHotelPrice
  17614. {
  17615. Name = "经济舱SGR",
  17616. Price = rightSum + air + hotel,
  17617. Count = result["经济舱SGR"]
  17618. });
  17619. allPrice += (rightSum + air + hotel) * result["经济舱SGR"];
  17620. }
  17621. if (result.Keys.Contains("公务舱SGR") && result["公务舱SGR"] > 0)
  17622. {
  17623. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  17624. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  17625. airHotelPriceList.Add(new
  17626. AirHotelPrice
  17627. {
  17628. Name = "公务舱SGR",
  17629. Price = rightSum + air + hotel,
  17630. Count = result["公务舱SGR"]
  17631. });
  17632. allPrice += (rightSum + air + hotel) * result["公务舱SGR"];
  17633. }
  17634. if (result.Keys.Contains("公务舱JSES") && result["公务舱JSES"] > 0)
  17635. {
  17636. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  17637. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  17638. airHotelPriceList.Add(new
  17639. AirHotelPrice
  17640. {
  17641. Name = "公务舱JSES",
  17642. Price = rightSum + air + hotel,
  17643. Count = result["公务舱JSES"]
  17644. });
  17645. allPrice += (rightSum + air + hotel) * result["公务舱JSES"];
  17646. }
  17647. if (result.Keys.Contains("公务舱SUITE") && result["公务舱SUITE"] > 0)
  17648. {
  17649. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  17650. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  17651. airHotelPriceList.Add(new
  17652. AirHotelPrice
  17653. {
  17654. Name = "公务舱SUITE",
  17655. Price = rightSum + air + hotel,
  17656. Count = result["公务舱SUITE"]
  17657. });
  17658. allPrice += (rightSum + air + hotel) * result["公务舱SUITE"];
  17659. }
  17660. if (result.Keys.Contains("经济舱SUITE") && result["经济舱SUITE"] > 0)
  17661. {
  17662. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  17663. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  17664. airHotelPriceList.Add(new
  17665. AirHotelPrice
  17666. {
  17667. Name = "经济舱SUITE",
  17668. Price = rightSum + air + hotel,
  17669. Count = result["经济舱SUITE"]
  17670. });
  17671. allPrice += (rightSum + air + hotel) * result["经济舱SUITE"];
  17672. }
  17673. if (result.Keys.Contains("头等舱JSES") && result["头等舱JSES"] > 0)
  17674. {
  17675. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  17676. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  17677. airHotelPriceList.Add(new
  17678. AirHotelPrice
  17679. {
  17680. Name = "头等舱JSES",
  17681. Price = rightSum + air + hotel,
  17682. Count = result["头等舱JSES"]
  17683. });
  17684. allPrice += (rightSum + air + hotel) * result["头等舱JSES"];
  17685. }
  17686. if (result.Keys.Contains("头等舱SUITE") && result["头等舱SUITE"] > 0)
  17687. {
  17688. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  17689. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  17690. airHotelPriceList.Add(new
  17691. AirHotelPrice
  17692. {
  17693. Name = "头等舱SUITE",
  17694. Price = rightSum + air + hotel,
  17695. Count = result["头等舱SUITE"]
  17696. });
  17697. allPrice += (rightSum + air + hotel) * result["头等舱SUITE"];
  17698. }
  17699. if (result.Keys.Contains("经济舱JSES") && result["经济舱JSES"] > 0)
  17700. {
  17701. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  17702. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  17703. airHotelPriceList.Add(new
  17704. AirHotelPrice
  17705. {
  17706. Name = "经济舱JSES",
  17707. Price = rightSum + air + hotel,
  17708. Count = result["经济舱JSES"]
  17709. });
  17710. allPrice += (rightSum + air + hotel) * result["经济舱JSES"];
  17711. }
  17712. #endregion
  17713. foreach (var item in airSouer.Keys)
  17714. {
  17715. var find = airHotelPriceList.FirstOrDefault(x => x.Name == item);
  17716. if (find != null && find.Count > 0)
  17717. {
  17718. if (item.Contains("TBR"))
  17719. {
  17720. itemStr += "团费(" + airSouer[item] + ") RMB " + find.Price.ToString("F2") + "/人*" + find.Count + "(" + (find.Count / 2) + "间) ............合计 RMB " + (find.Count * find.Price).ToString("#0.00") + "\n";
  17721. }
  17722. else
  17723. {
  17724. itemStr += "团费(" + airSouer[item] + ") RMB " + find.Price.ToString("F2") + "/人*" + find.Count + "(" + find.Count + "间) ............合计 RMB " + (find.Count * find.Price).ToString("#0.00") + "\n";
  17725. }
  17726. }
  17727. }
  17728. #region 替换Word模板书签内容
  17729. Dictionary<string, string> marks = new Dictionary<string, string>();
  17730. marks.Add("To", di.ClientUnit);//付款方
  17731. marks.Add("ToTel", di.TellPhone);//付款方电话
  17732. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  17733. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  17734. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  17735. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  17736. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  17737. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  17738. marks.Add("PayItemContent", itemStr);//详细信息
  17739. marks.Add("Total", allPrice.ToString("F2"));//合计
  17740. #endregion
  17741. foreach (var item in marks.Keys)
  17742. {
  17743. if (doc.Range.Bookmarks[item] != null)
  17744. {
  17745. Bookmark mark = doc.Range.Bookmarks[item];
  17746. mark.Text = marks[item];
  17747. }
  17748. }
  17749. string savePaht = $"{AppSettingsHelper.Get("WordBasePath")}GroupCostQuotations/{di.TeamName}_报批费用.doc";
  17750. doc.Save(savePaht);
  17751. var jw = new JsonView();
  17752. jw.Msg = "生成成功!";
  17753. jw.Code = 200;
  17754. jw.Data = new { Url = AppSettingsHelper.Get("WordBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("WordBasePath"), AppSettingsHelper.Get("WordFtpPath")) };
  17755. return Ok(jw);
  17756. }
  17757. /// <summary>
  17758. /// 详细报价费用Excel下载
  17759. /// </summary>
  17760. /// <param name="dto"></param>
  17761. /// <returns></returns>
  17762. [HttpPost]
  17763. public async Task<IActionResult> GroupQuotationsDetailFileDown(GroupQuotationsFileDownDto dto)
  17764. {
  17765. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  17766. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  17767. if (di == null)
  17768. {
  17769. return Ok(JsonView(false, "团组不存在!"));
  17770. }
  17771. var mainPrice = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  17772. if (mainPrice == null || mainPrice.IsShare == 0)
  17773. {
  17774. return Ok(JsonView(false, "团组成本不存在!"));
  17775. }
  17776. var costTypeHotelNumbers = await _sqlSugar.Queryable<Grp_CostTypeHotelNumber>()
  17777. .FirstAsync(x => x.Type == "Default" && x.Diid == dto.Diid && x.IsDel == 0);
  17778. if (costTypeHotelNumbers == null)
  17779. {
  17780. return Ok(JsonView(false, "团组成本不存在!"));
  17781. }
  17782. WorkbookDesigner designer = new WorkbookDesigner();
  17783. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/报价详细表.xls"));
  17784. List<int> hideRowsList = new List<int>();
  17785. int conterStartIndex = 3;
  17786. int rowIndex = conterStartIndex;
  17787. designer.SetDataSource("GroupName", di.TeamName);
  17788. var priceDataList = new List<(string rsName, string cbName, string xsName, string prefix)>
  17789. {
  17790. ("VisaRS", "VisaCB", "VisaXS", "qz"),
  17791. ("BXRS", "BXCB", "BXXS", "bx"),
  17792. ("HCPRS", "HCPCB", "HCPXS", "hcp"),
  17793. ("JJCRS", "JJCCB", "JJCXS", "jjc"),
  17794. ("GWCRS", "GWCCB", "GWCXS", "gwc") ,
  17795. ("TDCRS", "TDCCB", "TDCXS", "tdc") ,
  17796. ("CPRS", "CPCB", "CPXS", "cp") ,
  17797. ("HSRS", "HSCB", "HSXS", "hsjc") ,
  17798. ("TBRNumber", "TBRCB", "TBRXS", "tbr") ,
  17799. ("SGRNumber", "SGRCB", "SGRXS", "sgr") ,
  17800. ("JSESNumber", "JSESCB", "JSESXS", "jses") ,
  17801. ("SUITENumber", "SUITECB", "SUITEXS", "suite") ,
  17802. ("DJRS", "DJCB", "DJXS", "dj") ,
  17803. ("GWRS", "GWCB", "GWXS", "gw") ,
  17804. ("LYJRS", "LYJCB", "LYJXS", "lyj") ,
  17805. };
  17806. var OtherCostPropertyBJ = new string[] { "qz", "hcp", "cp", "bx", "hsjc", "dj", "gw", "lyj" };
  17807. var rightSum = 0.00M;
  17808. foreach (var (rsName, cbName, xsName, prefix) in priceDataList)
  17809. {
  17810. var rsValue = (int)mainPrice.GetType().GetProperty(rsName).GetValue(mainPrice);
  17811. var cbValue = (decimal)mainPrice.GetType().GetProperty(cbName).GetValue(mainPrice);
  17812. var xsValue = (decimal)mainPrice.GetType().GetProperty(xsName).GetValue(mainPrice);
  17813. if (prefix == "tbr")
  17814. {
  17815. rsValue *= 2;
  17816. cbValue /= 2;
  17817. }
  17818. if (OtherCostPropertyBJ.Contains(prefix))
  17819. {
  17820. rightSum += cbValue * xsValue;
  17821. }
  17822. if (rsValue == 0)
  17823. {
  17824. hideRowsList.Add(rowIndex);
  17825. }
  17826. else
  17827. {
  17828. designer.SetDataSource($"{prefix}rs", rsValue);
  17829. designer.SetDataSource($"{prefix}bj", cbValue * xsValue);
  17830. designer.SetDataSource($"{prefix}zbj", cbValue * xsValue * rsValue);
  17831. }
  17832. rowIndex += 2;
  17833. }
  17834. var hotelRooms = new Dictionary<string, int>
  17835. {
  17836. { "SGR", costTypeHotelNumbers.SGR },
  17837. { "TBR", costTypeHotelNumbers.TBR },
  17838. { "JSES", costTypeHotelNumbers.JSES },
  17839. { "SUITE", costTypeHotelNumbers.SUITE }
  17840. };
  17841. var flights = new Dictionary<string, int>
  17842. {
  17843. { "经济舱", mainPrice.JJCRS },
  17844. { "公务舱", mainPrice.GWCRS },
  17845. { "头等舱", mainPrice.TDCRS }
  17846. };
  17847. var flightRoomMatchingRules = new Dictionary<string, string[]>
  17848. {
  17849. { "经济舱", new[] { "TBR", "SGR", "JSES", "SUITE" } },
  17850. { "公务舱", new[] { "SUITE", "JSES", "SGR" } },
  17851. { "头等舱", new[] { "SUITE", "JSES" } }
  17852. };
  17853. var result = new Dictionary<string, int>();
  17854. foreach (var flight in flights.Keys)
  17855. {
  17856. // 获取当前舱位的匹配规则
  17857. if (flightRoomMatchingRules.TryGetValue(flight, out string[] roomTypes))
  17858. {
  17859. MatchRooms(ref hotelRooms, ref flights, roomTypes, flight, ref result);
  17860. }
  17861. }
  17862. var allPrice = 0.00M;
  17863. #region right计算
  17864. int airRowIndex = 35;
  17865. if (result.Keys.Contains("经济舱TBR") && result["经济舱TBR"] > 0)
  17866. {
  17867. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  17868. var hotel = (mainPrice.TBRCB * mainPrice.TBRXS) / 2;
  17869. designer.SetDataSource("jjctbrrs", result["经济舱TBR"] * 2);
  17870. designer.SetDataSource("jjctbrbj", rightSum + air + hotel);
  17871. designer.SetDataSource("jjctbrzbj", (rightSum + air + hotel) * result["经济舱TBR"] * 2);
  17872. allPrice += (rightSum + air + hotel) * result["经济舱TBR"] * 2;
  17873. }
  17874. else
  17875. {
  17876. hideRowsList.Add(airRowIndex);
  17877. }
  17878. airRowIndex += 2;
  17879. if (result.Keys.Contains("经济舱SGR") && result["经济舱SGR"] > 0)
  17880. {
  17881. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  17882. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  17883. designer.SetDataSource("jjcsgrrs", result["经济舱SGR"]);
  17884. designer.SetDataSource("jjcsgrbj", rightSum + air + hotel);
  17885. designer.SetDataSource("jjcsgrzbj", (rightSum + air + hotel) * result["经济舱SGR"]);
  17886. allPrice += (rightSum + air + hotel) * result["经济舱SGR"];
  17887. }
  17888. else
  17889. {
  17890. hideRowsList.Add(airRowIndex);
  17891. }
  17892. airRowIndex += 2;
  17893. if (result.Keys.Contains("公务舱SGR") && result["公务舱SGR"] > 0)
  17894. {
  17895. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  17896. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  17897. designer.SetDataSource("gwcsgrrs", result["公务舱SGR"]);
  17898. designer.SetDataSource("gwcsgrbj", rightSum + air + hotel);
  17899. designer.SetDataSource("gwcsgrzbj", (rightSum + air + hotel) * result["公务舱SGR"]);
  17900. allPrice += (rightSum + air + hotel) * result["公务舱SGR"];
  17901. }
  17902. else
  17903. {
  17904. hideRowsList.Add(airRowIndex);
  17905. }
  17906. airRowIndex += 2;
  17907. if (result.Keys.Contains("公务舱JSES") && result["公务舱JSES"] > 0)
  17908. {
  17909. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  17910. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  17911. designer.SetDataSource("gwcjsesrs", result["公务舱JSES"]);
  17912. designer.SetDataSource("gwcjsesbj", rightSum + air + hotel);
  17913. designer.SetDataSource("gwcjseszbj", (rightSum + air + hotel) * result["公务舱JSES"]);
  17914. allPrice += (rightSum + air + hotel) * result["公务舱JSES"];
  17915. }
  17916. else
  17917. {
  17918. hideRowsList.Add(airRowIndex);
  17919. }
  17920. airRowIndex += 2;
  17921. if (result.Keys.Contains("公务舱SUITE") && result["公务舱SUITE"] > 0)
  17922. {
  17923. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  17924. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  17925. designer.SetDataSource("gwcsuiters", result["公务舱SUITE"]);
  17926. designer.SetDataSource("gwcsuitebj", rightSum + air + hotel);
  17927. designer.SetDataSource("gwcsuitezbj", (rightSum + air + hotel) * result["公务舱SUITE"]);
  17928. allPrice += (rightSum + air + hotel) * result["公务舱SUITE"];
  17929. }
  17930. else
  17931. {
  17932. hideRowsList.Add(airRowIndex);
  17933. }
  17934. airRowIndex += 2;
  17935. if (result.Keys.Contains("经济舱SUITE") && result["经济舱SUITE"] > 0)
  17936. {
  17937. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  17938. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  17939. designer.SetDataSource("jjcsuiters", result["经济舱SUITE"]);
  17940. designer.SetDataSource("jjcsuitebj", rightSum + air + hotel);
  17941. designer.SetDataSource("jjcsuitezbj", (rightSum + air + hotel) * result["经济舱SUITE"]);
  17942. allPrice += (rightSum + air + hotel) * result["经济舱SUITE"];
  17943. }
  17944. else
  17945. {
  17946. hideRowsList.Add(airRowIndex);
  17947. }
  17948. airRowIndex += 2;
  17949. if (result.Keys.Contains("头等舱JSES") && result["头等舱JSES"] > 0)
  17950. {
  17951. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  17952. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  17953. designer.SetDataSource("tdcjsesrs", result["头等舱JSES"]);
  17954. designer.SetDataSource("tdcjsesbj", rightSum + air + hotel);
  17955. designer.SetDataSource("tdcjseszbj", (rightSum + air + hotel) * result["头等舱JSES"]);
  17956. allPrice += (rightSum + air + hotel) * result["头等舱JSES"];
  17957. }
  17958. else
  17959. {
  17960. hideRowsList.Add(airRowIndex);
  17961. }
  17962. airRowIndex += 2;
  17963. if (result.Keys.Contains("头等舱SUITE") && result["头等舱SUITE"] > 0)
  17964. {
  17965. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  17966. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  17967. designer.SetDataSource("tdcsuiters", result["头等舱SUITE"]);
  17968. designer.SetDataSource("tdcsuitebj", rightSum + air + hotel);
  17969. designer.SetDataSource("tdcsuitezbj", (rightSum + air + hotel) * result["头等舱SUITE"]);
  17970. allPrice += (rightSum + air + hotel) * result["头等舱SUITE"];
  17971. }
  17972. else
  17973. {
  17974. hideRowsList.Add(airRowIndex);
  17975. }
  17976. airRowIndex += 2;
  17977. if (result.Keys.Contains("经济舱JSES") && result["经济舱JSES"] > 0)
  17978. {
  17979. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  17980. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  17981. designer.SetDataSource("jjcjsesrs", result["经济舱JSES"]);
  17982. designer.SetDataSource("jjcjsesbj", rightSum + air + hotel);
  17983. designer.SetDataSource("jjcjseszbj", (rightSum + air + hotel) * result["经济舱JSES"]);
  17984. allPrice += (rightSum + air + hotel) * result["经济舱JSES"];
  17985. }
  17986. else
  17987. {
  17988. hideRowsList.Add(airRowIndex);
  17989. }
  17990. #endregion
  17991. designer.SetDataSource("AllPrice", "总金额:" + allPrice.ToString("#0.00"));
  17992. string savePaht = AppSettingsHelper.Get("ExcelBasePath") + "GroupCostQuotations/" + di.TeamName + "_详细报批费用.xls";
  17993. var ws = designer.Workbook.Worksheets[0];
  17994. foreach (var Rowindex in hideRowsList)
  17995. {
  17996. ws.Cells.HideRows(Rowindex, 2);
  17997. }
  17998. designer.Process();
  17999. designer.Workbook.Save(savePaht);
  18000. return Ok(JsonView(true, "生成成功!", new
  18001. {
  18002. Url = AppSettingsHelper.Get("ExcelBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("ExcelBasePath"), AppSettingsHelper.Get("ExcelFtpPath"))
  18003. }));
  18004. }
  18005. private void MatchRooms(ref Dictionary<string, int> hotelRooms, ref Dictionary<string, int> flights, string[] roomTypes, string flightType, ref Dictionary<string, int> result)
  18006. {
  18007. foreach (var roomType in roomTypes)
  18008. {
  18009. while (hotelRooms[roomType] > 0 && flights[flightType] > 0)
  18010. {
  18011. hotelRooms[roomType]--;
  18012. flights[flightType]--;
  18013. if (roomType == "TBR")
  18014. {
  18015. flights[flightType]--; // 双人间在减少1
  18016. }
  18017. string key = flightType + roomType;
  18018. if (result.Keys.Contains(key))
  18019. {
  18020. result[key]++;
  18021. }
  18022. else
  18023. {
  18024. result.Add(key, 1);
  18025. }
  18026. }
  18027. }
  18028. }
  18029. private class AirHotelPrice
  18030. {
  18031. public string Name { get; set; }
  18032. public decimal Price { get; set; }
  18033. public int Count { get; set; }
  18034. }
  18035. /// <summary>
  18036. /// 团组系数设置
  18037. /// </summary>
  18038. /// <param name="dto"></param>
  18039. /// <returns></returns>
  18040. [HttpPost]
  18041. public async Task<IActionResult> QueryGroupCostCoefficient(QueryGroupCostCoefficientDto dto)
  18042. {
  18043. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  18044. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  18045. if (di == null)
  18046. {
  18047. return Ok(JsonView(false, "团组不存在!"));
  18048. }
  18049. //var firstExpression = Expressionable.Create<Grp_GroupCostParameter>()
  18050. // .And(x => x.CostType == "A" && x.DiId == di.Id && x.IsDel == 0);
  18051. //var groupCostMainPrice = await _sqlSugar.Queryable<Grp_GroupCostParameter>().
  18052. // FirstAsync(firstExpression.ToExpression());
  18053. #region JSON
  18054. string hcpJson = @"
  18055. [
  18056. {
  18057. ""min"": 1,
  18058. ""max"": 500,
  18059. ""value"": 1.50
  18060. },
  18061. {
  18062. ""min"": 501,
  18063. ""max"": 1000,
  18064. ""value"": 1.40
  18065. },
  18066. {
  18067. ""min"": 1001,
  18068. ""max"": 2000,
  18069. ""value"": 1.35
  18070. }
  18071. ]";
  18072. #endregion
  18073. var hcpPriceRange = Newtonsoft.Json.JsonConvert.DeserializeObject<List<PriceRange>>(hcpJson);
  18074. List<(Predicate<decimal>, decimal)> hcpSwitchDictionary = hcpPriceRange
  18075. .Select(pr => (new Predicate<decimal>(x => x >= pr.Min && x <= pr.Max), pr.Value))
  18076. .ToList();
  18077. List<(Predicate<decimal>, List<(Predicate<decimal>, decimal)>)> jjcSwitchDictionary =
  18078. new List<(Predicate<decimal>, List<(Predicate<decimal>, decimal)>)>();
  18079. //jjcSwitchDictionary.Add((new Predicate<decimal>(x => x >= 1 && x <= 3),
  18080. // new List<(Predicate<decimal>, decimal)>()
  18081. // {
  18082. // (new Predicate<decimal>(y => y >= 1000 && y <= 3000), 2.6M),
  18083. // (new Predicate<decimal>(y => y > 3000), 2.5M)
  18084. // }
  18085. // ));
  18086. #region 签证系数
  18087. var visaXS = 0.00M;
  18088. switch (dto.VisaCB)
  18089. {
  18090. case decimal n when (n > 1 && n < 500):
  18091. switch (dto.VisaRS)
  18092. {
  18093. case 2 or 3:
  18094. visaXS = 1.35M;
  18095. break;
  18096. case 4 or 5:
  18097. visaXS = 1.30M;
  18098. break;
  18099. case 6 or 7:
  18100. visaXS = 1.25M;
  18101. break;
  18102. case 8 or 9 or 10:
  18103. visaXS = 1.20M;
  18104. break;
  18105. case > 10:
  18106. visaXS = 1.15M;
  18107. break;
  18108. default:
  18109. visaXS = 0.00M;
  18110. break;
  18111. }
  18112. break;
  18113. case decimal n when (n >= 500 && n < 1000):
  18114. switch (dto.VisaRS)
  18115. {
  18116. case 2 or 3 or 4:
  18117. visaXS = 1.30M;
  18118. break;
  18119. case 5 or 6 or 7 or 8:
  18120. visaXS = 1.25M;
  18121. break;
  18122. case 9 or 10:
  18123. visaXS = 1.20M;
  18124. break;
  18125. case > 10:
  18126. visaXS = 1.15M;
  18127. break;
  18128. default:
  18129. visaXS = 0.00M;
  18130. break;
  18131. }
  18132. break;
  18133. default:
  18134. switch (dto.VisaRS)
  18135. {
  18136. case 2 or 3 or 4:
  18137. visaXS = 1.30M;
  18138. break;
  18139. case 5 or 6 or 7 or 8:
  18140. visaXS = 1.25M;
  18141. break;
  18142. case 9 or 10:
  18143. visaXS = 1.20M;
  18144. break;
  18145. case > 10:
  18146. visaXS = 1.15M;
  18147. break;
  18148. default:
  18149. visaXS = 0.00M;
  18150. break;
  18151. }
  18152. break;
  18153. }
  18154. #endregion
  18155. #region 火车系数
  18156. var hcpXS = 0.00M;
  18157. foreach (var (condition, result) in hcpSwitchDictionary)
  18158. {
  18159. if (condition(dto.HCPCB))
  18160. {
  18161. hcpXS = result;
  18162. break;
  18163. }
  18164. }
  18165. #endregion
  18166. #region 机票系数
  18167. #region 经济舱系数
  18168. var jjcXS = 0.00M;
  18169. switch (dto.JJCCB)
  18170. {
  18171. case decimal x when (x >= 1000 && x <= 3000):
  18172. jjcXS = 2.6M;
  18173. break;
  18174. case decimal x when (x >= 3001 && x <= 8000):
  18175. jjcXS = 2.3M;
  18176. break;
  18177. case decimal x when (x >= 8001 && x <= 15000):
  18178. jjcXS = 2.1M;
  18179. break;
  18180. case decimal x when (x >= 15001 && x <= 30000):
  18181. jjcXS = 1.95M;
  18182. break;
  18183. case > 30000:
  18184. jjcXS = 1.8M;
  18185. break;
  18186. default:
  18187. break;
  18188. }
  18189. #endregion
  18190. #region 公务舱系数
  18191. var gwcXS = 0.00M;
  18192. switch (dto.GWCCB)
  18193. {
  18194. case decimal x when (x >= 1000 && x <= 3000):
  18195. gwcXS = 2.5M;
  18196. break;
  18197. case decimal x when (x >= 3001 && x <= 8000):
  18198. gwcXS = 2.2M;
  18199. break;
  18200. case decimal x when (x >= 8001 && x <= 15000):
  18201. gwcXS = 2.0M;
  18202. break;
  18203. case decimal x when (x >= 15001 && x <= 30000):
  18204. gwcXS = 1.85M;
  18205. break;
  18206. case > 30000:
  18207. gwcXS = 1.7M;
  18208. break;
  18209. default:
  18210. break;
  18211. }
  18212. #endregion
  18213. #region 头等舱系数
  18214. var tdcXS = 0.00M;
  18215. switch (dto.TDCCB)
  18216. {
  18217. case > 70000:
  18218. tdcXS = 1.5M;
  18219. break;
  18220. default:
  18221. tdcXS = 1.9M;
  18222. break;
  18223. }
  18224. #endregion
  18225. #endregion
  18226. #region 酒店系数
  18227. Dictionary<decimal, List<string>> dic = new Dictionary<decimal, List<string>>()
  18228. {
  18229. {1.6M, new List<string>(){"新西兰","澳大利亚" }},
  18230. {1.5M, new List<string>(){"越南社会主义共和国",
  18231. "老挝",
  18232. "柬埔寨",
  18233. "泰国",
  18234. "缅甸",
  18235. "马来西亚",
  18236. //"新加坡",
  18237. "文莱达鲁萨兰",
  18238. "印度尼西亚",
  18239. "东帝汶"}},
  18240. {1.2M, new List<string>(){ "日本","新加坡","法国","意大利","荷兰"}},
  18241. };
  18242. #region SGR
  18243. var sgrXS = 1.25M;
  18244. #endregion
  18245. #region TBR
  18246. var tbrXS = 1.25M;
  18247. #endregion
  18248. #region JSES
  18249. var jsesXS = 1.25M;
  18250. #endregion
  18251. #region SUITE
  18252. var suiteXS = 1.25M;
  18253. #endregion
  18254. var countryArr = di.VisitCountry.Split("|");
  18255. foreach (var item in dic)
  18256. {
  18257. var extsisCount = item.Value.Where(x => countryArr.Contains(x))
  18258. .Count();
  18259. if (extsisCount > 0)
  18260. {
  18261. jsesXS = item.Key;
  18262. sgrXS = item.Key;
  18263. tbrXS = item.Key;
  18264. suiteXS = item.Key;
  18265. }
  18266. }
  18267. #endregion
  18268. #region 地接系数
  18269. var djXS = 0.00M;
  18270. switch (dto.DJRS)
  18271. {
  18272. case 2 or 3:
  18273. djXS = 2.65M;
  18274. break;
  18275. case 4:
  18276. djXS = 2.6M;
  18277. break;
  18278. case 5 or 6:
  18279. djXS = 2.5M;
  18280. break;
  18281. case 7 or 8:
  18282. djXS = 2.4M;
  18283. break;
  18284. case 9 or 10:
  18285. djXS = 2.3M;
  18286. break;
  18287. case 11:
  18288. djXS = 2.2M;
  18289. break;
  18290. case 12:
  18291. djXS = 2.1M;
  18292. break;
  18293. case 13 or 14:
  18294. djXS = 2M;
  18295. break;
  18296. case 15:
  18297. djXS = 1.9M;
  18298. break;
  18299. case 16 or 17 or 18:
  18300. djXS = 1.8M;
  18301. break;
  18302. case 19 or 20:
  18303. djXS = 1.7M;
  18304. break;
  18305. }
  18306. #endregion
  18307. #region 零用金系数
  18308. var lyjXS = 0.00M;
  18309. switch (dto.LYJRS)
  18310. {
  18311. case 2:
  18312. lyjXS = 1.25M;
  18313. break;
  18314. case 3 or 4 or 5:
  18315. lyjXS = 1.2M;
  18316. break;
  18317. case int number when (number > 5 && number < 10):
  18318. lyjXS = 1.15M;
  18319. break;
  18320. case > 10:
  18321. lyjXS = 1.1M;
  18322. break;
  18323. default:
  18324. break;
  18325. }
  18326. #endregion
  18327. return Ok(JsonView(true, "查询成功", new ArrayList()
  18328. {
  18329. new { label = "火车票系数", value = hcpXS, key = "hcpXS" },
  18330. new { label = "经济舱系数", value = jjcXS, key = "jjcXS" },
  18331. new { label = "公务舱系数", value = gwcXS, key = "gwcXS" },
  18332. new { label = "头等舱系数", value = tdcXS, key = "tdcXS" },
  18333. new { label = "SGR系数", value = sgrXS, key = "sgrXS" },
  18334. new { label = "TBR系数", value = tbrXS, key = "tbrXS" },
  18335. new { label = "JSES系数", value = jsesXS, key = "jsesXS" },
  18336. new { label = "SUITE系数", value = suiteXS, key = "suiteXS" },
  18337. new { label = "地接系数", value = djXS, key = "djXS" },
  18338. new { label = "零用金系数", value = lyjXS, key = "lyjXS" },
  18339. new { label = "公务系数", value = 2M, key = "gwXS" }
  18340. }));
  18341. }
  18342. #endregion
  18343. #region 酒店预订 New 2023-12-28 17:45
  18344. /// <summary>
  18345. /// 酒店预订
  18346. /// 酒店费用列表 根据团组Id查询
  18347. /// </summary>
  18348. /// <param name="_dto"></param>
  18349. /// <returns></returns>
  18350. [HttpPost]
  18351. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18352. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  18353. {
  18354. #region 参数验证
  18355. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  18356. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  18357. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  18358. #region 团组操作权限验证 76 酒店预定模块
  18359. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18360. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  18361. #endregion
  18362. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18363. #region 页面操作权限验证
  18364. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18365. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  18366. #endregion
  18367. #endregion
  18368. return Ok(await _hotelPriceRep.ItemsByDiId(_dto.PortType, _dto.DiId));
  18369. }
  18370. /// <summary>
  18371. /// 酒店预订
  18372. /// 基础数据
  18373. /// </summary>
  18374. /// <param name="_dto"></param>
  18375. /// <returns></returns>
  18376. [HttpPost]
  18377. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18378. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  18379. {
  18380. #region 参数验证
  18381. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  18382. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  18383. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  18384. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18385. #region 页面操作权限验证
  18386. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18387. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  18388. #endregion
  18389. #region 团组操作权限验证 76 酒店预定模块
  18390. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18391. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  18392. #endregion
  18393. #endregion
  18394. return Ok(await _hotelPriceRep.BasicsDataInit(_dto.PortType, _dto.DiId));
  18395. }
  18396. /// <summary>
  18397. /// 酒店预订
  18398. /// 创建 入住卷号码
  18399. /// </summary>
  18400. /// <param name="_dto"></param>
  18401. /// <returns></returns>
  18402. [HttpPost]
  18403. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18404. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  18405. {
  18406. #region 参数验证
  18407. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  18408. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  18409. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  18410. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18411. #region 页面操作权限验证
  18412. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18413. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  18414. #endregion
  18415. #region 团组操作权限验证 76 酒店预定模块
  18416. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18417. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  18418. #endregion
  18419. #endregion
  18420. Result data = await _hotelPriceRep.CreateCheckVolumeNo(_dto.DiId);
  18421. if (data.Code != 0)
  18422. {
  18423. return Ok(JsonView(false, data.Msg));
  18424. }
  18425. return Ok(JsonView(true, data.Msg, data.Data));
  18426. }
  18427. /// <summary>
  18428. /// 酒店预订
  18429. /// 详情
  18430. /// </summary>
  18431. /// <param name="_dto"></param>
  18432. /// <returns></returns>
  18433. [HttpPost]
  18434. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18435. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  18436. {
  18437. #region 参数验证
  18438. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  18439. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  18440. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  18441. #region 团组操作权限验证 76 酒店预定模块
  18442. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18443. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  18444. #endregion
  18445. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18446. #region 页面操作权限验证
  18447. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18448. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  18449. #endregion
  18450. #endregion
  18451. return Ok(await _hotelPriceRep.Details(_dto.PortType, _dto.Id));
  18452. }
  18453. /// <summary>
  18454. /// 酒店预订
  18455. /// Add Or Edit
  18456. /// </summary>
  18457. /// <param name="_dto"></param>
  18458. /// <returns></returns>
  18459. [HttpPost]
  18460. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18461. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  18462. {
  18463. #region 参数验证
  18464. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  18465. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  18466. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  18467. #region 团组操作权限验证 76 酒店预定模块
  18468. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18469. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  18470. #endregion
  18471. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18472. #region 页面操作权限验证
  18473. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18474. if (_dto.Id == 0) // Add
  18475. {
  18476. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  18477. }
  18478. else if (_dto.Id > 1) // Edit
  18479. {
  18480. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  18481. }
  18482. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  18483. #endregion
  18484. #endregion
  18485. JsonView _view = await _hotelPriceRep.AddOrEdit(_dto);
  18486. if (_view.Code != 200)
  18487. {
  18488. return Ok(_view);
  18489. }
  18490. #region 成本无酒店价格数据进入超支
  18491. _sqlSugar.BeginTran();
  18492. var start_Bool = DateTime.TryParse(_dto.CheckInDate, out DateTime start_Time);
  18493. var end_Bool = DateTime.TryParse(_dto.CheckOutDate, out DateTime end_Time);
  18494. var groupCost = _sqlSugar.Queryable<Grp_GroupCost>().Where(x => x.Diid == _dto.DiId && x.IsDel == 0).ToList();
  18495. for (int i = 0; i < groupCost.Count; i++)
  18496. {
  18497. if (groupCost[i].Date.IsNullOrWhiteSpace() && i != 0)
  18498. {
  18499. groupCost[i].Date = groupCost[i - 1].Date;
  18500. }
  18501. }
  18502. var groupCost_Grp = groupCost.GroupBy(x => x.Date).ToList();
  18503. List<Fin_GroupExtraCostDto_OP> extraCostList = new
  18504. List<Fin_GroupExtraCostDto_OP>();
  18505. if (start_Bool && end_Bool)
  18506. {
  18507. while (start_Time < end_Time)
  18508. {
  18509. foreach (var item in groupCost_Grp)
  18510. {
  18511. if (DateTime.TryParse(item.Key, out DateTime cost_Time))
  18512. {
  18513. if (DateTime.Compare(start_Time, cost_Time) == 0 && item.Sum(x => x.SGR + x.Suite + x.TBR + x.JS_ES) == 0)
  18514. {
  18515. extraCostList.Add(new
  18516. Fin_GroupExtraCostDto_OP
  18517. {
  18518. Area = _dto.AreaId,
  18519. coefficient = 1.5M,
  18520. createUser = _dto.UserId,
  18521. currency = _dto.CardPriceCurrency,
  18522. diId = _dto.DiId,
  18523. ManagerConfirm = 0,
  18524. SupervisorConfirm = 0,
  18525. SYsupervisorConfirm = 0,
  18526. editType = 1,
  18527. PortType = 1,
  18528. price = _dto.CardPrice,
  18529. PriceCount = 1,
  18530. priceType = 1027,
  18531. priceDetailType = 1044,
  18532. PriceDt = start_Time.ToString("yyyy-MM-dd"),
  18533. priceName = $"酒店超支费用-酒店导入-({start_Time.ToString("yyyy/MM/dd")})",
  18534. });
  18535. }
  18536. }
  18537. }
  18538. start_Time = start_Time.AddDays(1);
  18539. }
  18540. }
  18541. if (extraCostList.Any())
  18542. {
  18543. await _carTouristGuideGroundRep.GroupExtraCost_OperatorList(extraCostList);
  18544. }
  18545. _sqlSugar.CommitTran();
  18546. #endregion
  18547. #region 应用推送
  18548. try
  18549. {
  18550. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  18551. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  18552. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  18553. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  18554. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  18555. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  18556. var diId = _dto.DiId;
  18557. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  18558. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  18559. #region 操作记录
  18560. var opInfo = new Crm_TableOperationRecord()
  18561. {
  18562. TableName = "Grp_HotelReservations",
  18563. PortType = _dto.PortType,
  18564. DataId = hotelId,
  18565. CreateUserId = _dto.UserId
  18566. };
  18567. //var opStatus = OperationEnum.NoOperation;
  18568. if (_dto.Id < 1) //添加操作
  18569. {
  18570. opInfo.OperationItem = OperationEnum.Add;
  18571. }
  18572. else if (_dto.Id > 0)
  18573. {
  18574. opInfo.OperationItem = OperationEnum.Edit;
  18575. }
  18576. string opRemark = string.Empty;
  18577. if (ccpInfo != null)
  18578. {
  18579. // USD 1211.86、 CNY 8761.75、汇率:7.2300
  18580. var currency = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.Id == ccpInfo.PaymentCurrency).First()?.Name;
  18581. var cnyPrice = ccpInfo.PayMoney * ccpInfo.DayRate;
  18582. opRemark = $"{currency} {ccpInfo.PayMoney.ToString("#0.00")}、CNY {cnyPrice.ToString("#0.00")}、汇率:{ccpInfo.DayRate.ToString("#0.0000")}";
  18583. }
  18584. opInfo.Remark = opRemark;
  18585. await _tableorRep.AddAsync(opInfo);
  18586. #endregion
  18587. _logger.LogInformation($"【iOS推送通知Exception】Begin");
  18588. //2024-10-21 新增LZ UID
  18589. var userIds = new List<int>() { 21 };
  18590. string title = $"费用审核";
  18591. string content = "";
  18592. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  18593. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  18594. try
  18595. {
  18596. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "76" };
  18597. await APNsTools.iOS_PushNotifications1("051", title, "", content, true, "ExpenseAuditWebView", h5);
  18598. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】Start");
  18599. //var iosRes = await APNsTools.iOS_PushNotifications("051", title, "", content);
  18600. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】End Response:[{JsonConvert.SerializeObject(iosRes)}]");
  18601. }
  18602. catch (Exception ex)
  18603. {
  18604. Logs($"【iOS推送通知-PostHotelReservationsAddOrEdit-Exception】[{ex.Message}]");
  18605. }
  18606. }
  18607. catch (Exception ex)
  18608. {
  18609. Logs($"【iOS推送通知Exception】【{ex.Message}】");
  18610. }
  18611. try
  18612. {
  18613. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  18614. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  18615. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  18616. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  18617. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  18618. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  18619. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  18620. //自动审核
  18621. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  18622. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  18623. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  18624. //2024-10-21 新增LZ UID
  18625. var userIds = new List<int>() { 21 };
  18626. string title = $"系统通知";
  18627. var diId = _dto.DiId;
  18628. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  18629. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  18630. string content = "";
  18631. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  18632. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  18633. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  18634. }
  18635. catch (Exception ex)
  18636. {
  18637. }
  18638. #endregion
  18639. return Ok(_view);
  18640. }
  18641. /// <summary>
  18642. /// 酒店自动审核测试
  18643. /// Add Or Edit
  18644. /// </summary>
  18645. /// <param name="diid"></param>
  18646. /// <param name="dataId"></param>
  18647. /// <returns></returns>
  18648. [HttpPost]
  18649. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18650. public async Task<IActionResult> PostHotelAutoAuditTest(int diid, int dataId)
  18651. {
  18652. #region 应用推送
  18653. try
  18654. {
  18655. //自动审核
  18656. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  18657. }
  18658. catch (Exception ex)
  18659. {
  18660. return Ok(JsonView(false, ex.Message));
  18661. }
  18662. #endregion
  18663. return Ok(JsonView(false, "操作成功"));
  18664. }
  18665. /// <summary>
  18666. /// 酒店预订
  18667. /// Del
  18668. /// </summary>
  18669. /// <param name="_dto"></param>
  18670. /// <returns></returns>
  18671. [HttpPost]
  18672. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18673. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  18674. {
  18675. #region 参数验证
  18676. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  18677. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  18678. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  18679. #region 团组操作权限验证 76 酒店预定模块
  18680. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18681. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  18682. #endregion
  18683. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18684. #region 页面操作权限验证
  18685. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18686. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  18687. #endregion
  18688. #endregion
  18689. var data = await _hotelPriceRep.Del(_dto.Id, _dto.UserId);
  18690. #region 操作记录
  18691. await _tableorRep.AddAsync(new Crm_TableOperationRecord()
  18692. {
  18693. TableName = "Grp_HotelReservations",
  18694. PortType = _dto.PortType,
  18695. OperationItem = OperationEnum.Del,
  18696. DataId = _dto.Id,
  18697. CreateUserId = _dto.UserId
  18698. });
  18699. #endregion
  18700. return Ok(data);
  18701. }
  18702. /// <summary>
  18703. /// 酒店预订
  18704. /// 生成VOUCHER
  18705. /// 2024.05.06 之前版本
  18706. /// </summary>
  18707. /// <param name="_dto"></param>
  18708. /// <returns></returns>
  18709. [HttpPost]
  18710. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18711. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  18712. {
  18713. try
  18714. {
  18715. #region 参数验证
  18716. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  18717. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  18718. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  18719. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  18720. #region 团组操作权限验证 76 酒店预定模块
  18721. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18722. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  18723. #endregion
  18724. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18725. #region 页面操作权限验证
  18726. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18727. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  18728. #endregion
  18729. #endregion
  18730. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  18731. //判断数据是否完整
  18732. if (hr != null)
  18733. {
  18734. if (!string.IsNullOrEmpty(hr.DetermineNo))
  18735. {
  18736. string strFileName = "HotelStatement/";
  18737. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  18738. if (dele != null)
  18739. strFileName += dele.TourCode;
  18740. //载入模板
  18741. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  18742. Document doc = new Document(sss);
  18743. DocumentBuilder builder = new DocumentBuilder(doc);
  18744. #region 替换Word模板书签内容
  18745. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  18746. //入住卷预定号码
  18747. if (doc.Range.Bookmarks["VNO"] != null)
  18748. {
  18749. Bookmark mark = doc.Range.Bookmarks["VNO"];
  18750. mark.Text = hr.CheckNumber;
  18751. }
  18752. //酒店时间
  18753. if (doc.Range.Bookmarks["Date"] != null)
  18754. {
  18755. Bookmark mark = doc.Range.Bookmarks["Date"];
  18756. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  18757. }
  18758. //团号
  18759. if (doc.Range.Bookmarks["TNo"] != null)
  18760. {
  18761. Bookmark mark = doc.Range.Bookmarks["TNo"];
  18762. mark.Text = dele.TourCode;
  18763. }
  18764. //预定号码
  18765. if (doc.Range.Bookmarks["BookingId"] != null)
  18766. {
  18767. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  18768. mark.Text = hr.ReservationsNo;
  18769. }
  18770. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  18771. {
  18772. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  18773. mark.Text = hr.DetermineNo;
  18774. }
  18775. //酒店城市
  18776. if (doc.Range.Bookmarks["City"] != null)
  18777. {
  18778. Bookmark mark = doc.Range.Bookmarks["City"];
  18779. mark.Text = hr.City;
  18780. }
  18781. //酒店名称
  18782. if (doc.Range.Bookmarks["HName"] != null)
  18783. {
  18784. Bookmark mark = doc.Range.Bookmarks["HName"];
  18785. mark.Text = hr.HotelName;
  18786. }
  18787. //酒店地址
  18788. if (doc.Range.Bookmarks["Address"] != null)
  18789. {
  18790. Bookmark mark = doc.Range.Bookmarks["Address"];
  18791. mark.Text = hr.HotelAddress;
  18792. }
  18793. //酒店电话
  18794. if (doc.Range.Bookmarks["Tel"] != null)
  18795. {
  18796. Bookmark mark = doc.Range.Bookmarks["Tel"];
  18797. mark.Text = hr.HotelTel;
  18798. }
  18799. //酒店传真
  18800. if (doc.Range.Bookmarks["Fax"] != null)
  18801. {
  18802. Bookmark mark = doc.Range.Bookmarks["Fax"];
  18803. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  18804. {
  18805. mark.Text = hr.HotelFax;
  18806. }
  18807. }
  18808. //入住时间
  18809. if (doc.Range.Bookmarks["CIn"] != null)
  18810. {
  18811. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  18812. Bookmark mark = doc.Range.Bookmarks["CIn"];
  18813. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  18814. }
  18815. //退房时间
  18816. if (doc.Range.Bookmarks["COut"] != null)
  18817. {
  18818. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  18819. Bookmark mark = doc.Range.Bookmarks["COut"];
  18820. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  18821. }
  18822. //客户名称
  18823. if (doc.Range.Bookmarks["GName"] != null)
  18824. {
  18825. string guestName = "";
  18826. string[] clients = Array.Empty<string>();
  18827. if (hr.GuestName.Contains(","))
  18828. {
  18829. clients = hr.GuestName.Split(",");
  18830. }
  18831. else
  18832. {
  18833. clients = new string[] { hr.GuestName };
  18834. }
  18835. List<int> clientIds_int = new List<int>();
  18836. if (clients.Length > 0)
  18837. {
  18838. foreach (var item in clients)
  18839. {
  18840. if (item.IsNumeric())
  18841. {
  18842. clientIds_int.Add(int.Parse(item));
  18843. }
  18844. }
  18845. }
  18846. if (clientIds_int.Count > 0)
  18847. {
  18848. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  18849. foreach (var client in _clientDatas)
  18850. {
  18851. //男
  18852. if (client.Sex == 0) guestName += $"Mr.";
  18853. //女
  18854. else if (client.Sex == 1) guestName += $"Ms.";
  18855. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  18856. {
  18857. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  18858. }
  18859. //guestName += $"{client.Pinyin},";
  18860. }
  18861. if (guestName.Length > 0)
  18862. {
  18863. guestName = guestName.Substring(0, guestName.Length - 1);
  18864. }
  18865. }
  18866. else
  18867. {
  18868. guestName = hr.GuestName;
  18869. }
  18870. Bookmark mark = doc.Range.Bookmarks["GName"];
  18871. mark.Text = guestName;
  18872. }
  18873. //房间介绍
  18874. if (doc.Range.Bookmarks["ROOM"] != null)
  18875. {
  18876. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  18877. mark.Text = hr.RoomExplanation;
  18878. }
  18879. //报价描述
  18880. if (doc.Range.Bookmarks["NOTE"] != null)
  18881. {
  18882. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  18883. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  18884. if (ss != null)
  18885. mark.Text = ss.Name;
  18886. }
  18887. //入住时间
  18888. if (doc.Range.Bookmarks["CheckIn"] != null)
  18889. {
  18890. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  18891. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  18892. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  18893. }
  18894. //退房时间
  18895. if (doc.Range.Bookmarks["CheckOut"] != null)
  18896. {
  18897. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  18898. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  18899. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  18900. }
  18901. //日期
  18902. if (doc.Range.Bookmarks["DT"] != null)
  18903. {
  18904. Bookmark mark = doc.Range.Bookmarks["DT"];
  18905. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  18906. }
  18907. //名称
  18908. if (doc.Range.Bookmarks["VName"] != null)
  18909. {
  18910. Bookmark mark = doc.Range.Bookmarks["VName"];
  18911. mark.Text = hr.HotelName;
  18912. }
  18913. //号码
  18914. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  18915. {
  18916. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  18917. mark.Text = hr.CheckNumber;
  18918. }
  18919. #endregion
  18920. strFileName += "VOUCHER.doc";
  18921. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  18922. doc.Save(fileDir);
  18923. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  18924. return Ok(JsonView(true, "操作成功!", Url));
  18925. }
  18926. else
  18927. {
  18928. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  18929. }
  18930. }
  18931. else
  18932. {
  18933. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  18934. }
  18935. }
  18936. catch (Exception ex)
  18937. {
  18938. return Ok(JsonView(false, ex.Message));
  18939. }
  18940. }
  18941. /// <summary>
  18942. /// 酒店预订
  18943. /// 生成VOUCHER
  18944. /// 2024.05.06 之后版本
  18945. /// </summary>
  18946. /// <param name="_dto"></param>
  18947. /// <returns></returns>
  18948. [HttpPost]
  18949. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18950. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  18951. {
  18952. #region 参数验证
  18953. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  18954. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  18955. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  18956. #region 团组操作权限验证 76 酒店预定模块
  18957. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18958. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  18959. #endregion
  18960. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18961. #region 页面操作权限验证
  18962. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18963. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  18964. #endregion
  18965. #endregion
  18966. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  18967. //判断数据是否完整
  18968. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  18969. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  18970. string strFileName = "HotelStatement/";
  18971. string guestNames = ""; //格式Mr.xxx Ms.xxx
  18972. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  18973. #region 数据处理
  18974. List<int> guestIds = new List<int>();
  18975. //int index = 0;
  18976. foreach (var item in hrDtas)
  18977. {
  18978. if (item.GuestName.Contains(","))
  18979. {
  18980. string[] guestIdArr = item.GuestName.Split(',');
  18981. foreach (var guestIdStr in guestIdArr)
  18982. {
  18983. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  18984. if (guestBool)
  18985. {
  18986. guestIds.Add(guestId);
  18987. }
  18988. }
  18989. }
  18990. else guestNames += item.GuestName;
  18991. var voucherInfo = new HotelVoucherInfoView()
  18992. {
  18993. HotelName = item.HotelName,
  18994. CheckInDate = item.CheckInDate,
  18995. CheckOutDate = item.CheckOutDate,
  18996. ConfirmationNumber = item.DetermineNo.Trim(),
  18997. RoomType = item.RoomExplanation
  18998. };
  18999. vouchers.Add(voucherInfo);
  19000. }
  19001. if (guestIds.Count > 0)
  19002. {
  19003. guestIds = guestIds.Distinct().ToList();
  19004. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  19005. if (guestDatas.Count > 0)
  19006. {
  19007. guestNames = "";
  19008. foreach (var guest in guestDatas)
  19009. {
  19010. string guestName = "";
  19011. if (guest.Sex == 0) guestName += @"MR.";
  19012. else if (guest.Sex == 1) guestName += @"MS.";
  19013. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  19014. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  19015. guestNames += @$"{guestName.Trim()}、";
  19016. }
  19017. if (guestNames.Length > 0)
  19018. {
  19019. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  19020. }
  19021. }
  19022. }
  19023. #endregion
  19024. //载入模板
  19025. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  19026. Document doc = new Document(sss);
  19027. DocumentBuilder builder = new DocumentBuilder(doc);
  19028. if (doc.Range.Bookmarks["GuestName"] != null)
  19029. {
  19030. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  19031. mark.Text = guestNames;
  19032. }
  19033. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  19034. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  19035. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  19036. for (int i = 1; i <= vouchers.Count; i++)
  19037. {
  19038. HotelVoucherInfoView hviv = vouchers[i - 1];
  19039. builder.MoveToCell(0, i, 0, 0);
  19040. builder.Write(hviv.HotelName);
  19041. builder.MoveToCell(0, i, 1, 0);
  19042. builder.Write(hviv.CheckInDate);
  19043. builder.MoveToCell(0, i, 2, 0);
  19044. builder.Write(hviv.CheckOutDate);
  19045. builder.MoveToCell(0, i, 3, 0);
  19046. builder.Write(hviv.RoomType);
  19047. builder.MoveToCell(0, i, 4, 0);
  19048. builder.Write(hviv.ConfirmationNumber);
  19049. }
  19050. //删除多余行
  19051. int currRowIndex = vouchers.Count + 1;
  19052. int delRows = 21 - currRowIndex;
  19053. if (delRows > 0)
  19054. {
  19055. for (int i = 0; i < delRows; i++)
  19056. {
  19057. table.Rows.RemoveAt(currRowIndex);
  19058. //cultivateRowIndex++;
  19059. }
  19060. }
  19061. strFileName += "VOUCHER.docx";
  19062. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  19063. doc.Save(fileDir);
  19064. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  19065. return Ok(JsonView(true, "操作成功!", Url));
  19066. }
  19067. /// <summary>
  19068. /// 酒店预订
  19069. /// 生成VOUCHER 批量生成
  19070. /// New
  19071. /// </summary>
  19072. /// <param name="_dto"></param>
  19073. /// <returns></returns>
  19074. [HttpPost]
  19075. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19076. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  19077. {
  19078. #region 参数验证
  19079. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  19080. if (_dto.PageId < 1) _dto.PageId = 28;
  19081. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  19082. #region 团组操作权限验证 76 酒店预定模块
  19083. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  19084. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  19085. #endregion
  19086. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19087. #region 页面操作权限验证
  19088. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19089. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  19090. #endregion
  19091. #endregion
  19092. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  19093. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  19094. .OrderBy(x => x.CheckInDate)
  19095. .ToListAsync();
  19096. //判断数据是否完整
  19097. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  19098. string strFileName = "HotelStatement/";
  19099. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  19100. if (dele != null)
  19101. strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
  19102. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>()
  19103. .Select(x => new Crm_DeleClient { Id = x.Id, FirstName = x.FirstName, LastName = x.LastName, Pinyin = x.Pinyin })
  19104. .Where(it => it.IsDel == 0)
  19105. .ToListAsync();
  19106. foreach (var item in guestDatas) EncryptionProcessor.DecryptProperties(item);
  19107. for (int i = 0; i < hrDtas.Count; i++)
  19108. {
  19109. string guestNames = string.Empty;
  19110. List<int> guestIds = new List<int>();
  19111. var item = hrDtas[i];
  19112. //处理客户姓名
  19113. if (item.GuestName.Contains(","))
  19114. {
  19115. string[] guestIdArr = item.GuestName.Split(',');
  19116. foreach (var guestIdStr in guestIdArr)
  19117. if (int.TryParse(guestIdStr, out int guestId))
  19118. guestIds.Add(guestId);
  19119. }
  19120. else
  19121. {
  19122. bool guestIdBool = int.TryParse(item.GuestName, out int guestId);
  19123. if (guestIdBool)
  19124. {
  19125. guestIds.Add(guestId);
  19126. }
  19127. //NaN
  19128. if (item.GuestName.Contains("NaN"))
  19129. {
  19130. guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
  19131. }
  19132. }
  19133. if (guestIds.Count > 0)
  19134. {
  19135. guestIds = guestIds.Distinct().ToList();
  19136. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  19137. if (guestDatas1.Count > 0)
  19138. {
  19139. guestNames = "";
  19140. foreach (var guest in guestDatas1)
  19141. {
  19142. string guestName = "";
  19143. if (guest.Sex == 0) guestName += @"MR.";
  19144. else if (guest.Sex == 1) guestName += @"MS.";
  19145. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  19146. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  19147. guestNames += @$"{guestName.Trim()}、";
  19148. }
  19149. if (guestNames.Length > 0)
  19150. {
  19151. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  19152. }
  19153. }
  19154. }
  19155. //if (!string.IsNullOrEmpty(guestNames))
  19156. //{
  19157. hrDtas[i].GuestName = guestNames;
  19158. //}
  19159. }
  19160. strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  19161. Document doc = new Document();
  19162. DocumentBuilder builder = new DocumentBuilder(doc);
  19163. try
  19164. {
  19165. builder.MoveToDocumentStart();
  19166. foreach (var item in hrDtas)
  19167. {
  19168. //标题
  19169. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  19170. builder.ParagraphFormat.LineSpacing = 1;
  19171. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19172. builder.ParagraphFormat.Style.Font.Size = 9;
  19173. builder.ParagraphFormat.Style.Font.Bold = true;
  19174. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  19175. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  19176. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  19177. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  19178. builder.ParagraphFormat.LineSpacing = 1;
  19179. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19180. builder.ParagraphFormat.Style.Font.Size = 9;
  19181. builder.ParagraphFormat.Style.Font.Bold = true;
  19182. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  19183. builder.StartTable();
  19184. // 设置边框颜色
  19185. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  19186. //设置边框样式
  19187. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
  19188. //表格
  19189. #region 第一行
  19190. builder.InsertCell();
  19191. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19192. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19193. //builder.CellFormat.AllowAutoFit = false;
  19194. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19195. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19196. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19197. builder.CellFormat.WrapText = true; //自动换行
  19198. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  19199. builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
  19200. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19201. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19202. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19203. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19204. builder.Write("TOUR NO:");
  19205. builder.InsertCell();
  19206. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19207. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19208. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19209. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19210. builder.ParagraphFormat.Style.Font.Bold = false;
  19211. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19212. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  19213. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19214. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19215. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19216. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19217. builder.Write($"{dele?.TourCode ?? "-"}");
  19218. builder.InsertCell();
  19219. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19220. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19221. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19222. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19223. builder.ParagraphFormat.Style.Font.Bold = false;
  19224. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19225. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  19226. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19227. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19228. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19229. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19230. builder.Write($"CITY:");
  19231. builder.InsertCell();
  19232. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19233. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19234. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19235. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19236. builder.ParagraphFormat.Style.Font.Bold = false;
  19237. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19238. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  19239. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19240. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19241. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19242. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19243. builder.Write($"{item.City}");
  19244. builder.EndRow();
  19245. #endregion
  19246. #region 第二行
  19247. builder.InsertCell();
  19248. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19249. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19250. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19251. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19252. builder.ParagraphFormat.Style.Font.Bold = false;
  19253. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19254. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  19255. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19256. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19257. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19258. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19259. builder.Write("CONFIRMATION NO:");
  19260. builder.InsertCell();
  19261. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19262. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19263. builder.ParagraphFormat.Style.Font.Size = 8;
  19264. builder.ParagraphFormat.Style.Font.Bold = false;
  19265. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19266. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19267. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  19268. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19269. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19270. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19271. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19272. builder.CellFormat.HorizontalMerge = CellMerge.First;
  19273. builder.Write($"{item.DetermineNo}");
  19274. builder.InsertCell();
  19275. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19276. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  19277. builder.InsertCell();
  19278. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19279. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  19280. builder.EndRow();
  19281. #endregion
  19282. #region 第三行
  19283. builder.InsertCell();
  19284. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19285. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19286. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19287. builder.ParagraphFormat.Style.Font.Bold = false;
  19288. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19289. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19290. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  19291. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19292. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19293. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19294. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19295. builder.Write($"HOTEL NAME:");
  19296. builder.InsertCell();
  19297. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19298. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19299. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19300. builder.ParagraphFormat.Style.Font.Bold = false;
  19301. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19302. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19303. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  19304. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19305. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19306. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19307. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19308. builder.CellFormat.HorizontalMerge = CellMerge.First;
  19309. builder.Write($"{item.HotelName}");
  19310. builder.InsertCell();
  19311. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19312. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  19313. builder.InsertCell();
  19314. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19315. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  19316. builder.EndRow();
  19317. #endregion
  19318. #region 第四行
  19319. builder.InsertCell();
  19320. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19321. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19322. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19323. builder.ParagraphFormat.Style.Font.Bold = false;
  19324. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19325. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19326. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  19327. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19328. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19329. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19330. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19331. builder.Write($"HOTEL ADDRESS:");
  19332. builder.InsertCell();
  19333. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19334. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19335. builder.ParagraphFormat.Style.Font.Size = 8;
  19336. builder.ParagraphFormat.Style.Font.Bold = false;
  19337. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19338. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19339. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  19340. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19341. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19342. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19343. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19344. builder.CellFormat.HorizontalMerge = CellMerge.First;
  19345. builder.Write($"{item.HotelAddress}");
  19346. builder.InsertCell();
  19347. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19348. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  19349. builder.InsertCell();
  19350. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19351. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  19352. builder.EndRow();
  19353. #endregion
  19354. #region 第五行
  19355. builder.InsertCell();
  19356. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19357. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19358. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19359. builder.ParagraphFormat.Style.Font.Bold = false;
  19360. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19361. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19362. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  19363. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19364. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19365. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19366. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19367. builder.Write("TEL:");
  19368. builder.InsertCell();
  19369. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19370. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19371. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19372. builder.ParagraphFormat.Style.Font.Bold = false;
  19373. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19374. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19375. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  19376. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19377. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19378. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19379. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19380. builder.Write($"{item.HotelTel}");
  19381. builder.InsertCell();
  19382. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19383. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19384. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19385. builder.ParagraphFormat.Style.Font.Bold = false;
  19386. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19387. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19388. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  19389. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19390. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19391. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19392. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19393. builder.Write($"FAX:");
  19394. builder.InsertCell();
  19395. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19396. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19397. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19398. builder.ParagraphFormat.Style.Font.Bold = false;
  19399. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19400. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19401. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  19402. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19403. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19404. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19405. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19406. builder.Write($"{item.HotelFax}");
  19407. builder.EndRow();
  19408. #endregion
  19409. #region 第六行
  19410. builder.InsertCell();
  19411. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19412. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19413. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19414. builder.ParagraphFormat.Style.Font.Bold = false;
  19415. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19416. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19417. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  19418. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19419. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19420. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19421. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19422. builder.Write("CHECK IN:");
  19423. builder.InsertCell();
  19424. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19425. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19426. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19427. builder.ParagraphFormat.Style.Font.Bold = false;
  19428. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19429. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19430. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  19431. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19432. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19433. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19434. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19435. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  19436. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  19437. builder.Write($"{checkInStr}");
  19438. builder.InsertCell();
  19439. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19440. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19441. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19442. builder.ParagraphFormat.Style.Font.Bold = false;
  19443. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19444. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19445. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  19446. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19447. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19448. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19449. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19450. builder.Write($"CHECK OUT:");
  19451. builder.InsertCell();
  19452. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19453. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19454. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19455. builder.ParagraphFormat.Style.Font.Bold = false;
  19456. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19457. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19458. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  19459. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19460. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19461. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19462. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19463. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  19464. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  19465. builder.Write($"{checkOutStr}");
  19466. builder.EndRow();
  19467. #endregion
  19468. #region 第七行
  19469. builder.InsertCell();
  19470. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19471. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19472. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19473. builder.ParagraphFormat.Style.Font.Bold = false;
  19474. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19475. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19476. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  19477. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19478. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19479. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19480. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19481. builder.Write($"GUEST NAME:");
  19482. builder.InsertCell();
  19483. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19484. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19485. builder.ParagraphFormat.Style.Font.Size = 8;
  19486. builder.ParagraphFormat.Style.Font.Bold = false;
  19487. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19488. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19489. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  19490. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19491. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19492. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19493. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19494. builder.CellFormat.HorizontalMerge = CellMerge.First;
  19495. builder.Write($"{item.GuestName.Trim()}");
  19496. builder.InsertCell();
  19497. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19498. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  19499. builder.InsertCell();
  19500. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19501. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  19502. builder.EndRow();
  19503. #endregion
  19504. #region 第八行
  19505. builder.InsertCell();
  19506. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19507. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19508. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19509. builder.ParagraphFormat.Style.Font.Bold = false;
  19510. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19511. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19512. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  19513. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19514. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19515. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19516. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19517. builder.Write($"ROOM TYPE:");
  19518. builder.InsertCell();
  19519. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19520. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19521. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19522. builder.ParagraphFormat.Style.Font.Bold = false;
  19523. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19524. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19525. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  19526. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19527. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19528. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19529. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19530. builder.CellFormat.HorizontalMerge = CellMerge.First;
  19531. builder.Write($"{item.RoomExplanation}");
  19532. builder.InsertCell();
  19533. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19534. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  19535. builder.InsertCell();
  19536. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19537. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  19538. builder.EndRow();
  19539. #endregion
  19540. #region 第九行
  19541. builder.InsertCell();
  19542. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19543. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19544. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19545. builder.ParagraphFormat.Style.Font.Bold = false;
  19546. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19547. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19548. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  19549. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19550. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19551. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19552. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19553. builder.Write($"NOTE:");
  19554. builder.InsertCell();
  19555. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19556. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19557. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19558. builder.ParagraphFormat.Style.Font.Bold = false;
  19559. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19560. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19561. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  19562. builder.CellFormat.HorizontalMerge = CellMerge.First;
  19563. 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.");
  19564. builder.InsertCell();
  19565. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19566. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  19567. builder.InsertCell();
  19568. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19569. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  19570. builder.EndRow();
  19571. #endregion
  19572. builder.EndTable();
  19573. //换行
  19574. builder.Writeln("");
  19575. builder.Writeln("");
  19576. }
  19577. #region 获取文档中的所有表格 设置文字自适应
  19578. // 获取文档中的所有表格。
  19579. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  19580. {
  19581. // 遍历表格中的所有行。
  19582. foreach (Aspose.Words.Tables.Row row in table.Rows)
  19583. {
  19584. foreach (Cell cell in row.Cells)
  19585. {
  19586. Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
  19587. cellFormat.Width = 0;
  19588. }
  19589. }
  19590. }
  19591. #endregion
  19592. #region 设置页眉
  19593. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  19594. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  19595. if (System.IO.File.Exists(voucherHeaderPath))
  19596. {
  19597. byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
  19598. //Image image = Image.FromStream(imageBytes, ImageType.Png);
  19599. //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
  19600. Aspose.Words.Drawing.Shape shape = builder.InsertImage(imageBytes);
  19601. // 调整图片位置
  19602. shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
  19603. shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
  19604. shape.Top = 50; // 将图片距离页眉上边缘的距离
  19605. shape.Left = 0; // 将图片距离页面左边缘的距离
  19606. shape.Width = 81; // 设置图片宽度
  19607. shape.Height = 36; // 设置图片高度
  19608. }
  19609. //靠右
  19610. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  19611. //// 设置页脚上下边距
  19612. //builder.PageSetup.HeaderDistance = 42;
  19613. // 添加页眉线
  19614. Aspose.Words.Border borderHeader = null;
  19615. try
  19616. {
  19617. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  19618. }
  19619. catch (Exception e)
  19620. {
  19621. // TODO Auto-generated catch block
  19622. //e.printStackTrace();
  19623. }
  19624. borderHeader.Shadow = true;
  19625. borderHeader.DistanceFromText = 2;
  19626. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  19627. #endregion
  19628. }
  19629. catch (Exception ex)
  19630. {
  19631. }
  19632. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  19633. doc.Save(fileDir);
  19634. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  19635. return Ok(JsonView(true, "操作成功!", Url));
  19636. }
  19637. /// <summary>
  19638. /// 酒店预订
  19639. /// 生成 预定成本 Excel
  19640. /// </summary>
  19641. /// <param name="_dto"></param>
  19642. /// <returns></returns>
  19643. [HttpPost]
  19644. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19645. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  19646. {
  19647. #region 参数验证
  19648. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  19649. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  19650. if (!vadalitorRes.IsValid)
  19651. {
  19652. var errors = new StringBuilder();
  19653. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  19654. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  19655. }
  19656. #region 团组操作权限验证 76 酒店预定模块
  19657. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  19658. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  19659. #endregion
  19660. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19661. #region 页面操作权限验证
  19662. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19663. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  19664. #endregion
  19665. #endregion
  19666. decimal _rate = 1.00M;
  19667. string _currency = string.Empty;
  19668. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  19669. var hrDtas = _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  19670. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  19671. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  19672. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  19673. var _GroupCostParameter = _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).First();
  19674. //if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  19675. if (_GroupCostParameter == null)
  19676. {
  19677. //return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  19678. bool isIntType = int.TryParse(_currency, out int currId);
  19679. if (isIntType)
  19680. {
  19681. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  19682. }
  19683. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  19684. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  19685. if (currInfo == null)
  19686. {
  19687. //return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  19688. }
  19689. else _rate = currInfo.Rate;
  19690. if (!string.IsNullOrEmpty(_currency) && !_currency.ToUpper().Equals("CNY"))
  19691. {
  19692. _rate = _GroupCostParameter.Rate;
  19693. }
  19694. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  19695. //string strFileName = "HotelStatement/";
  19696. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  19697. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  19698. var rateDatas = new List<dynamic>();
  19699. #region 数据处理
  19700. foreach (var item in hrDtas)
  19701. {
  19702. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  19703. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  19704. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  19705. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  19706. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  19707. if (ccpInfo == null || roomInfo == null || breakfastInfo == null || governmentRentInfo == null || cityTaxInfo == null)
  19708. {
  19709. continue;
  19710. }
  19711. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  19712. if (string.IsNullOrEmpty(_currency)) _currency = $"CNY";
  19713. string singleRoomFeeStr = string.Empty,
  19714. doubleRoomFeeStr = string.Empty,
  19715. suiteRoomFeeStr = string.Empty,
  19716. otherRoomFeeStr = string.Empty,
  19717. payMoneyStr = string.Empty,
  19718. cardPriceStr = string.Empty;
  19719. if (roomCurr.Equals("CNY"))
  19720. {
  19721. rateDatas.Add(new { code = "CNY", rate = 1.0000 });
  19722. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  19723. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  19724. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  19725. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  19726. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? ""}";
  19727. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {currDatas.Find(it => it.Id == item.CardPriceCurrency)?.Name ?? ""}";
  19728. }
  19729. else
  19730. {
  19731. //singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  19732. //doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  19733. //suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  19734. //otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  19735. //payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  19736. //cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  19737. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  19738. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  19739. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  19740. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  19741. rateDatas.Add(new { code = roomCurr, rate = roomInfo.Rate });
  19742. var ccpPaymentCurrency = currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? "";
  19743. if (ccpPaymentCurrency.Equals("CNY"))
  19744. {
  19745. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} CNY";
  19746. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  19747. }
  19748. else
  19749. {
  19750. rateDatas.Add(new { code = ccpPaymentCurrency, rate = ccpInfo.DayRate });
  19751. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {ccpPaymentCurrency}\r\n{((ccpInfo.PayMoney * ccpInfo.DayRate) / _rate).ToString("#0.00")} CNY";
  19752. }
  19753. var hotelcardPriceCurrency = currDatas.Find(it => it.Id == item?.CardPriceCurrency)?.Name ?? "";
  19754. if (hotelcardPriceCurrency.Equals("CNY"))
  19755. {
  19756. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  19757. }
  19758. else
  19759. {
  19760. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {hotelcardPriceCurrency}\r\n{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} CNY";
  19761. }
  19762. }
  19763. string breakfastPriceStr = string.Empty,
  19764. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  19765. governmentRentStr = string.Empty,
  19766. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  19767. cityTaxStr = string.Empty,
  19768. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  19769. var breakfastCurrency1 = currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name;
  19770. if (!string.IsNullOrEmpty(breakfastCurrency1))
  19771. {
  19772. if (breakfastCurrency1.Equals("CNY"))
  19773. {
  19774. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  19775. }
  19776. else
  19777. {
  19778. rateDatas.Add(new { code = breakfastCurrency1, rate = breakfastInfo.Rate });
  19779. var breakfastPriceCny = breakfastInfo.Price * breakfastInfo.Rate;
  19780. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}\r\n{breakfastPriceCny.ToString("#0.00")} CNY";
  19781. }
  19782. }
  19783. else breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  19784. var governmentRentCurrency1 = currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name;
  19785. if (!string.IsNullOrEmpty(governmentRentCurrency1))
  19786. {
  19787. if (governmentRentCurrency.Equals("CNY"))
  19788. {
  19789. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  19790. }
  19791. else
  19792. {
  19793. rateDatas.Add(new { code = governmentRentCurrency1, rate = governmentRentInfo.Rate });
  19794. var governmentRentCny = governmentRentInfo.Price * governmentRentInfo.Rate;
  19795. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}\r\n{governmentRentCny.ToString("#0.00")} CNY";
  19796. }
  19797. }
  19798. else governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  19799. var cityTaxStrCurrency1 = currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name;
  19800. if (!string.IsNullOrEmpty(cityTaxStrCurrency1))
  19801. {
  19802. if (cityTaxStrCurrency1.Equals("CNY"))
  19803. {
  19804. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  19805. }
  19806. else
  19807. {
  19808. rateDatas.Add(new { code = cityTaxStrCurrency1, rate = cityTaxInfo.Rate });
  19809. var cityTaxCny = cityTaxInfo.Price * cityTaxInfo.Rate;
  19810. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}\r\n{cityTaxCny.ToString("#0.00")} CNY";
  19811. }
  19812. }
  19813. else cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  19814. int payDId = roomInfo?.PayDId ?? 0;
  19815. pcfds.Add(new HotelReservations_PCFD_View()
  19816. {
  19817. City = item.City,
  19818. HotelName = item.HotelName,
  19819. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  19820. // SingleRoomCount = item.SingleRoomCount,
  19821. SingleRoomPrice = singleRoomFeeStr,
  19822. // DoubleRoomCount = item.DoubleRoomCount,
  19823. DoubleRoomPrice = doubleRoomFeeStr,
  19824. //SuiteRoomCount = item.SuiteRoomCount,
  19825. SuiteRoomPrice = suiteRoomFeeStr,
  19826. OtherRoomPrice = otherRoomFeeStr,
  19827. //OtherRoomCount = item.OtherRoomCount,
  19828. BreakfastPrice = breakfastPriceStr,
  19829. GovernmentRent = governmentRentStr,
  19830. CityTax = cityTaxStr,
  19831. RoomExplanation = item.RoomExplanation,
  19832. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  19833. PayTime = roomInfo?.ConsumptionDate,
  19834. BankNo = roomInfo?.BankNo,
  19835. PayMoney = payMoneyStr,
  19836. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  19837. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  19838. CardPrice = cardPriceStr,
  19839. Remark = ccpInfo.Remark
  19840. });
  19841. }
  19842. #endregion
  19843. //载入模板
  19844. WorkbookDesigner designer = new WorkbookDesigner();
  19845. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  19846. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  19847. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  19848. designer.SetDataSource("TourNo", groupInfo.TourCode);
  19849. var rateDatas1 = rateDatas.Distinct();
  19850. var rateStr = string.Empty;
  19851. foreach (var item in rateDatas1)
  19852. {
  19853. rateStr += $"{item.code} {item.rate.ToString("#0.0000")} \t\t";
  19854. }
  19855. designer.SetDataSource("TeamName", $"酒店模块汇率:{rateStr}");
  19856. designer.SetDataSource("Opertor", userInfo.CnName);
  19857. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  19858. dt.TableName = "ViewMyHotelReservations";
  19859. designer.SetDataSource(dt);
  19860. designer.Process();
  19861. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  19862. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  19863. designer.Workbook.Save(serverPath);
  19864. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  19865. #region 删除指定行
  19866. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  19867. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  19868. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  19869. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  19870. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  19871. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  19872. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  19873. cssIndex = dt.Columns["CityTax"].Ordinal,
  19874. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  19875. remarkIndex = dt.Columns["Remark"].Ordinal;
  19876. //删除指定列
  19877. foreach (DataRow item in dt.Rows)
  19878. {
  19879. string singleStr = item["SingleRoomPrice"].ToString();
  19880. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  19881. if (containsDigitButNotZero1) singleDel = false;
  19882. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  19883. string doubleStr = item["DoubleRoomPrice"].ToString();
  19884. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  19885. if (containsDigitButNotZero2) doubleDel = false;
  19886. string suiteStr = item["SuiteRoomPrice"].ToString();
  19887. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  19888. if (containsDigitButNotZero3) suiteDel = false;
  19889. string otherStr = item["OtherRoomPrice"].ToString();
  19890. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  19891. if (containsDigitButNotZero4) otherDel = false;
  19892. string zcStr = item["BreakfastPrice"].ToString();
  19893. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  19894. if (containsDigitButNotZero5) zcDel = false;
  19895. string dsStr = item["GovernmentRent"].ToString();
  19896. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  19897. if (containsDigitButNotZero6) dsDel = false;
  19898. string cssStr = item["CityTax"].ToString();
  19899. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  19900. if (containsDigitButNotZero7) cssDel = false;
  19901. string cpStr = item["ConsumptionPatterns"].ToString();
  19902. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  19903. string remarkStr = item["Remark"].ToString();
  19904. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  19905. }
  19906. DeleteColumn(serverPath, remarkIndex, remarkDel);
  19907. DeleteColumn(serverPath, cpIndex, cpDel);
  19908. DeleteColumn(serverPath, dsIndex, dsDel);
  19909. DeleteColumn(serverPath, cssIndex, cssDel);
  19910. DeleteColumn(serverPath, zcIndex, zcDel);
  19911. DeleteColumn(serverPath, otherIndex, otherDel);
  19912. DeleteColumn(serverPath, suiteIndex, suiteDel);
  19913. DeleteColumn(serverPath, doubleIndex, doubleDel);
  19914. DeleteColumn(serverPath, singleIndex, singleDel);
  19915. #endregion
  19916. //只保留第一个表格
  19917. DeleteSheet(serverPath);
  19918. return Ok(JsonView(true, "操作成功", url = rst));
  19919. }
  19920. else
  19921. {
  19922. _currency = _GroupCostParameter.Currency;
  19923. bool isIntType = int.TryParse(_currency, out int currId);
  19924. if (isIntType)
  19925. {
  19926. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  19927. }
  19928. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  19929. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  19930. if (currInfo == null)
  19931. {
  19932. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  19933. }
  19934. if (!_currency.ToUpper().Equals("CNY"))
  19935. {
  19936. _rate = _GroupCostParameter.Rate;
  19937. }
  19938. _rate = currInfo.Rate;
  19939. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  19940. //string strFileName = "HotelStatement/";
  19941. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  19942. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  19943. #region 数据处理
  19944. foreach (var item in hrDtas)
  19945. {
  19946. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  19947. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  19948. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  19949. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  19950. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  19951. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  19952. string singleRoomFeeStr = string.Empty,
  19953. doubleRoomFeeStr = string.Empty,
  19954. suiteRoomFeeStr = string.Empty,
  19955. otherRoomFeeStr = string.Empty,
  19956. payMoneyStr = string.Empty,
  19957. cardPriceStr = string.Empty;
  19958. if (roomCurr.Equals(_currency))
  19959. {
  19960. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  19961. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  19962. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  19963. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  19964. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  19965. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  19966. }
  19967. else
  19968. {
  19969. singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  19970. doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  19971. suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  19972. otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  19973. payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  19974. cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  19975. }
  19976. string breakfastPriceStr = string.Empty,
  19977. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  19978. governmentRentStr = string.Empty,
  19979. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  19980. cityTaxStrStr = string.Empty,
  19981. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  19982. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  19983. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  19984. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  19985. int payDId = roomInfo?.PayDId ?? 0;
  19986. pcfds.Add(new HotelReservations_PCFD_View()
  19987. {
  19988. City = item.City,
  19989. HotelName = item.HotelName,
  19990. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  19991. // SingleRoomCount = item.SingleRoomCount,
  19992. SingleRoomPrice = singleRoomFeeStr,
  19993. // DoubleRoomCount = item.DoubleRoomCount,
  19994. DoubleRoomPrice = doubleRoomFeeStr,
  19995. //SuiteRoomCount = item.SuiteRoomCount,
  19996. SuiteRoomPrice = suiteRoomFeeStr,
  19997. OtherRoomPrice = otherRoomFeeStr,
  19998. //OtherRoomCount = item.OtherRoomCount,
  19999. BreakfastPrice = breakfastPriceStr,
  20000. GovernmentRent = governmentRentStr,
  20001. CityTax = cityTaxStrStr,
  20002. RoomExplanation = item.RoomExplanation,
  20003. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  20004. PayTime = roomInfo?.ConsumptionDate,
  20005. BankNo = roomInfo?.BankNo,
  20006. PayMoney = payMoneyStr,
  20007. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  20008. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  20009. CardPrice = cardPriceStr,
  20010. Remark = ccpInfo.Remark
  20011. });
  20012. }
  20013. #endregion
  20014. //载入模板
  20015. WorkbookDesigner designer = new WorkbookDesigner();
  20016. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  20017. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  20018. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  20019. designer.SetDataSource("TourNo", groupInfo.TourCode);
  20020. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  20021. designer.SetDataSource("Opertor", userInfo.CnName);
  20022. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  20023. dt.TableName = "ViewMyHotelReservations";
  20024. designer.SetDataSource(dt);
  20025. designer.Process();
  20026. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  20027. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  20028. designer.Workbook.Save(serverPath);
  20029. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  20030. #region 删除指定行
  20031. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  20032. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  20033. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  20034. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  20035. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  20036. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  20037. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  20038. cssIndex = dt.Columns["CityTax"].Ordinal,
  20039. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  20040. remarkIndex = dt.Columns["Remark"].Ordinal;
  20041. //删除指定列
  20042. foreach (DataRow item in dt.Rows)
  20043. {
  20044. string singleStr = item["SingleRoomPrice"].ToString();
  20045. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  20046. if (containsDigitButNotZero1) singleDel = false;
  20047. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  20048. string doubleStr = item["DoubleRoomPrice"].ToString();
  20049. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  20050. if (containsDigitButNotZero2) doubleDel = false;
  20051. string suiteStr = item["SuiteRoomPrice"].ToString();
  20052. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  20053. if (containsDigitButNotZero3) suiteDel = false;
  20054. string otherStr = item["OtherRoomPrice"].ToString();
  20055. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  20056. if (containsDigitButNotZero4) otherDel = false;
  20057. string zcStr = item["BreakfastPrice"].ToString();
  20058. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  20059. if (containsDigitButNotZero5) zcDel = false;
  20060. string dsStr = item["GovernmentRent"].ToString();
  20061. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  20062. if (containsDigitButNotZero6) dsDel = false;
  20063. string cssStr = item["CityTax"].ToString();
  20064. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  20065. if (containsDigitButNotZero7) cssDel = false;
  20066. string cpStr = item["ConsumptionPatterns"].ToString();
  20067. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  20068. string remarkStr = item["Remark"].ToString();
  20069. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  20070. }
  20071. DeleteColumn(serverPath, remarkIndex, remarkDel);
  20072. DeleteColumn(serverPath, cpIndex, cpDel);
  20073. DeleteColumn(serverPath, dsIndex, dsDel);
  20074. DeleteColumn(serverPath, cssIndex, cssDel);
  20075. DeleteColumn(serverPath, zcIndex, zcDel);
  20076. DeleteColumn(serverPath, otherIndex, otherDel);
  20077. DeleteColumn(serverPath, suiteIndex, suiteDel);
  20078. DeleteColumn(serverPath, doubleIndex, doubleDel);
  20079. DeleteColumn(serverPath, singleIndex, singleDel);
  20080. #endregion
  20081. //只保留第一个表格
  20082. DeleteSheet(serverPath);
  20083. return Ok(JsonView(true, "操作成功", url = rst));
  20084. }
  20085. //return Ok(JsonView(false));
  20086. }
  20087. /// <summary>
  20088. /// 删除指定列
  20089. /// </summary>
  20090. /// <param name="file"></param>
  20091. /// <param name="columnIndex"></param>
  20092. /// <param name="isDel"></param>
  20093. private void DeleteColumn(string file, int columnIndex, bool isDel)
  20094. {
  20095. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  20096. //wb.Save(file);
  20097. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  20098. if (sheet1 != null)
  20099. {
  20100. if (isDel)
  20101. {
  20102. Cells cells = sheet1.Cells;
  20103. cells.DeleteColumn(columnIndex);
  20104. }
  20105. }
  20106. wb.Save(file);
  20107. }
  20108. /// <summary>
  20109. /// 删除sheet
  20110. /// </summary>
  20111. /// <param name="file"></param>
  20112. private void DeleteSheet(string file)
  20113. {
  20114. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  20115. //wb.Save(file);
  20116. List<string> sheets = new List<string>();
  20117. foreach (var item in wb.Worksheets)
  20118. {
  20119. sheets.Add(item.Name);
  20120. }
  20121. if (sheets.Count > 0)
  20122. {
  20123. sheets.RemoveAt(0);//不删除第一个sheet
  20124. foreach (var item in sheets)
  20125. {
  20126. wb.Worksheets.RemoveAt(item);
  20127. }
  20128. }
  20129. wb.Save(file);
  20130. }
  20131. /// <summary>
  20132. /// 酒店预订
  20133. /// 确认单
  20134. /// </summary>
  20135. /// <param name="_dto"></param>
  20136. /// <returns></returns>
  20137. [HttpPost]
  20138. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20139. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  20140. {
  20141. try
  20142. {
  20143. #region 参数验证
  20144. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  20145. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  20146. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  20147. #region 团组操作权限验证 76 酒店预定模块
  20148. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  20149. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  20150. #endregion
  20151. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20152. #region 页面操作权限验证
  20153. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20154. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  20155. #endregion
  20156. #endregion
  20157. //团组信息
  20158. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  20159. //酒店数据
  20160. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  20161. if (listhoteldata.Count < 0)
  20162. {
  20163. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  20164. }
  20165. //利datatable存储
  20166. DataTable dt = new DataTable();
  20167. dt.Columns.Add("CheckInDate", typeof(string));
  20168. dt.Columns.Add("City", typeof(string));
  20169. dt.Columns.Add("Hotel", typeof(string));
  20170. dt.Columns.Add("Room", typeof(string));
  20171. for (int i = 0; i < listhoteldata.Count; i++)
  20172. {
  20173. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  20174. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  20175. while (dayStart < dayEnd)
  20176. {
  20177. string temp = "";
  20178. DataRow row = dt.NewRow();
  20179. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  20180. row["City"] = listhoteldata[i].City;
  20181. row["Hotel"] = listhoteldata[i].HotelName;
  20182. if (listhoteldata[i].SingleRoomCount > 0)
  20183. {
  20184. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  20185. }
  20186. if (listhoteldata[i].DoubleRoomCount > 0)
  20187. {
  20188. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  20189. }
  20190. if (listhoteldata[i].SuiteRoomCount > 0)
  20191. {
  20192. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  20193. }
  20194. if (listhoteldata[i].OtherRoomCount > 0)
  20195. {
  20196. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  20197. }
  20198. row["Room"] = temp;
  20199. dt.Rows.Add(row);
  20200. dayStart = dayStart.AddDays(1);
  20201. }
  20202. }
  20203. Dictionary<string, string> dic = new Dictionary<string, string>();
  20204. dic.Add("Dele", di.TeamName);
  20205. dic.Add("City", di.VisitCountry);
  20206. //模板路径
  20207. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  20208. //载入模板
  20209. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  20210. DocumentBuilder builder = new DocumentBuilder(doc);
  20211. foreach (var key in dic.Keys)
  20212. {
  20213. builder.MoveToBookmark(key);
  20214. builder.Write(dic[key]);
  20215. }
  20216. //获取word里所有表格
  20217. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  20218. //获取所填表格的序数
  20219. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  20220. var rowStart = tableOne.Rows[0]; //获取第1行
  20221. //循环赋值
  20222. for (int i = 0; i < dt.Rows.Count; i++)
  20223. {
  20224. builder.MoveToCell(0, i + 1, 0, 0);
  20225. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  20226. builder.MoveToCell(0, i + 1, 1, 0);
  20227. builder.Write(dt.Rows[i]["City"].ToString());
  20228. builder.MoveToCell(0, i + 1, 2, 0);
  20229. builder.Write(dt.Rows[i]["Hotel"].ToString());
  20230. builder.MoveToCell(0, i + 1, 3, 0);
  20231. builder.Write(dt.Rows[i]["Room"].ToString());
  20232. }
  20233. //删除多余行
  20234. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  20235. {
  20236. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  20237. }
  20238. string strFileName = di.TeamName + "酒店确认单.doc";
  20239. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  20240. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  20241. return Ok(JsonView(true, "成功", url));
  20242. }
  20243. catch (Exception ex)
  20244. {
  20245. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  20246. }
  20247. }
  20248. #endregion
  20249. #region 团组状态
  20250. /// <summary>
  20251. /// 团组状态列表 Page
  20252. /// </summary>
  20253. /// <param name="dto">团组列表请求dto</param>
  20254. /// <returns></returns>
  20255. [HttpPost]
  20256. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20257. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  20258. {
  20259. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  20260. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  20261. {
  20262. string sqlWhere = string.Empty;
  20263. if (dto.IsSure == 0) //未完成
  20264. {
  20265. sqlWhere += string.Format(@" And IsSure = 0");
  20266. }
  20267. else if (dto.IsSure == 1) //已完成
  20268. {
  20269. sqlWhere += string.Format(@" And IsSure = 1");
  20270. }
  20271. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  20272. {
  20273. string tj = dto.SearchCriteria;
  20274. 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}%')",
  20275. tj, tj, tj, tj, tj);
  20276. }
  20277. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  20278. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  20279. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  20280. From (
  20281. Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
  20282. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  20283. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  20284. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  20285. From Grp_DelegationInfo gdi
  20286. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  20287. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  20288. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  20289. Where gdi.IsDel = 0 {0}
  20290. ) temp ", sqlWhere);
  20291. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  20292. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  20293. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  20294. }
  20295. else
  20296. {
  20297. return Ok(JsonView(false, "查询失败"));
  20298. }
  20299. }
  20300. /// <summary>
  20301. /// 团组状态
  20302. /// 设置操作完成
  20303. /// </summary>
  20304. /// <param name="dto">团组列表请求dto</param>
  20305. /// <returns></returns>
  20306. [HttpPost]
  20307. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20308. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  20309. {
  20310. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  20311. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  20312. {
  20313. Id = dto.Id,
  20314. IsSure = 1
  20315. };
  20316. var result = await _sqlSugar.Updateable(_DelegationInfo)
  20317. .UpdateColumns(it => new { it.IsSure })
  20318. .WhereColumns(it => new { it.Id })
  20319. .ExecuteCommandAsync();
  20320. if (result > 0)
  20321. {
  20322. return Ok(JsonView(true, "操作完成!"));
  20323. }
  20324. return Ok(JsonView(false, "操作失败!"));
  20325. }
  20326. #endregion
  20327. #region 保险费用录入
  20328. /// <summary>
  20329. /// 根据团组Id查询保险费用列表
  20330. /// </summary>
  20331. /// <param name="dto"></param>
  20332. /// <returns></returns>
  20333. [HttpPost]
  20334. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20335. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  20336. {
  20337. Result groupData = await _customersRep.CustomersByDiId(dto);
  20338. if (groupData.Code != 0)
  20339. {
  20340. return Ok(JsonView(false, groupData.Msg));
  20341. }
  20342. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  20343. }
  20344. /// <summary>
  20345. /// 根据保险费用Id查询保险费用详细
  20346. /// </summary>
  20347. /// <param name="dto"></param>
  20348. /// <returns></returns>
  20349. [HttpPost]
  20350. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20351. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  20352. {
  20353. try
  20354. {
  20355. Result groupData = await _customersRep.CustomersById(dto);
  20356. if (groupData.Code != 0)
  20357. {
  20358. return Ok(JsonView(false, groupData.Msg));
  20359. }
  20360. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  20361. }
  20362. catch (Exception ex)
  20363. {
  20364. return Ok(JsonView(false, ex.Message));
  20365. }
  20366. }
  20367. /// <summary>
  20368. /// 保险费用录入页面初始化绑定
  20369. /// </summary>
  20370. /// <param name="dto"></param>
  20371. /// <returns></returns>
  20372. [HttpPost]
  20373. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20374. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  20375. {
  20376. try
  20377. {
  20378. Result groupData = await _customersRep.CustomersInitialize(dto);
  20379. if (groupData.Code != 0)
  20380. {
  20381. return Ok(JsonView(false, groupData.Msg));
  20382. }
  20383. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  20384. }
  20385. catch (Exception ex)
  20386. {
  20387. return Ok(JsonView(false, ex.Message));
  20388. }
  20389. }
  20390. /// <summary>
  20391. /// 保险费用操作(Status:1.新增,2.修改)
  20392. /// </summary>
  20393. /// <param name="dto"></param>
  20394. /// <returns></returns>
  20395. [HttpPost]
  20396. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20397. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  20398. {
  20399. Result groupData = await _customersRep.OpCustomers(dto);
  20400. if (groupData.Code != 0)
  20401. {
  20402. return Ok(JsonView(false, groupData.Msg));
  20403. }
  20404. #region 应用推送
  20405. try
  20406. {
  20407. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  20408. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  20409. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  20410. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  20411. //自动审核
  20412. await _feeAuditRep.FeeAutomaticAudit(4, dto.DiId, dataId);
  20413. //2024-10-21 新增LZ UID
  20414. var userIds = new List<int>() { 21 };
  20415. string title = $"系统通知";
  20416. var diId = dto.DiId;
  20417. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  20418. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  20419. string content = "";
  20420. if (dto.Status == 1) content = $"[新增-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  20421. else if (dto.Status == 2) content = $"[更新-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  20422. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  20423. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "82" };
  20424. await APNsTools.iOS_PushNotifications1("051", "保险费用审核", "", content, true, "ExpenseAuditWebView", h5);
  20425. }
  20426. catch (Exception ex)
  20427. {
  20428. }
  20429. #endregion
  20430. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  20431. }
  20432. /// <summary>
  20433. /// 保险文件上传
  20434. /// </summary>
  20435. /// <param name="file"></param>
  20436. /// <returns></returns>
  20437. [HttpPost]
  20438. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20439. public async Task<IActionResult> UploadCus(IFormFile file)
  20440. {
  20441. try
  20442. {
  20443. if (file != null)
  20444. {
  20445. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  20446. //文件名称
  20447. string projectFileName = file.FileName;
  20448. //上传的文件的路径
  20449. string filePath = "";
  20450. if (!Directory.Exists(fileDir))
  20451. {
  20452. Directory.CreateDirectory(fileDir);
  20453. }
  20454. //上传的文件的路径
  20455. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  20456. using (FileStream fs = System.IO.File.Create(filePath))
  20457. {
  20458. file.CopyTo(fs);
  20459. fs.Flush();
  20460. }
  20461. return Ok(JsonView(true, "上传成功!", projectFileName));
  20462. }
  20463. else
  20464. {
  20465. return Ok(JsonView(false, "上传失败!"));
  20466. }
  20467. }
  20468. catch (Exception ex)
  20469. {
  20470. return Ok(JsonView(false, ex.Message));
  20471. }
  20472. }
  20473. /// <summary>
  20474. /// 保险删除指定文件
  20475. /// </summary>
  20476. /// <param name="dto"></param>
  20477. /// <returns></returns>
  20478. [HttpPost]
  20479. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20480. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  20481. {
  20482. try
  20483. {
  20484. string filePath = "";
  20485. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  20486. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  20487. //int id = 0;
  20488. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  20489. // 删除该文件
  20490. try
  20491. {
  20492. System.IO.File.Delete(filePath);
  20493. 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()
  20494. {
  20495. Attachment = "",
  20496. }).ExecuteCommandAsync();
  20497. if (result != 0)
  20498. {
  20499. return Ok(JsonView(true, "成功!"));
  20500. }
  20501. else
  20502. {
  20503. return Ok(JsonView(false, "失败!"));
  20504. }
  20505. }
  20506. catch (Exception)
  20507. {
  20508. 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()
  20509. {
  20510. Attachment = "",
  20511. }).ExecuteCommandAsync();
  20512. if (result != 0)
  20513. {
  20514. return Ok(JsonView(true, "成功!"));
  20515. }
  20516. else
  20517. {
  20518. return Ok(JsonView(false, "失败!"));
  20519. }
  20520. }
  20521. }
  20522. catch (Exception ex)
  20523. {
  20524. return Ok(JsonView(false, "程序错误!"));
  20525. throw;
  20526. }
  20527. }
  20528. /// <summary>
  20529. /// 保险费用操作(删除)
  20530. /// </summary>
  20531. /// <param name="dto"></param>
  20532. /// <returns></returns>
  20533. [HttpPost]
  20534. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20535. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  20536. {
  20537. try
  20538. {
  20539. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  20540. if (!res)
  20541. {
  20542. return Ok(JsonView(false, "删除失败"));
  20543. }
  20544. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  20545. {
  20546. IsDel = 1,
  20547. DeleteUserId = dto.DeleteUserId,
  20548. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  20549. }).ExecuteCommandAsync();
  20550. return Ok(JsonView(true, "删除成功!"));
  20551. }
  20552. catch (Exception ex)
  20553. {
  20554. return Ok(JsonView(false, "程序错误!"));
  20555. throw;
  20556. }
  20557. }
  20558. #endregion
  20559. #region 接团客户名单 PageId 104
  20560. /// <summary>
  20561. /// 接团客户名单
  20562. /// 迁移数据(慎用!)
  20563. /// </summary>
  20564. /// <returns></returns>
  20565. [HttpPost]
  20566. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20567. public async Task<IActionResult> PostTourClientListChange()
  20568. {
  20569. try
  20570. {
  20571. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  20572. //var groupClinetData1
  20573. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  20574. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  20575. int updateCount = 0;
  20576. if (oldOAClientList.Count > 0)
  20577. {
  20578. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  20579. _sqlSugar.BeginTran();
  20580. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  20581. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  20582. foreach (var item in oldOAClientList)
  20583. {
  20584. int comId = 0;
  20585. string format = "yyyy-MM-dd HH:mm:ss";
  20586. string data11 = "1990-01-01 00:00";
  20587. var data1 = IsValidDate(item.OPdate, format);
  20588. if (data1) data11 = item.OPdate;
  20589. //客户公司验证
  20590. if (!string.IsNullOrEmpty(item.Company))
  20591. {
  20592. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  20593. if (clientComInfo == null) // add
  20594. {
  20595. var addInfo = new Crm_CustomerCompany()
  20596. {
  20597. CompanyAbbreviation = "",
  20598. CompanyFullName = item.Company,
  20599. Address = "",
  20600. PostCodes = "",
  20601. LastedOpUserId = item.OPer,
  20602. LastedOpDt = Convert.ToDateTime(data11),
  20603. CreateUserId = item.OPer,
  20604. CreateTime = Convert.ToDateTime(data11),
  20605. IsDel = 0
  20606. };
  20607. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  20608. if (comId1 > 0) comId = comId1;
  20609. }
  20610. else comId = clientComInfo.Id;
  20611. }
  20612. //客户人员验证
  20613. int clientId = 0;
  20614. string name = item.LastName + item.Name;
  20615. if (!string.IsNullOrEmpty(name))
  20616. {
  20617. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  20618. if (clientInfo == null)
  20619. {
  20620. DateTime? dateTime = null;
  20621. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  20622. if (isDt) dateTime = birthDayDt;
  20623. var addInfo1 = new Crm_DeleClient()
  20624. {
  20625. CrmCompanyId = comId,
  20626. DiId = -1,
  20627. LastName = item.LastName,
  20628. FirstName = item.Name,
  20629. OldName = "",
  20630. Pinyin = item.Pinyin,
  20631. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  20632. Marriage = 0,
  20633. Phone = item.Phone,
  20634. Job = item.Job,
  20635. BirthDay = dateTime
  20636. };
  20637. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  20638. if (clientId1 > 0) clientId = clientId1;
  20639. }
  20640. else clientId = clientInfo.Id;
  20641. }
  20642. if (clientId < 1)
  20643. {
  20644. continue;
  20645. }
  20646. int airType = 0;
  20647. if (item.AirType == "超经舱") airType = 459;
  20648. else if (item.AirType == "公务舱") airType = 458;
  20649. else if (item.AirType == "经济舱") airType = 460;
  20650. else if (item.AirType == "其他") airType = 565;
  20651. else if (item.AirType == "头等舱") airType = 457;
  20652. var _TourClientListEntity = new Grp_TourClientList()
  20653. {
  20654. DiId = item.Diid,
  20655. ClientId = clientId,
  20656. CreateUserId = item.OPer,
  20657. CreateTime = Convert.ToDateTime(data11),
  20658. Remark = item.Remark,
  20659. IsDel = item.Isdel,
  20660. ShippingSpaceTypeId = airType,
  20661. ShippingSpaceSpecialNeeds = item.AirRemark,
  20662. HotelSpecialNeeds = item.RoomType
  20663. };
  20664. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  20665. if (_TourClientList > 0)
  20666. {
  20667. updateCount++;
  20668. }
  20669. }
  20670. _sqlSugar.CommitTran();
  20671. }
  20672. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  20673. }
  20674. catch (Exception ex)
  20675. {
  20676. _sqlSugar.RollbackTran();
  20677. return Ok(JsonView(false, ex.Message));
  20678. }
  20679. //return Ok(JsonView(true));
  20680. }
  20681. private bool IsValidDate(string dateString, string format)
  20682. {
  20683. return DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime dateValue);
  20684. }
  20685. /// <summary>
  20686. /// 接团客户名单
  20687. /// 根据团组Id查询List
  20688. /// </summary>
  20689. /// <param name="_dto"></param>
  20690. /// <returns></returns>
  20691. [HttpPost]
  20692. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20693. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  20694. {
  20695. #region 参数验证
  20696. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  20697. if (_dto.PageId != 104) _dto.PageId = 104; //接团客户名单PageId
  20698. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  20699. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20700. #region 页面操作权限验证
  20701. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20702. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  20703. #endregion
  20704. #endregion
  20705. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  20706. if (viewData.Code != 0)
  20707. {
  20708. return Ok(JsonView(false, viewData.Msg));
  20709. }
  20710. return Ok(JsonView(viewData.Data));
  20711. }
  20712. /// <summary>
  20713. /// 接团客户名单
  20714. /// 基础数据 Init
  20715. /// </summary>
  20716. /// <param name="_dto"></param>
  20717. /// <returns></returns>
  20718. [HttpPost]
  20719. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20720. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  20721. {
  20722. #region 参数验证
  20723. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  20724. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  20725. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20726. #region 页面操作权限验证
  20727. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20728. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  20729. #endregion
  20730. #endregion
  20731. return Ok(await _tourClientListRep._BasicDataInit(_dto.PortType));
  20732. }
  20733. /// <summary>
  20734. /// 接团客户名单
  20735. /// 根据 Id查询 Details
  20736. /// </summary>
  20737. /// <param name="_dto"></param>
  20738. /// <returns></returns>
  20739. [HttpPost]
  20740. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20741. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  20742. {
  20743. #region 参数验证
  20744. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  20745. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  20746. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  20747. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20748. #region 页面操作权限验证
  20749. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20750. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  20751. #endregion
  20752. #endregion
  20753. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  20754. if (viewData.Code != 0)
  20755. {
  20756. return Ok(JsonView(false, viewData.Msg));
  20757. }
  20758. return Ok(JsonView(viewData.Data));
  20759. }
  20760. /// <summary>
  20761. /// 接团客户名单
  20762. /// Add Or Edit
  20763. /// </summary>
  20764. /// <param name="_dto"></param>
  20765. /// <returns></returns>
  20766. [HttpPost]
  20767. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20768. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  20769. {
  20770. #region 参数验证
  20771. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  20772. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  20773. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  20774. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20775. #region 页面操作权限验证
  20776. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20777. if (_dto.Id == 0) //添加
  20778. {
  20779. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  20780. }
  20781. else if (_dto.Id >= 0) //修改
  20782. {
  20783. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  20784. }
  20785. #endregion
  20786. #endregion
  20787. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  20788. if (viewData.Code != 0)
  20789. {
  20790. return Ok(JsonView(false, viewData.Msg));
  20791. }
  20792. return Ok(JsonView(true));
  20793. }
  20794. /// <summary>
  20795. /// 接团客户名单
  20796. /// json字符串 AddMultiple(添加多个)
  20797. /// </summary>
  20798. /// <param name="_dto"></param>
  20799. /// <returns></returns>
  20800. [HttpPost]
  20801. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20802. public async Task<IActionResult> PostTourClientListJsonFormatAddMultiple(PostTourClientListJsonFormatAddMultipleDto _dto)
  20803. {
  20804. #region 参数验证
  20805. string jsonLabel = _dto.JsonLabel;
  20806. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  20807. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  20808. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20809. #region 页面操作权限验证
  20810. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20811. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  20812. #endregion
  20813. #endregion
  20814. var request = new TourClientListAddMultipleDto();
  20815. request.DiId = _dto.DiId;
  20816. request.UserId = _dto.UserId;
  20817. if (!CommonFun.IsValidJson(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数不是合法的json格式!"));
  20818. if (string.IsNullOrEmpty(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数值不能为空"));
  20819. List<TourClientListInfoCN> datas = JsonConvert.DeserializeObject<List<TourClientListInfoCN>>(jsonLabel);
  20820. if (!datas.Any()) return Ok(JsonView(false, "JsonLabel参数值不能为空!"));
  20821. var infos = new List<TourClientListInfo>();
  20822. foreach (var data in datas)
  20823. {
  20824. (string lastName, string firstName) = CommonFun.GetLastNameAndFirstName(data.Name);
  20825. string lastNameEn = CommonFun.ConvertToPinyin(lastName),
  20826. firstNameEn = CommonFun.ConvertToPinyin(lastName);
  20827. if (string.IsNullOrEmpty(lastNameEn) || string.IsNullOrEmpty(firstNameEn))
  20828. {
  20829. continue;
  20830. }
  20831. infos.Add(new TourClientListInfo()
  20832. {
  20833. IsAccompany = 1,
  20834. LastName = lastName,
  20835. FirstName = firstName,
  20836. Pinyin = lastNameEn + @"/" + firstNameEn,
  20837. Sex = data.Sex.Equals("男") ? 0 : data.Sex.Equals("女") ? 1 : 2,
  20838. CompanyFullName = data.CompanyFullName,
  20839. Job = data.Job
  20840. });
  20841. }
  20842. if (infos.Any())
  20843. {
  20844. var viewData = await _tourClientListRep._AddMultiple(request);
  20845. if (viewData.Code != 0)
  20846. {
  20847. return Ok(JsonView(false, viewData.Msg));
  20848. }
  20849. return Ok(JsonView(true));
  20850. }
  20851. return Ok(JsonView(false));
  20852. }
  20853. /// <summary>
  20854. /// 接团客户名单
  20855. /// AddMultiple(添加多个)
  20856. /// </summary>
  20857. /// <param name="_dto"></param>
  20858. /// <returns></returns>
  20859. [HttpPost]
  20860. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20861. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  20862. {
  20863. #region 参数验证
  20864. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  20865. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  20866. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20867. #region 页面操作权限验证
  20868. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20869. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  20870. #endregion
  20871. #endregion
  20872. var viewData = await _tourClientListRep._AddMultiple(_dto);
  20873. if (viewData.Code != 0)
  20874. {
  20875. return Ok(JsonView(false, viewData.Msg));
  20876. }
  20877. return Ok(JsonView(true));
  20878. }
  20879. /// <summary>
  20880. /// 接团客户名单
  20881. /// Del
  20882. /// </summary>
  20883. /// <param name="_dto"></param>
  20884. /// <returns></returns>
  20885. [HttpPost]
  20886. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20887. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  20888. {
  20889. #region 参数验证
  20890. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  20891. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  20892. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20893. #region 页面操作权限验证
  20894. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20895. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  20896. #endregion
  20897. #endregion
  20898. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  20899. if (viewData.Code != 0)
  20900. {
  20901. return Ok(JsonView(false, viewData.Msg));
  20902. }
  20903. return Ok(JsonView(true));
  20904. }
  20905. /// <summary>
  20906. /// 接团客户名单
  20907. /// 文件下载 客户名单
  20908. /// </summary>
  20909. /// <param name="_dto"></param>
  20910. /// <returns></returns>
  20911. [HttpPost]
  20912. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20913. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  20914. {
  20915. #region 参数验证
  20916. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  20917. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  20918. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  20919. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20920. #region 页面操作权限验证
  20921. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20922. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  20923. #endregion
  20924. #endregion
  20925. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  20926. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  20927. From Grp_TourClientList tcl
  20928. Left Join
  20929. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  20930. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  20931. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  20932. From Crm_DeleClient dc
  20933. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  20934. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  20935. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  20936. Where dc.IsDel = 0) temp
  20937. On temp.DcId =tcl.ClientId
  20938. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  20939. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  20940. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  20941. //载入模板
  20942. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  20943. if (_dto.Language == 1)
  20944. {
  20945. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  20946. }
  20947. //载入模板
  20948. var doc = new Document(tempPath);
  20949. DocumentBuilder builder = new DocumentBuilder(doc);
  20950. //获取word里所有表格
  20951. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  20952. //获取所填表格的序数
  20953. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  20954. var rowStart = tableOne.Rows[0]; //获取第1行
  20955. if (_dto.Language == 0)
  20956. {
  20957. //循环赋值
  20958. for (int i = 0; i < DcList.Count; i++)
  20959. {
  20960. EncryptionProcessor.DecryptProperties(DcList[i]);
  20961. builder.MoveToCell(0, i + 1, 0, 0);
  20962. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  20963. builder.MoveToCell(0, i + 1, 1, 0);
  20964. int sex = DcList[i].Sex;
  20965. string sexStr = string.Empty;
  20966. if (sex == 0) sexStr = "男";
  20967. else if (sex == 1) sexStr = "女";
  20968. else sexStr = "未设置";
  20969. builder.Write(sexStr);
  20970. builder.MoveToCell(0, i + 1, 2, 0);
  20971. string birthDay = DcList[i].BirthDay;
  20972. string birthDayStr = string.Empty;
  20973. if (!string.IsNullOrEmpty(birthDay))
  20974. {
  20975. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  20976. }
  20977. builder.Write(birthDayStr);
  20978. builder.MoveToCell(0, i + 1, 3, 0);
  20979. string company = "";
  20980. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  20981. {
  20982. company = DcList[i].CompanyFullName.ToString();
  20983. }
  20984. builder.Write(company);
  20985. builder.MoveToCell(0, i + 1, 4, 0);
  20986. builder.Write(DcList[i].Job);
  20987. }
  20988. }
  20989. else if (_dto.Language == 1)
  20990. {
  20991. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  20992. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  20993. List<string> transArrayStr = new List<string>();
  20994. string transStrRes1 = "";
  20995. var clientEnglishs = new List<ClientEnglishView>();
  20996. for (int i = 0; i < DcList.Count; i++)
  20997. {
  20998. var dc = DcList[i];
  20999. EncryptionProcessor.DecryptProperties(dc);
  21000. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  21001. if (dc.Job.Equals("暂无")) dc.Job = "-";
  21002. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  21003. if (DcList.Count - 1 == i) transStrRes1 += str1;
  21004. else transStrRes1 += $"{str1}|";
  21005. clientEnglishs.Add(new()
  21006. {
  21007. Id = dc.Id,
  21008. LastName = dc.LastName,
  21009. FirstName = dc.FirstName,
  21010. Pinyin = dc.Pinyin,
  21011. Sex = dc.Sex,
  21012. CompanyFullName = dc.CompanyFullName,
  21013. Job = dc.Job,
  21014. IDCardNo = dc.IDCardNo,
  21015. BirthDay = dc.BirthDay,
  21016. });
  21017. }
  21018. #region AI转英文
  21019. string jsonValue = JsonConvert.SerializeObject(clientEnglishs);
  21020. string text = @"将此JSON的中文部分全部翻译为英文,然后只给出修改后的JSON数据,不要其他任何文字";
  21021. List<SeedMessages> messages = new List<SeedMessages>()
  21022. {
  21023. new SeedMessages
  21024. {
  21025. Role = KimiRole.user,
  21026. Content = jsonValue + text
  21027. }
  21028. };
  21029. KiMiApiClient client = new KiMiApiClient();
  21030. var kimiApiResult = await client.SeedMessage(messages);
  21031. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  21032. string clients = kimiApiResult_JObject["content"].ToString();
  21033. string startStr = "```json", endStr = "```";
  21034. // 判断并清除开头部分
  21035. if (clients.StartsWith(startStr))
  21036. {
  21037. clients = clients.Remove(0, startStr.Length);
  21038. }
  21039. // 判断并清除结尾部分
  21040. if (clients.EndsWith(endStr))
  21041. {
  21042. clients = clients.Remove(clients.Length - endStr.Length);
  21043. }
  21044. var en_Json = JsonConvert.DeserializeObject<List<ClientEnglishView>>(clients);
  21045. //循环赋值
  21046. for (int i = 0; i < en_Json.Count; i++)
  21047. {
  21048. var dc = en_Json[i];
  21049. var dc1 = DcList.Find(x => x.Id == dc.Id);
  21050. string PYName = dc.FirstName + " " + dc.LastName;
  21051. builder.MoveToCell(0, i + 1, 0, 0);
  21052. builder.Write(PYName);
  21053. string sex = dc.Sex == 0 ? "Male" : dc.Sex == 1 ? "Female" : "";
  21054. builder.MoveToCell(0, i + 1, 1, 0);
  21055. builder.Write(sex);
  21056. DateTime birthDt;
  21057. bool b_birth = DateTime.TryParse(dc.BirthDay, out birthDt);
  21058. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  21059. builder.MoveToCell(0, i + 1, 2, 0);
  21060. builder.Write(birthday);
  21061. string company = string.Empty, job = string.Empty;
  21062. company = dc.CompanyFullName;
  21063. job = dc.Job;
  21064. if (dc1 != null && !string.IsNullOrEmpty(dc1.CompanyFullName))
  21065. {
  21066. //查询对照表
  21067. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(dc1.CompanyFullName.ToString().Trim()));
  21068. if (tempCec != null)
  21069. {
  21070. company = tempCec.enName;
  21071. }
  21072. }
  21073. builder.MoveToCell(0, i + 1, 3, 0);
  21074. builder.Write(company);
  21075. if (dc1 != null && !string.IsNullOrEmpty(dc1.Job))
  21076. {
  21077. //查询对照表
  21078. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == dc1.Job.ToString().Trim());
  21079. if (tempPec != null)
  21080. {
  21081. job = tempPec.enName;
  21082. }
  21083. }
  21084. builder.MoveToCell(0, i + 1, 4, 0);
  21085. builder.Write(job);
  21086. }
  21087. #endregion
  21088. #region 旧翻译英文处理
  21089. ////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";
  21090. //string transStrRes = "";
  21091. //if (transStrRes1.Length > 0)
  21092. //{
  21093. // transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  21094. //}
  21095. ////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
  21096. ////await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  21097. ////List<string> transArray = new List<string> { };
  21098. //List<TranslateInfo> transArray = new List<TranslateInfo>();
  21099. //if (transStrRes.Contains("|"))
  21100. //{
  21101. // string[] transArray1 = transStrRes.Split('|');
  21102. // if (transArray1.Length > 0)
  21103. // {
  21104. // foreach (var item in transArray1)
  21105. // {
  21106. // if (item.Contains("&"))
  21107. // {
  21108. // string[] transArray2 = item.Split('&');
  21109. // int index = 0;
  21110. // string companyName = "", job = "";
  21111. // if (transArray2.Length > 0)
  21112. // {
  21113. // bool success = int.TryParse(transArray2[0].Trim(), out index);
  21114. // if (1 < transArray2.Length) companyName = transArray2[1];
  21115. // if (2 < transArray2.Length) job = transArray2[2];
  21116. // }
  21117. // transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  21118. // }
  21119. // }
  21120. // }
  21121. //}
  21122. ////循环赋值
  21123. //for (int i = 0; i < DcList.Count; i++)
  21124. //{
  21125. // string PYName = "";
  21126. // if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  21127. // {
  21128. // string PY_Last = DcList[i].Pinyin.Split('/')[0];
  21129. // string PY_First = DcList[i].Pinyin.Split('/')[1];
  21130. // PYName = PY_First + " " + PY_Last;
  21131. // }
  21132. // else
  21133. // {
  21134. // string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  21135. // string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  21136. // PYName = PY_First + " " + PY_Last;
  21137. // }
  21138. // builder.MoveToCell(0, i + 1, 0, 0);
  21139. // builder.Write(PYName);
  21140. // string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  21141. // builder.MoveToCell(0, i + 1, 1, 0);
  21142. // builder.Write(sex);
  21143. // DateTime birthDt;
  21144. // bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  21145. // string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  21146. // builder.MoveToCell(0, i + 1, 2, 0);
  21147. // builder.Write(birthday);
  21148. // string company = string.Empty, job = string.Empty;
  21149. // var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  21150. // if (dcTransInfo != null)
  21151. // {
  21152. // company = dcTransInfo.CompanyName;
  21153. // job = dcTransInfo.Job;
  21154. // }
  21155. // if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  21156. // {
  21157. // //查询对照表
  21158. // Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  21159. // if (tempCec != null)
  21160. // {
  21161. // company = tempCec.enName;
  21162. // }
  21163. // //翻译
  21164. // else
  21165. // {
  21166. // }
  21167. // }
  21168. // builder.MoveToCell(0, i + 1, 3, 0);
  21169. // builder.Write(company);
  21170. // if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  21171. // {
  21172. // //查询对照表
  21173. // Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  21174. // if (tempPec != null)
  21175. // {
  21176. // job = tempPec.enName;
  21177. // }
  21178. // //翻译
  21179. // else
  21180. // {
  21181. // }
  21182. // }
  21183. // builder.MoveToCell(0, i + 1, 4, 0);
  21184. // builder.Write(job);
  21185. //}
  21186. #endregion
  21187. }
  21188. //删除多余行
  21189. while (tableOne.Rows.Count > DcList.Count + 1)
  21190. {
  21191. tableOne.Rows.RemoveAt(DcList.Count + 1);
  21192. }
  21193. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  21194. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  21195. doc.Save(fileDir);
  21196. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  21197. return Ok(JsonView(true, "操作成功!", Url));
  21198. }
  21199. private class TranslateInfo
  21200. {
  21201. public int Index { get; set; }
  21202. public string CompanyName { get; set; }
  21203. public string Job { get; set; }
  21204. }
  21205. [HttpPost]
  21206. public async Task<IActionResult> FileReadClient(List<IFormFile> files)
  21207. {
  21208. if (files.Count == 0)
  21209. {
  21210. return Ok(JsonView(false, "文件为空"));
  21211. }
  21212. KiMiApiClient KiMiApi = new KiMiApiClient();
  21213. var seedConter = await KiMiApi.UploadFilesAsync(files);
  21214. if (seedConter.Count == 0)
  21215. {
  21216. return Ok(JsonView(false, "上传结果为空!"));
  21217. }
  21218. var messages = new List<SeedMessages>
  21219. {
  21220. new SeedMessages { Role = KimiRole.system, Content = "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长中文和英文的对话。你会为用户提供安全,有帮助,准确的回答。同时,你会拒绝一切涉及恐怖主义,种族歧视,黄色暴力等问题的回答。Moonshot AI 为专有名词,不可翻译成其他语言。" },
  21221. new SeedMessages { Role = KimiRole.user, Content = "根据文件内容 ,按照“姓、名、姓名拼音、性别、单位、职务、出生日期”的json格式来排列整理(性别和出生日期通过身份证来识别 , 当识别到性别为男时值给0女给1 未识别到性别的情况下值给-1,出生日期按照yyyy-MM-dd来整理(若出生日期没有值则为‘-’),文件存在拼音的情况读取对应的拼音不存在则设置拼音为中文名字全拼),只输出JSON数组数据 从'['开始 到']'结尾 ,不要除JSON数据外的任何文字以及符号" }
  21222. };
  21223. messages.InsertRange(1, seedConter);
  21224. var kimiApiResult = await KiMiApi.SeedMessage(messages);
  21225. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  21226. string clients = kimiApiResult_JObject["content"].ToString();
  21227. string startStr = "```json", endStr = "```";
  21228. // 判断并清除开头部分
  21229. if (clients.StartsWith(startStr))
  21230. {
  21231. clients = clients.Remove(0, startStr.Length);
  21232. }
  21233. // 判断并清除结尾部分
  21234. if (clients.EndsWith(endStr))
  21235. {
  21236. clients = clients.Remove(clients.Length - endStr.Length);
  21237. }
  21238. var clients_JObject = JsonConvert.DeserializeObject<List<JObject>>(clients);
  21239. Dictionary<string, string> clientFieldMap = new Dictionary<string, string>()
  21240. {
  21241. {"姓", "LastName" },
  21242. {"名", "FirstName" },
  21243. {"姓名拼音", "Pinyin" },
  21244. {"性别", "Sex" },
  21245. {"单位", "CompanyFullName" },
  21246. {"职务", "Job" },
  21247. {"出生日期", "Birthday" },
  21248. };
  21249. List<BaiduClientOCRView> crmClients = new List<BaiduClientOCRView>();
  21250. foreach (var item in clients_JObject)
  21251. {
  21252. BaiduClientOCRView cdc = new BaiduClientOCRView();
  21253. foreach (var field in clientFieldMap.Keys)
  21254. {
  21255. if (item.TryGetValue(field, out JToken value))
  21256. {
  21257. var getValue = value.ToString();
  21258. System.Type type = cdc.GetType();
  21259. PropertyInfo propertyInfo = type.GetProperty(clientFieldMap[field]);
  21260. var propertyValue = Convert.ChangeType(getValue, propertyInfo.PropertyType);
  21261. propertyInfo.SetValue(cdc, propertyValue);
  21262. }
  21263. }
  21264. crmClients.Add(cdc);
  21265. }
  21266. return Ok(JsonView(new
  21267. {
  21268. fileCount = files.Count,
  21269. UploadCount = seedConter.Count,
  21270. ApiResult = clients,
  21271. CrmClients = crmClients
  21272. }));
  21273. }
  21274. #endregion
  21275. #region 团组倒推表
  21276. /// <summary>
  21277. /// 倒推表基础数据
  21278. /// Init
  21279. /// </summary>
  21280. /// <returns></returns>
  21281. [HttpPost]
  21282. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21283. public async Task<IActionResult> PostInvertedListInit()
  21284. {
  21285. var viewData = await _invertedListRep._Init();
  21286. if (viewData.Code != 0)
  21287. {
  21288. return Ok(JsonView(false, viewData.Msg));
  21289. }
  21290. return Ok(JsonView(viewData.Data));
  21291. }
  21292. /// <summary>
  21293. /// 倒推表
  21294. /// Info
  21295. /// </summary>
  21296. /// <param name="dto"></param>
  21297. /// <returns></returns>
  21298. [HttpPost]
  21299. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21300. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  21301. {
  21302. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  21303. if (viewData.Code != 0)
  21304. {
  21305. return Ok(JsonView(false, viewData.Msg));
  21306. }
  21307. return Ok(JsonView(viewData.Data));
  21308. }
  21309. /// <summary>
  21310. /// 倒推表
  21311. /// Create
  21312. /// </summary>
  21313. /// <param name="dto"></param>
  21314. /// <returns></returns>
  21315. [HttpPost]
  21316. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21317. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  21318. {
  21319. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  21320. if (viewData.Code != 0)
  21321. {
  21322. return Ok(JsonView(false, viewData.Msg));
  21323. }
  21324. return Ok(JsonView(viewData.Data));
  21325. }
  21326. /// <summary>
  21327. /// 倒推表
  21328. /// Update
  21329. /// </summary>
  21330. /// <param name="dto"></param>
  21331. /// <returns></returns>
  21332. [HttpPost]
  21333. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21334. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  21335. {
  21336. var viewData = await _invertedListRep._Update(dto);
  21337. if (viewData.Code != 0)
  21338. {
  21339. return Ok(JsonView(false, viewData.Msg));
  21340. }
  21341. return Ok(JsonView(viewData.Data));
  21342. }
  21343. /// <summary>
  21344. /// 倒推表
  21345. /// File Download
  21346. /// </summary>
  21347. /// <param name="dto"></param>
  21348. /// <returns></returns>
  21349. [HttpPost]
  21350. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21351. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  21352. {
  21353. var info2 = await _invertedListRep._Info(1, dto.DiId);
  21354. if (info2.Code != 0)
  21355. {
  21356. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  21357. }
  21358. var info1 = info2.Data as InvertedListInfoView;
  21359. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  21360. string teamName = "";
  21361. if (info != null) teamName = info.TeamName;
  21362. var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20250121.doc";
  21363. var doc = new Document();
  21364. var builder = new DocumentBuilder(doc);
  21365. #region old insert
  21366. ////载入模板
  21367. //var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20200617.doc";
  21368. //Document doc = new Document(tempPath);
  21369. //DocumentBuilder builder = new DocumentBuilder(doc);
  21370. //利用键值对存放数据
  21371. //Dictionary<string, string> dic = new Dictionary<string, string>();
  21372. //dic.Add("TeamName", teamName);
  21373. //dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  21374. //dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  21375. //dic.Add("BPRemark", info1.ApprovalDataRemark);
  21376. //dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  21377. //dic.Add("SQRemark", info1.ApprovalRemark);
  21378. //dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  21379. //dic.Add("CPJRemark", info1.IssueApprovalRemark);
  21380. ////dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  21381. ////dic.Add("HZRemark", info1.ApplyPassportRemark);
  21382. //dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  21383. //dic.Add("QZRemark", info1.VisaInformationRemark);
  21384. //dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  21385. //dic.Add("SQQZRemark", info1.SendVisaRemark);
  21386. //dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  21387. //dic.Add("CQRemark", info1.IssueVisaRemark);
  21388. //dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  21389. //dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  21390. //dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  21391. //dic.Add("SJRemark", info1.AirportdDropOffRemark);
  21392. //#region 填充word模板书签内容
  21393. //foreach (var key in dic.Keys)
  21394. //{
  21395. // builder.MoveToBookmark(key);
  21396. // builder.Write(dic[key]);
  21397. //}
  21398. //#endregion
  21399. #endregion
  21400. #region New Insert
  21401. string titleFont = $"仿宋",
  21402. contentFont = $"仿宋";
  21403. var fontColor = Color.FromArgb(64, 64, 64);
  21404. //设置标题 团组名称
  21405. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  21406. builder.Font.Name = titleFont;
  21407. builder.Font.Color = fontColor;
  21408. builder.Font.Size = 12;
  21409. builder.Font.Bold = true;
  21410. builder.Writeln(teamName);
  21411. //设置副标题 团组出访时间
  21412. builder.Font.Size = 12;
  21413. builder.Writeln("出发时间:" + info1.AirportdDropOffDt.ConvertToDatetime());
  21414. builder.Writeln();
  21415. var backgroundColor = Color.FromArgb(199, 199, 199);
  21416. var table = builder.StartTable();
  21417. builder.InsertCell();
  21418. builder.CellFormat.Shading.BackgroundPatternColor = backgroundColor;
  21419. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Single;
  21420. builder.CellFormat.Borders.LineWidth = 1;
  21421. builder.CellFormat.Borders.Color = Color.FromArgb(183, 183, 183);
  21422. table.FirstRow.FirstCell.CellFormat.Width = 20; // 单位为百分比
  21423. builder.RowFormat.Height = 40;
  21424. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  21425. builder.Font.Name = contentFont;
  21426. builder.Font.Size = 12;
  21427. builder.Font.Bold = true;
  21428. builder.Font.Color = fontColor;
  21429. builder.Write("时间");
  21430. builder.InsertCell();
  21431. table.FirstRow.FirstCell.CellFormat.Width = 30; // 单位为百分比
  21432. builder.Write("流程");
  21433. builder.InsertCell();
  21434. table.FirstRow.FirstCell.CellFormat.Width = 50; // 单位为百分比
  21435. builder.Write("说明");
  21436. builder.EndRow();
  21437. //报批资料准备
  21438. if (info1.IsSelectedAirportd)
  21439. {
  21440. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDataDt.ConvertToDatetime(), "报批资料准备", info1.ApprovalDataRemark);
  21441. }
  21442. //报批/提供送签资料
  21443. if (info1.IsSelectedApprovalData)
  21444. {
  21445. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDt.ConvertToDatetime(), "报批/提供送签资料", info1.ApprovalRemark);
  21446. }
  21447. //出批件护照办理
  21448. if (info1.IsSelectedIssueApproval)
  21449. {
  21450. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueApprovalDt.ConvertToDatetime(), "出批件\r\n护照办理", info1.IssueApprovalRemark);
  21451. }
  21452. //签证资料准备
  21453. if (info1.IsSelectedVisaInfo)
  21454. {
  21455. InvertedListFileDownloadSetRow(builder, contentFont, info1.VisaInformationDt.ConvertToDatetime(), "签证资料准备", info1.VisaInformationRemark);
  21456. }
  21457. //送签
  21458. if (info1.IsSelectedSendVisa)
  21459. {
  21460. InvertedListFileDownloadSetRow(builder, contentFont, info1.SendVisaDt.ConvertToDatetime(), "送签", info1.SendVisaRemark);
  21461. }
  21462. //出签
  21463. if (info1.IsSelectedIssueVisa)
  21464. {
  21465. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueVisaDt.ConvertToDatetime(), "出签", info1.IssueVisaRemark);
  21466. }
  21467. //机票
  21468. if (info1.IsSelectedAirTicket)
  21469. {
  21470. if (string.IsNullOrEmpty(info1.AirTicketDt)) info1.AirTicketDt = info1.IssueVisaDt;
  21471. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirTicketDt.ConvertToDatetime(), "机票", info1.AirTicketRemark);
  21472. }
  21473. //酒店
  21474. if (info1.IsSelectedHotel)
  21475. {
  21476. if (string.IsNullOrEmpty(info1.HotelDt)) info1.HotelDt = info1.IssueVisaDt;
  21477. InvertedListFileDownloadSetRow(builder, contentFont, info1.HotelDt.ConvertToDatetime(), "酒店", info1.HotelRemark);
  21478. }
  21479. //开行前会
  21480. if (info1.IsSelectedPreTripMeeting)
  21481. {
  21482. InvertedListFileDownloadSetRow(builder, contentFont, info1.PreTripMeetingDt.ConvertToDatetime(), "开行前会", info1.PreTripMeetingRemark);
  21483. }
  21484. //送机
  21485. if (info1.IsSelectedAirportdDropOff)
  21486. {
  21487. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirportdDropOffDt.ConvertToDatetime(), "送机", info1.AirportdDropOffRemark);
  21488. }
  21489. builder.EndTable();
  21490. //table.PreferredWidth = PreferredWidth.FromPercent(100.00);
  21491. //table.AutoFit(AutoFitBehavior.FixedColumnWidths);
  21492. for (int i = 0; i < table.Rows.Count; i++)
  21493. {
  21494. var row = table.Rows[i];
  21495. //设置宽度
  21496. row.Cells[0].CellFormat.Width = 20.00;
  21497. row.Cells[1].CellFormat.Width = 30.00;
  21498. row.Cells[2].CellFormat.Width = 50.00;
  21499. if (i != 0)
  21500. {
  21501. //边框设置
  21502. InvertedListFileDownloadSetBorders(row.Cells, 0);
  21503. InvertedListFileDownloadSetBorders(row.Cells, 1);
  21504. InvertedListFileDownloadSetBorders(row.Cells, 2);
  21505. }
  21506. }
  21507. #region 页脚插入图片
  21508. // 创建页脚
  21509. Aspose.Words.HeaderFooter footer = new Aspose.Words.HeaderFooter(doc, HeaderFooterType.FooterPrimary);
  21510. doc.FirstSection.HeadersFooters.Add(footer);
  21511. Paragraph para = new Paragraph(doc);
  21512. para.ParagraphFormat.Alignment = ParagraphAlignment.Right;
  21513. footer.AppendChild(para);
  21514. builder.MoveTo(para);
  21515. string imagePath = "./Images/FMGJ_Log.png";
  21516. builder.InsertImage(imagePath);
  21517. #endregion
  21518. #endregion
  21519. var fileDir = AppSettingsHelper.Get("WordBasePath");
  21520. string fileName = $"{teamName}团出行准备流程表{CommonFun.GUID}.doc";
  21521. string filePath = fileDir + $@"InvertedList/{fileName}";
  21522. doc.Save(filePath);
  21523. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  21524. return Ok(JsonView(true, "操作成功!", Url));
  21525. }
  21526. private void InvertedListFileDownloadSetRow(DocumentBuilder builder, string fontName, string dateTime, string content, string reamrk)
  21527. {
  21528. var fontColor = Color.FromArgb(64, 64, 64);
  21529. builder.InsertCell();
  21530. builder.CellFormat.Shading.BackgroundPatternColor = Color.Empty;
  21531. builder.RowFormat.Height = 40;
  21532. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  21533. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  21534. builder.Font.Name = fontName;
  21535. builder.Font.Size = 8;
  21536. builder.Font.Bold = true;
  21537. builder.Font.Color = fontColor;
  21538. builder.Write(dateTime);
  21539. builder.InsertCell();
  21540. builder.Font.Size = 9;
  21541. builder.Font.Bold = true;
  21542. builder.Font.Color = fontColor;
  21543. builder.Write(content);
  21544. builder.InsertCell();
  21545. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  21546. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  21547. builder.Font.Size = 9;
  21548. builder.Font.Bold = false;
  21549. builder.Font.Color = fontColor;
  21550. builder.Write(reamrk);
  21551. builder.EndRow();
  21552. }
  21553. private void InvertedListFileDownloadSetBorders(CellCollection cell, int index)
  21554. {
  21555. cell[index].CellFormat.Borders.Top.LineStyle = Aspose.Words.LineStyle.None;
  21556. cell[index].CellFormat.Borders.Bottom.LineStyle = Aspose.Words.LineStyle.None;
  21557. cell[index].CellFormat.Borders.Left.LineStyle = Aspose.Words.LineStyle.None;
  21558. cell[index].CellFormat.Borders.Right.LineStyle = Aspose.Words.LineStyle.None;
  21559. //cell[index].CellFormat.Borders.Horizontal.LineStyle = Aspose.Words.LineStyle.None;
  21560. //cell[index].CellFormat.Borders.Vertical.LineStyle = Aspose.Words.LineStyle.None;
  21561. }
  21562. #endregion
  21563. #region 会务倒推表
  21564. /// <summary>
  21565. /// 会务倒推表
  21566. /// Init
  21567. /// </summary>
  21568. /// <returns></returns>
  21569. [HttpPost]
  21570. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21571. public async Task<IActionResult> InforRetrogressTableInit()
  21572. {
  21573. var groupData = await _groupRepository.PostShareGroupInfos(1);
  21574. if (groupData.Code == 0) return Ok(JsonView(groupData.Data));
  21575. return Ok(JsonView(false, groupData.Msg));
  21576. }
  21577. /// <summary>
  21578. /// 会务倒推表
  21579. /// ExcelDownload
  21580. /// </summary>
  21581. /// <param name="dto"></param>
  21582. /// <returns></returns>
  21583. [HttpPost]
  21584. [ApiLog("InforRetrogressTable", OperationEnum.Download)]
  21585. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21586. public async Task<IActionResult> InforRetrogressTableFileDownload(InforRetrogressTableFileDownloadDto dto)
  21587. {
  21588. var validator = new InforRetrogressTableFileDownloadDtoValidator();
  21589. var validatorRes = await validator.ValidateAsync(dto);
  21590. if (!validatorRes.IsValid)
  21591. {
  21592. StringBuilder sb = new StringBuilder();
  21593. foreach (var item in validatorRes.Errors)
  21594. {
  21595. sb.AppendLine(item.ErrorMessage);
  21596. }
  21597. return Ok(JsonView(false, sb.ToString()));
  21598. }
  21599. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.GroupId);
  21600. if (groupInfo == null) return Ok(JsonView(false, $"该团组信息未填写!"));
  21601. //时间根据团组出访日期-接团录入日期的天数来判断用哪个模板
  21602. var days = groupInfo.VisitDate.Subtract(groupInfo.CreateTime).Days;
  21603. #region Excel
  21604. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  21605. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  21606. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "InforRetrogressTable/";
  21607. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "InforRetrogressTable/";
  21608. var fileNamePrefix = string.Empty;
  21609. if (days >= 30)
  21610. {
  21611. tempPath += $"会务工作倒推进度表(30天).xlsx";
  21612. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(30天)";
  21613. }
  21614. else if (days < 30 && days > 7)
  21615. {
  21616. tempPath += $"会务工作倒推进度表(15天).xlsx";
  21617. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(15天)";
  21618. }
  21619. else if (days <= 7)
  21620. {
  21621. tempPath += $"会务工作倒推进度表(7天).xlsx";
  21622. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(7天)";
  21623. }
  21624. var fileName = $"{fileNamePrefix}{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  21625. fileName = CommonFun.ValidFileName(fileName);
  21626. //载入模板
  21627. WorkbookDesigner designer = new WorkbookDesigner();
  21628. designer.Workbook = new Workbook(tempPath);
  21629. designer.Process();
  21630. if (!Directory.Exists(savePath))
  21631. {
  21632. Directory.CreateDirectory(savePath);
  21633. }
  21634. string serverPath = $"{savePath}{fileName}";
  21635. designer.Workbook.Save(serverPath);
  21636. string rst = $"{servicePath}{ftpPath}{fileName}";
  21637. #endregion
  21638. return Ok(JsonView(new { url = rst }));
  21639. }
  21640. #endregion
  21641. #region 三公签证费用(签证费、代办费)
  21642. /// <summary>
  21643. /// 三公签证费用(签证费、代办费)
  21644. /// List
  21645. /// </summary>
  21646. /// <returns></returns>
  21647. [HttpPost]
  21648. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21649. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  21650. {
  21651. return Ok(await _visaFeeInfoRep.List(_dto.PortType, _dto.DiId));
  21652. }
  21653. /// <summary>
  21654. /// 三公签证费用(签证费、代办费)
  21655. /// Add Or Update
  21656. /// </summary>
  21657. /// <returns></returns>
  21658. [HttpPost]
  21659. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21660. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  21661. {
  21662. var _view = await _visaFeeInfoRep.Update(_dto);
  21663. if (_view.Code != 0)
  21664. {
  21665. return Ok(JsonView(false, _view.Msg));
  21666. }
  21667. return Ok(JsonView(true, _view.Msg));
  21668. }
  21669. #endregion
  21670. #region 酒店询价
  21671. /// <summary>
  21672. /// 酒店询价
  21673. /// Init
  21674. /// </summary>
  21675. /// <returns></returns>
  21676. [HttpPost]
  21677. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21678. public async Task<IActionResult> PostHotelInquiryInit()
  21679. {
  21680. var res = await _hotelInquiryRep._Init();
  21681. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  21682. return Ok(JsonView(true, res.Msg, res.Data));
  21683. }
  21684. /// <summary>
  21685. /// 酒店询价
  21686. /// page Item
  21687. /// </summary>
  21688. /// <param name="_dto"></param>
  21689. /// <returns></returns>
  21690. [HttpPost]
  21691. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21692. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  21693. {
  21694. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  21695. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  21696. var view = res.Data as PageDataViewBase;
  21697. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  21698. }
  21699. /// <summary>
  21700. /// 酒店询价
  21701. /// info
  21702. /// </summary>
  21703. /// <param name="_dto"></param>
  21704. /// <returns></returns>
  21705. [HttpPost]
  21706. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21707. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  21708. {
  21709. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  21710. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  21711. return Ok(JsonView(true, res.Msg, res.Data));
  21712. }
  21713. /// <summary>
  21714. /// 酒店询价
  21715. /// Add Or Edit
  21716. /// </summary>
  21717. /// <param name="_dto"></param>
  21718. /// <returns></returns>
  21719. [HttpPost]
  21720. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21721. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  21722. {
  21723. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  21724. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  21725. return Ok(JsonView(true, res.Msg, res.Data));
  21726. }
  21727. /// <summary>
  21728. /// 酒店询价
  21729. /// Del
  21730. /// </summary>
  21731. /// <param name="_dto"></param>
  21732. /// <returns></returns>
  21733. [HttpPost]
  21734. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21735. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  21736. {
  21737. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  21738. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  21739. return Ok(JsonView(true, res.Msg, res.Data));
  21740. }
  21741. #endregion
  21742. #region 下载匹配op行程单
  21743. /// <summary>
  21744. /// 匹配op行程单
  21745. /// Init
  21746. /// </summary>
  21747. /// <param name="dto">团组列表请求dto</param>
  21748. /// <returns></returns>
  21749. [HttpPost]
  21750. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21751. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  21752. {
  21753. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  21754. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  21755. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  21756. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  21757. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  21758. .Where(it => it.IsDel == 0)
  21759. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  21760. .OrderByDescending(it => it.VisitStartDate)
  21761. .ToList();
  21762. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  21763. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  21764. var diids = groupInfos.Select(it => it.Id).ToList();
  21765. List<string> countrys = new List<string>();
  21766. foreach (var item in country)
  21767. {
  21768. var data = _groupRepository.FormartTeamName(item);
  21769. var dataArray = _groupRepository.GroupSplitCountry(data);
  21770. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  21771. }
  21772. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  21773. List<string> areaArray = new List<string>(); //GetGroupCityLine
  21774. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  21775. foreach (var item in areaItem)
  21776. {
  21777. string areaStr = item.Value;
  21778. if (!string.IsNullOrEmpty(areaStr))
  21779. {
  21780. string[] str1 = areaStr.Split("-");
  21781. if (str1.Length > 0)
  21782. {
  21783. areaArray.AddRange(str1);
  21784. }
  21785. }
  21786. }
  21787. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  21788. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  21789. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  21790. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  21791. .ToList();
  21792. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  21793. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  21794. .Where(it => countriesIds.Contains(it.Id))
  21795. .Select(it => new { it.Id, Name = it.Name_CN })
  21796. .ToList();
  21797. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  21798. .Select(it => it.TeamName).ToList();
  21799. stopwatch.Stop();
  21800. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  21801. }
  21802. ///// <summary>
  21803. ///// 匹配op行程单
  21804. ///// Init 查询区域数据
  21805. ///// </summary>
  21806. ///// <param name="dto">团组列表请求dto</param>
  21807. ///// <returns></returns>
  21808. //[HttpPost]
  21809. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21810. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  21811. //{
  21812. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  21813. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  21814. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  21815. // if (string.IsNullOrEmpty(countriesDataStr))
  21816. // {
  21817. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  21818. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  21819. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  21820. // }
  21821. // else
  21822. // {
  21823. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  21824. // }
  21825. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  21826. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  21827. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  21828. // List<dynamic> childList = new List<dynamic>();
  21829. // int parentId = dto.CountriesId;
  21830. // if (provinceData.Count > 1)
  21831. // {
  21832. // foreach (var item1 in provinceData)
  21833. // {
  21834. // List<dynamic> childList1 = new List<dynamic>();
  21835. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  21836. // foreach (var item2 in citiesData1)
  21837. // {
  21838. // List<dynamic> childList2 = new List<dynamic>();
  21839. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  21840. // foreach (var item3 in countiesData1)
  21841. // {
  21842. // childList2.Add(new
  21843. // {
  21844. // id = item3.Id,
  21845. // parentId = item2.Id,
  21846. // level = "district",
  21847. // name = item3.Name_CN,
  21848. // });
  21849. // }
  21850. // childList1.Add(new
  21851. // {
  21852. // id = item2.Id,
  21853. // parentId = item1.Id,
  21854. // level = "city",
  21855. // name = item2.Name_CN,
  21856. // childList = childList2
  21857. // });
  21858. // }
  21859. // childList.Add(new
  21860. // {
  21861. // id = item1.Id,
  21862. // parentId = parentId,
  21863. // level = "province",
  21864. // name = item1.Name_CN,
  21865. // childList = childList1
  21866. // });
  21867. // }
  21868. // //城市
  21869. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  21870. // foreach (var item2 in citiesData2)
  21871. // {
  21872. // List<dynamic> childList22 = new List<dynamic>();
  21873. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  21874. // foreach (var item3 in countiesData1)
  21875. // {
  21876. // childList22.Add(new
  21877. // {
  21878. // id = item3.Id,
  21879. // parentId = item2.Id,
  21880. // level = "district",
  21881. // name = item3.Name_CN,
  21882. // });
  21883. // }
  21884. // childList.Add(new
  21885. // {
  21886. // id = item2.Id,
  21887. // parentId = parentId,
  21888. // level = "city",
  21889. // name = item2.Name_CN,
  21890. // childList = childList22
  21891. // });
  21892. // }
  21893. // }
  21894. // else
  21895. // {
  21896. // foreach (var item2 in citiesData)
  21897. // {
  21898. // string cname = item2.Name_CN;
  21899. // List<dynamic> childList1 = new List<dynamic>();
  21900. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  21901. // foreach (var item3 in countiesData1)
  21902. // {
  21903. // childList1.Add(new
  21904. // {
  21905. // Id = item3.Id,
  21906. // parentId = item2.Id,
  21907. // level = "district",
  21908. // name = item3.Name_CN
  21909. // });
  21910. // }
  21911. // childList.Add(new
  21912. // {
  21913. // id = item2.Id,
  21914. // parentId = parentId,
  21915. // level = "city",
  21916. // name = item2.Name_CN,
  21917. // childList = childList1
  21918. // });
  21919. // }
  21920. // }
  21921. // stopwatch.Stop();
  21922. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  21923. //}
  21924. /// <summary>
  21925. /// 匹配op行程单
  21926. /// 接团信息列表 Page
  21927. /// </summary>
  21928. /// <param name="dto">团组列表请求dto</param>
  21929. /// <returns></returns>
  21930. [HttpPost]
  21931. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21932. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  21933. {
  21934. var swatch = new Stopwatch();
  21935. swatch.Start();
  21936. #region 参数验证
  21937. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  21938. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  21939. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  21940. #region 页面操作权限验证
  21941. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  21942. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  21943. #endregion
  21944. #endregion
  21945. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  21946. {
  21947. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  21948. //string sqlWhere = "";
  21949. if (!string.IsNullOrEmpty(dto.Country))
  21950. {
  21951. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  21952. }
  21953. if (!string.IsNullOrEmpty(dto.Area))
  21954. {
  21955. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  21956. }
  21957. if (!string.IsNullOrEmpty(dto.TeamName))
  21958. {
  21959. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  21960. }
  21961. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  21962. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  21963. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  21964. swatch.Stop();
  21965. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  21966. }
  21967. else
  21968. {
  21969. return Ok(JsonView(false, "查询失败"));
  21970. }
  21971. }
  21972. /// <summary>
  21973. /// 匹配op行程单
  21974. /// 行程单下载
  21975. /// </summary>
  21976. /// <param name="dto">团组列表请求dto</param>
  21977. /// <returns></returns>
  21978. [HttpPost]
  21979. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21980. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  21981. {
  21982. #region 参数验证
  21983. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  21984. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  21985. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  21986. #region 页面操作权限验证
  21987. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  21988. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  21989. #endregion
  21990. #endregion
  21991. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  21992. {
  21993. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  21994. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  21995. }
  21996. else
  21997. {
  21998. return Ok(JsonView(false, "下载失败!"));
  21999. }
  22000. }
  22001. #endregion
  22002. #region 国家信息 数据 注释
  22003. //[HttpPost]
  22004. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  22005. //{
  22006. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  22007. // foreach (var item in dto)
  22008. // {
  22009. // infos.Add(new Grp_GroupsTaskAssignment()
  22010. // {
  22011. // DIId = item,
  22012. // CTId = 82,
  22013. // UId = 248,
  22014. // IsEnable = 1,
  22015. // CreateUserId = 233,
  22016. // CreateTime = DateTime.Now,
  22017. // IsDel = 0
  22018. // });
  22019. // infos.Add(new Grp_GroupsTaskAssignment()
  22020. // {
  22021. // DIId = item,
  22022. // CTId = 82,
  22023. // UId = 286,
  22024. // IsEnable = 1,
  22025. // CreateUserId = 233,
  22026. // CreateTime = DateTime.Now,
  22027. // IsDel = 0
  22028. // });
  22029. // }
  22030. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  22031. // return Ok("操作成功");
  22032. //}
  22033. //public class paramJsonDto
  22034. //{
  22035. // public List<CountriesInfo> str { get; set; }
  22036. //}
  22037. //[HttpPost]
  22038. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  22039. //{
  22040. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  22041. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  22042. // List<Sys_Cities> cities = new List<Sys_Cities>();
  22043. // List<Sys_Cities> districts = new List<Sys_Cities>();
  22044. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  22045. // _sqlSugar.BeginTran();
  22046. // int countitiesIndex = 0;
  22047. // foreach (var item in dto.str)
  22048. // {
  22049. // dynamic data = item.c;
  22050. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  22051. // if (data != null)
  22052. // {
  22053. // countitiesIndex++;
  22054. // foreach (var item1 in data)
  22055. // {
  22056. // string cnname = item1.cn;
  22057. // string enname = item1.en;
  22058. // Sys_Cities provinceInfo = new Sys_Cities()
  22059. // {
  22060. // CountriesId = countriesId,
  22061. // Name_CN = cnname,
  22062. // Name_EN = enname,
  22063. // ParentId = 0,
  22064. // IsCapital = 1,
  22065. // CreateUserId = 208,
  22066. // CreateTime = DateTime.Now,
  22067. // IsDel = 0
  22068. // };
  22069. // if (item1.lv == "province") //省份
  22070. // {
  22071. // provinceInfo.Level = 1;
  22072. // int provinceId = 0;
  22073. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  22074. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  22075. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  22076. // var data1 = item1.c;
  22077. // foreach (var item2 in data1)
  22078. // {
  22079. // if (item2.lv == "city")
  22080. // {
  22081. // string citycnname = item2.cn;
  22082. // string cityenname = item2.en;
  22083. // Sys_Cities cityInfo = new Sys_Cities()
  22084. // {
  22085. // CountriesId = countriesId,
  22086. // ParentId = provinceId,
  22087. // Level = 2,
  22088. // Name_CN = citycnname,
  22089. // Name_EN = cityenname,
  22090. // IsCapital = 1,
  22091. // CreateUserId = 208,
  22092. // CreateTime = DateTime.Now,
  22093. // IsDel = 0
  22094. // };
  22095. // if (item2.c != null)
  22096. // {
  22097. // int cityId = 0;
  22098. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  22099. // if (citiesInfo != null) cityId = citiesInfo.Id;
  22100. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  22101. // foreach (var item3 in item2.c)
  22102. // {
  22103. // if (item3.lv == "district")
  22104. // {
  22105. // var districtInfo = new Sys_Cities()
  22106. // {
  22107. // CountriesId = countriesId,
  22108. // Name_CN = item3.cn,
  22109. // Name_EN = item3.en,
  22110. // Level = 3,
  22111. // ParentId = cityId,
  22112. // IsCapital = 1,
  22113. // CreateUserId = 208,
  22114. // CreateTime = DateTime.Now,
  22115. // IsDel = 0
  22116. // };
  22117. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  22118. // //{
  22119. // districts.Add(districtInfo);
  22120. // //}
  22121. // }
  22122. // }
  22123. // }
  22124. // else
  22125. // {
  22126. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  22127. // //{
  22128. // cities.Add(cityInfo);
  22129. // //}
  22130. // }
  22131. // }
  22132. // }
  22133. // }
  22134. // else if (item1.lv == "city")//城市
  22135. // {
  22136. // provinceInfo.Level = 2;
  22137. // if (item1.c != null)
  22138. // {
  22139. // int cityId = 0;
  22140. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  22141. // if (citiesInfo != null) cityId = citiesInfo.Id;
  22142. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  22143. // foreach (var item3 in item1.c)
  22144. // {
  22145. // if (item3.lv == "district")
  22146. // {
  22147. // var districtInfo = new Sys_Cities()
  22148. // {
  22149. // CountriesId = countriesId,
  22150. // Name_CN = item3.cn,
  22151. // Name_EN = item3.en,
  22152. // Level = 3,
  22153. // ParentId = cityId,
  22154. // IsCapital = 1,
  22155. // CreateUserId = 208,
  22156. // CreateTime = DateTime.Now,
  22157. // IsDel = 0
  22158. // };
  22159. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  22160. // //{
  22161. // districts.Add(districtInfo);
  22162. // //}
  22163. // }
  22164. // }
  22165. // }
  22166. // else
  22167. // {
  22168. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  22169. // //{
  22170. // cities.Add(provinceInfo);
  22171. // //}
  22172. // }
  22173. // }
  22174. // }
  22175. // }
  22176. // }
  22177. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  22178. // cities = cities.Distinct().ToList();
  22179. // districts = districts.Distinct().ToList();
  22180. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  22181. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  22182. // cities.AddRange(districts);
  22183. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  22184. // //_sqlSugar.RollbackTran();
  22185. // _sqlSugar.CommitTran();
  22186. // return Ok(JsonView(false, "操作成功!"));
  22187. //}
  22188. //[HttpPost]
  22189. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  22190. //{
  22191. // List<CountitiesInfo> infos = dto.MyProperty;
  22192. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  22193. // _sqlSugar.BeginTran();
  22194. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  22195. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  22196. // foreach (var item in infos)
  22197. // {
  22198. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  22199. // if (countryInfo != null)
  22200. // {
  22201. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  22202. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  22203. // if (cityInfo1 != null)
  22204. // {
  22205. // cityInfo1.IsCapital = 0;
  22206. // cityInfos.Add(cityInfo1);
  22207. // }
  22208. // }
  22209. // }
  22210. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  22211. // .UpdateColumns(it => it.IsCapital)
  22212. // .WhereColumns(it => it.Id)
  22213. // .ExecuteCommand();
  22214. // //_sqlSugar.RollbackTran();
  22215. // _sqlSugar.CommitTran();
  22216. // return Ok(JsonView(false, "操作成功!"));
  22217. //}
  22218. //public class CounrtiesDto
  22219. //{
  22220. // public List<CountitiesInfo> MyProperty { get; set; }
  22221. //}
  22222. //public class CountitiesInfo
  22223. //{
  22224. // /// <summary>
  22225. // /// 圣约翰
  22226. // /// </summary>
  22227. // public string capital_name_chinese { get; set; }
  22228. // /// <summary>
  22229. // ///
  22230. // /// </summary>
  22231. // public string capital_name { get; set; }
  22232. // /// <summary>
  22233. // ///
  22234. // /// </summary>
  22235. // public string country_type { get; set; }
  22236. // /// <summary>
  22237. // /// 安提瓜和巴布达
  22238. // /// </summary>
  22239. // public string country_name_chinese { get; set; }
  22240. // /// <summary>
  22241. // /// 安提瓜和巴布达
  22242. // /// </summary>
  22243. // public string country_name_chinese_short { get; set; }
  22244. // /// <summary>
  22245. // /// 安提瓜和巴布达
  22246. // /// </summary>
  22247. // public string country_name_chinese_UN { get; set; }
  22248. // /// <summary>
  22249. // ///
  22250. // /// </summary>
  22251. // public string country_name_english_abbreviation { get; set; }
  22252. // /// <summary>
  22253. // ///
  22254. // /// </summary>
  22255. // public string country_name_english_formal { get; set; }
  22256. // /// <summary>
  22257. // ///
  22258. // /// </summary>
  22259. // public string country_name_english_UN { get; set; }
  22260. // /// <summary>
  22261. // ///
  22262. // /// </summary>
  22263. // public string continent_name { get; set; }
  22264. // /// <summary>
  22265. // ///
  22266. // /// </summary>
  22267. // public string subregion_name { get; set; }
  22268. // /// <summary>
  22269. // ///
  22270. // /// </summary>
  22271. // public string country_code2 { get; set; }
  22272. // /// <summary>
  22273. // ///
  22274. // /// </summary>
  22275. // public string country_code3 { get; set; }
  22276. // /// <summary>
  22277. // ///
  22278. // /// </summary>
  22279. // public string phone_code { get; set; }
  22280. //}
  22281. //public class CountriesInfo : BasicInfo
  22282. //{
  22283. // public List<CitiesInfo> c { get; set; }
  22284. //}
  22285. //public class CitiesInfo : BasicInfo
  22286. //{
  22287. // public List<AreaInfo> c { get; set; }
  22288. //}
  22289. //public class AreaInfo : BasicInfo
  22290. //{
  22291. // public List<AreaInfo> c { get; set; }
  22292. //}
  22293. //public class BasicInfo
  22294. //{
  22295. // public string code { get; set; }
  22296. // public string cn { get; set; }
  22297. // public string lv { get; set; }
  22298. // public string en { get; set; }
  22299. //}
  22300. #endregion
  22301. #region 查看邀请方
  22302. /// <summary>
  22303. /// 查看邀请方
  22304. /// 邀请方信息 Init
  22305. /// </summary>
  22306. /// <param name="dto"></param>
  22307. /// <returns></returns>
  22308. [HttpPost]
  22309. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22310. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  22311. {
  22312. string sqlWhere = string.Empty;
  22313. if (!string.IsNullOrEmpty(dto.Search))
  22314. {
  22315. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  22316. }
  22317. string sql = string.Format($@"Select
  22318. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  22319. Id,
  22320. UnitName
  22321. From Res_InvitationOfficialActivityData
  22322. Where IsDel = 0
  22323. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  22324. RefAsync<int> total = 0;
  22325. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  22326. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  22327. }
  22328. /// <summary>
  22329. /// 查看邀请方
  22330. /// 国家信息 Init
  22331. /// </summary>
  22332. /// <param name="dto"></param>
  22333. /// <returns></returns>
  22334. [HttpPost]
  22335. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22336. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  22337. {
  22338. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  22339. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  22340. var diids = groupInfos.Select(it => it.Id).ToList();
  22341. List<string> countrys = new List<string>();
  22342. foreach (var item in country)
  22343. {
  22344. var data = _groupRepository.FormartTeamName(item);
  22345. var dataArray = _groupRepository.GroupSplitCountry(data);
  22346. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  22347. }
  22348. countrys = countrys.Distinct().ToList();
  22349. for (int i = 0; i < countrys.Count; i++)
  22350. {
  22351. string item = countrys[i];
  22352. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  22353. {
  22354. countrys.Remove(item);
  22355. i--;
  22356. }
  22357. }
  22358. RefAsync<int> total = 0;
  22359. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  22360. .Where(it => countrys.Contains(it.Name_CN))
  22361. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  22362. .Select(it => new { id = it.Id, name = it.Name_CN })
  22363. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  22364. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  22365. }
  22366. /// <summary>
  22367. /// 查看邀请方
  22368. /// 城市信息 Init
  22369. /// </summary>
  22370. /// <param name="dto"></param>
  22371. /// <returns></returns>
  22372. [HttpPost]
  22373. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22374. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  22375. {
  22376. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  22377. RefAsync<int> total = 0;
  22378. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  22379. .Where(it => it.CountriesId == dto.CountiesId)
  22380. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  22381. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  22382. .Select(it => new { id = it.Id, name = it.Name_CN })
  22383. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  22384. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  22385. }
  22386. /// <summary>
  22387. /// 查看邀请方
  22388. /// 团组名称 Init
  22389. /// </summary>
  22390. /// <param name="dto"></param>
  22391. /// <returns></returns>
  22392. [HttpPost]
  22393. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22394. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  22395. {
  22396. var watch = new Stopwatch();
  22397. watch.Start();
  22398. RefAsync<int> total = 0;
  22399. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  22400. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  22401. .Where((oa, di) => oa.IsDel == 0)
  22402. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  22403. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  22404. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  22405. .Distinct()
  22406. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  22407. watch.Stop();
  22408. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  22409. }
  22410. /// <summary>
  22411. /// 查看邀请方
  22412. /// 团组 & 邀请方信息
  22413. /// </summary>
  22414. /// <param name="dto"></param>
  22415. /// <returns></returns>
  22416. [HttpPost]
  22417. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22418. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  22419. {
  22420. var watch = new Stopwatch();
  22421. watch.Start();
  22422. RefAsync<int> total = 0;
  22423. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  22424. .AS("Grp_DelegationInfo")
  22425. .Includes(x => x.InvitingInfos)
  22426. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  22427. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  22428. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  22429. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  22430. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  22431. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  22432. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  22433. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  22434. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  22435. infos.ForEach(x =>
  22436. {
  22437. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  22438. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  22439. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  22440. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  22441. });
  22442. watch.Stop();
  22443. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  22444. }
  22445. #endregion
  22446. #region 报批行程
  22447. /// <summary>
  22448. /// 报批行程初始化
  22449. /// </summary>
  22450. /// <param name="dto"></param>
  22451. /// <returns></returns>
  22452. [HttpPost]
  22453. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  22454. {
  22455. const int chiNumber = 5;
  22456. var jw = JsonView(false);
  22457. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  22458. var group = groupList.First();
  22459. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  22460. group = groupList.First(x => x.Id == diid);
  22461. var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  22462. .Where(x => x.DiId == diid && x.IsDel == 0)
  22463. .ToArray();
  22464. var count = 1;
  22465. foreach (var item in blackCodeList)
  22466. {
  22467. if (string.IsNullOrWhiteSpace(item.Title))
  22468. {
  22469. item.Title = "未设置名称数据" + count;
  22470. }
  22471. count++;
  22472. }
  22473. ;
  22474. if (group == null)
  22475. {
  22476. jw.Msg = "暂无团组!";
  22477. return Ok(jw);
  22478. }
  22479. var data = new
  22480. {
  22481. groupList = groupList.Select(x => new
  22482. {
  22483. x.TeamName,
  22484. x.Id
  22485. }),
  22486. content = new ArrayList(),
  22487. groupInfo = new
  22488. {
  22489. group.VisitDays,
  22490. group.TourCode,
  22491. group.VisitPNumber,
  22492. group.TeamName,
  22493. group.Id,
  22494. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  22495. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd"),
  22496. group.ClientUnit
  22497. },
  22498. blackCodeList = blackCodeList.Select(x => new
  22499. {
  22500. x.Title,
  22501. x.Id
  22502. }),
  22503. FileTempList = new ArrayList()
  22504. {
  22505. new { Index = 1,FileName = "旧模板" },
  22506. new { Index = 2,FileName = "省外办" },
  22507. new { Index = 3,FileName = "市外办" },
  22508. }
  22509. };
  22510. var resultArr = new ArrayList();
  22511. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  22512. #region 默认不生成行程
  22513. //if (content.Count == 0)
  22514. //{
  22515. // var stay = "-";
  22516. // var cityPath = "-";
  22517. // var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  22518. // .Where(x => x.DiId == diid && x.IsDel == 0)
  22519. // .ToList();
  22520. // //添加城市路径以及住宿地
  22521. // //黑屏代码数据
  22522. // DataTable dtBlack = GeneralMethod.GetTableByBlackCodeById(blackCodeList.FirstOrDefault());
  22523. // if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  22524. // {
  22525. // jw = JsonView(true, "黑屏代码有误!", data);
  22526. // return Ok(jw);
  22527. // }
  22528. // data = data with
  22529. // {
  22530. // blackCodeList = new ArrayList(blackCodeList.Select(x => new
  22531. // {
  22532. // x.Title,
  22533. // x.Id,
  22534. // }).ToArray())
  22535. // };
  22536. // foreach (DataRow row in dtBlack.Rows)
  22537. // {
  22538. // if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  22539. // {
  22540. // jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  22541. // return Ok(jw);
  22542. // }
  22543. // }
  22544. // //黑屏代码获取时间区间
  22545. // var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  22546. // string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  22547. // _sqlSugar.BeginTran();
  22548. // for (int i = 0; i < timeArr.Count; i++)
  22549. // {
  22550. // stay = "-";
  22551. // cityPath = "-";
  22552. // DateTime NewData = DateTime.Parse(timeArr[i]);
  22553. // string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  22554. // Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  22555. // var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  22556. // if (tbSelect.Length > 0)
  22557. // {
  22558. // List<string> threeCodeStr = new List<string>();
  22559. // foreach (var item in tbSelect)
  22560. // {
  22561. // var threeCode = item["Three"].ToString() ?? "";
  22562. // if (threeCode.Length == 6)
  22563. // {
  22564. // var start = threeCode.Substring(0, 3);
  22565. // var end = threeCode.Substring(3, 3);
  22566. // if (threeCodeStr.Count == 0)
  22567. // {
  22568. // threeCodeStr.Add(start);
  22569. // threeCodeStr.Add(end);
  22570. // }
  22571. // else
  22572. // {
  22573. // if (threeCodeStr[threeCodeStr.Count - 1] == start)
  22574. // {
  22575. // threeCodeStr.Add(end);
  22576. // }
  22577. // else
  22578. // {
  22579. // threeCodeStr.Add(start);
  22580. // threeCodeStr.Add(end);
  22581. // }
  22582. // }
  22583. // }
  22584. // }
  22585. // var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  22586. // var last = threeCodeStr.Last();
  22587. // foreach (var item in threeCodeStr)
  22588. // {
  22589. // cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  22590. // if (item.Equals(last))
  22591. // {
  22592. // stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  22593. // }
  22594. // }
  22595. // cityPath = cityPath.Trim('-');
  22596. // }
  22597. // appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  22598. // appro.Diid = diid ?? -1;
  22599. // var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  22600. // appro.Id = thisId;
  22601. // appro.CreateUserId = dto.UserId;
  22602. // appro.CreateTime = DateTime.Now;
  22603. // content.Add(appro);
  22604. // }
  22605. // _sqlSugar.CommitTran();
  22606. //}
  22607. #endregion
  22608. foreach (var x in content)
  22609. {
  22610. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  22611. if (chiList.Count < chiNumber)
  22612. {
  22613. for (int i = chiList.Count; i < chiNumber; i++)
  22614. {
  22615. chiList.Add(new Grp_ApprovalTravelDetails());
  22616. }
  22617. }
  22618. resultArr.Add(new
  22619. {
  22620. x.Id,
  22621. x.Date,
  22622. x.Diid,
  22623. chiList = chiList.Select(x1 => new
  22624. {
  22625. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  22626. x1.Details,
  22627. x1.ParentId,
  22628. x1.Id
  22629. })
  22630. });
  22631. }
  22632. data = data with
  22633. {
  22634. content = resultArr,
  22635. };
  22636. jw = JsonView(true, "获取成功!", data);
  22637. return Ok(jw);
  22638. }
  22639. /// <summary>
  22640. /// 报批行程删除
  22641. /// </summary>
  22642. /// <param name="dto"></param>
  22643. /// <returns></returns>
  22644. [HttpPost]
  22645. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  22646. {
  22647. var jw = JsonView(false);
  22648. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  22649. if (group == null)
  22650. {
  22651. jw.Msg = "团组参数有误!";
  22652. return Ok(jw);
  22653. }
  22654. try
  22655. {
  22656. _sqlSugar.BeginTran();
  22657. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  22658. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  22659. {
  22660. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  22661. DeleteUserId = dto.uesrId,
  22662. IsDel = 1
  22663. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  22664. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  22665. {
  22666. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  22667. DeleteUserId = dto.uesrId,
  22668. IsDel = 1
  22669. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  22670. _sqlSugar.CommitTran();
  22671. jw = JsonView(true, "删除成功");
  22672. }
  22673. catch (Exception ex)
  22674. {
  22675. jw = JsonView(false, ex.Message);
  22676. }
  22677. return Ok(jw);
  22678. }
  22679. /// <summary>
  22680. /// 报批行程保存
  22681. /// </summary>
  22682. /// <param name="dto"></param>
  22683. /// <returns></returns>
  22684. [HttpPost]
  22685. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  22686. {
  22687. var jw = JsonView(false);
  22688. var Find = dto.Arr.Find(x => x.id == 0);
  22689. if (Find != null)
  22690. {
  22691. jw.Msg = "生成的ID为0!";
  22692. return Ok(jw);
  22693. }
  22694. foreach (var item in dto.Arr)
  22695. {
  22696. foreach (var chi in item.chiList)
  22697. {
  22698. if (chi.parentId == 0)
  22699. {
  22700. chi.parentId = item.id;
  22701. }
  22702. }
  22703. }
  22704. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  22705. _sqlSugar.BeginTran();
  22706. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  22707. {
  22708. var parentIds = dto.Arr.Select(x => x.id).ToList();
  22709. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  22710. {
  22711. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  22712. DeleteUserId = dto.UserId,
  22713. IsDel = 1
  22714. }).ExecuteCommand();
  22715. }
  22716. try
  22717. {
  22718. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  22719. {
  22720. CreateTime = DateTime.Now,
  22721. CreateUserId = dto.UserId,
  22722. Details = x.details,
  22723. ParentId = x.parentId,
  22724. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  22725. Remark = "",
  22726. IsDel = 0
  22727. }).ToList()).ExecuteCommand();
  22728. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  22729. {
  22730. Id = x.id,
  22731. Details = x.details,
  22732. ParentId = x.parentId,
  22733. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  22734. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  22735. {
  22736. Details = x.Details,
  22737. ParentId = x.ParentId,
  22738. Time = x.Time
  22739. }).ExecuteCommand();
  22740. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  22741. {
  22742. Id = x.id,
  22743. Date = x.date,
  22744. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  22745. {
  22746. Date = x.Date
  22747. }).ExecuteCommand();
  22748. _sqlSugar.CommitTran();
  22749. jw = JsonView(true, "保存成功!");
  22750. }
  22751. catch (Exception ex)
  22752. {
  22753. _sqlSugar.RollbackTran();
  22754. jw = JsonView(false, "保存失败!" + ex.Message);
  22755. }
  22756. return Ok(jw);
  22757. }
  22758. /// <summary>
  22759. /// 报批行程生成
  22760. /// </summary>
  22761. /// <param name="dto"></param>
  22762. /// <returns></returns>
  22763. [HttpPost]
  22764. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  22765. {
  22766. var jw = JsonView(false);
  22767. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  22768. if (group == null)
  22769. {
  22770. jw.Msg = "暂无该团组!";
  22771. return Ok(jw);
  22772. }
  22773. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().First(x => x.Id == dto.BlackCodeId && x.IsDel == 0);
  22774. //黑屏代码数据
  22775. DataTable dtBlack = GeneralMethod.GetTableByBlackCodeBySingle(blackCode);
  22776. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  22777. {
  22778. jw.Msg = "黑屏代码有误!";
  22779. return Ok(jw);
  22780. }
  22781. foreach (DataRow row in dtBlack.Rows)
  22782. {
  22783. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  22784. {
  22785. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  22786. return Ok(jw);
  22787. }
  22788. }
  22789. //var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  22790. var resultArr = new ArrayList();
  22791. //if (officialActivitiesArr.Count == 0)
  22792. //{
  22793. // jw.Msg = "暂无公务出访信息!";
  22794. // return Ok(jw);
  22795. //}
  22796. try
  22797. {
  22798. _sqlSugar.BeginTran();
  22799. DeleteApprovalJourney(new
  22800. Domain.Dtos.Groups.DeleteApprovalJourney
  22801. {
  22802. Diid = dto.Diid,
  22803. uesrId = dto.Userid
  22804. });
  22805. var stay = "-";
  22806. var cityPath = "-";
  22807. var arriveCountry = string.Empty;
  22808. //添加城市路径以及住宿地
  22809. //黑屏代码获取时间区间
  22810. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  22811. var empty = "【未收入该三字码!请机票同事录入】";
  22812. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  22813. #region 配置公务活动时间
  22814. List<Tuple<int, string, string>> Times = new List<Tuple<int, string, string>>();
  22815. Times.Add(new Tuple<int, string, string>(9, "9:00", "10:30"));
  22816. Times.Add(new Tuple<int, string, string>(11, "11:00", "12:00"));
  22817. Times.Add(new Tuple<int, string, string>(14, "14:00", "15:30"));
  22818. Times.Add(new Tuple<int, string, string>(16, "16:00", "17:00"));
  22819. List<Tuple<DateTime, List<string>>> fallTimesCheckCountry = new List<Tuple<DateTime, List<string>>>()
  22820. {
  22821. 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" }),
  22822. 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"}),
  22823. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,11,30,0), new List<string>{"14:00-15:30","16:00-17:00"}),
  22824. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,13,30,0), new List<string>{"16:30-17:30"}),
  22825. };
  22826. List<Tuple<DateTime, List<string>>> fallTimesNotCheckCountry = new List<Tuple<DateTime, List<string>>>()
  22827. {
  22828. 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" }),
  22829. 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"}),
  22830. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,11,30,0), new List<string>{"14:00-15:30","16:00-17:00"}),
  22831. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,14,30,0), new List<string>{"16:30-17:30"}),
  22832. };
  22833. List<Tuple<DateTime, List<string>>> takeoffTimes = new List<Tuple<DateTime, List<string>>>()
  22834. {
  22835. 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" }),
  22836. 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"}),
  22837. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,14,00,0), new List<string>{"9:00-10:30", "11:00-12:00",}),
  22838. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,12,00,0), new List<string>{"09:00-10:00"}),
  22839. };
  22840. #endregion
  22841. var nextDayNum = 0;
  22842. for (int i = 0; i < timeArr.Count; i++)
  22843. {
  22844. stay = "-";
  22845. cityPath = "-";
  22846. var chiarr = new List<Grp_ApprovalTravelDetails>();
  22847. DateTime NewData = DateTime.Parse(timeArr[i]);
  22848. //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();
  22849. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  22850. if (nextDayNum > 0)
  22851. {
  22852. nextDayNum--;
  22853. }
  22854. if (tbSelect.Length > 0)
  22855. {
  22856. List<string> threeCodeStr = new List<string>();
  22857. bool isTrade = false;
  22858. string trip = string.Empty;
  22859. foreach (var item in tbSelect)
  22860. {
  22861. if (nextDayNum == 0)
  22862. {
  22863. nextDayNum = Convert.ToInt32(item["Sign"]);
  22864. }
  22865. var airStartTime = item["StartTime"].ToString() ?? "0000";
  22866. var airEndTime = item["EndTime"].ToString() ?? "0000";
  22867. var takeOffTime = DateTime.Parse(timeArr[i]);
  22868. var fallToTime = DateTime.Parse(timeArr[i]);
  22869. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  22870. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  22871. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  22872. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  22873. if (nextDayNum > 0)
  22874. {
  22875. fallToTime = fallToTime.AddDays(nextDayNum);
  22876. }
  22877. trip = string.Empty;
  22878. var start = string.Empty;
  22879. var end = string.Empty;
  22880. var threeCode = item["Three"].ToString() ?? "";
  22881. if (threeCode.Length == 6)
  22882. {
  22883. start = threeCode.Substring(0, 3);
  22884. end = threeCode.Substring(3, 3);
  22885. if (threeCodeStr.Count == 0)
  22886. {
  22887. threeCodeStr.Add(start);
  22888. threeCodeStr.Add(end);
  22889. }
  22890. else
  22891. {
  22892. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  22893. {
  22894. threeCodeStr.Add(end);
  22895. }
  22896. else
  22897. {
  22898. threeCodeStr.Add(start);
  22899. threeCodeStr.Add(end);
  22900. }
  22901. }
  22902. }
  22903. //处理机票信息
  22904. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  22905. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  22906. if (start_Object == null)
  22907. {
  22908. start_Object = new Res_ThreeCode()
  22909. {
  22910. AirPort = empty,
  22911. AirPort_En = empty,
  22912. City = empty,
  22913. Country = empty,
  22914. Four = empty,
  22915. Three = empty,
  22916. };
  22917. }
  22918. if (end_Object == null)
  22919. {
  22920. end_Object = new Res_ThreeCode()
  22921. {
  22922. AirPort = empty,
  22923. AirPort_En = empty,
  22924. City = empty,
  22925. Country = empty,
  22926. Four = empty,
  22927. Three = empty,
  22928. };
  22929. }
  22930. //机型判断
  22931. string airModel = item["AirModel"].ToString();
  22932. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  22933. string flightTime = item["FlightTime"].ToString();
  22934. flightTime = ParseBlackTime(flightTime);
  22935. //航班号
  22936. string flightcode = item["Fliagtcode"].ToString();
  22937. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  22938. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  22939. if (aircompany == null)
  22940. {
  22941. aircompany = new Res_AirCompany
  22942. {
  22943. CnName = hsEmpty,
  22944. EnName = hsEmpty,
  22945. ShortCode = hsEmpty,
  22946. };
  22947. }
  22948. //航班前公务安排
  22949. if (tbSelect.First().Equals(item) && i != 0)
  22950. {
  22951. foreach (var takeoff in takeoffTimes)
  22952. {
  22953. var takeoffItem1 = NewData.AddHours(takeoff.Item1.Hour).AddMinutes(takeoff.Item1.Minute);
  22954. if (DateTime.Compare(takeOffTime, takeoffItem1) > 0)
  22955. {
  22956. foreach (var addTime in takeoff.Item2)
  22957. {
  22958. chiarr.Add(new Grp_ApprovalTravelDetails
  22959. {
  22960. Time = addTime,
  22961. CreateTime = DateTime.Now,
  22962. CreateUserId = dto.Userid,
  22963. ParentId = 0,
  22964. Details = "公务活动"
  22965. });
  22966. }
  22967. break;
  22968. }
  22969. }
  22970. }
  22971. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  22972. //trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName}{flightcode}飞往{end_Object.City}。\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  22973. //乘坐四川航空3U3901次航班由成都飞往加德满都,3小时25分钟
  22974. trip += $"乘坐{aircompany.CnName}{flightcode}次航班由{start_Object.City}飞往{end_Object.City},{flightTime}";
  22975. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  22976. if (isTrade)
  22977. {
  22978. //trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  22979. trip += "(转机不出机场)。";
  22980. }
  22981. //else
  22982. //{
  22983. // trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  22984. //}
  22985. chiarr.Add(new Grp_ApprovalTravelDetails
  22986. {
  22987. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  22988. CreateTime = DateTime.Now,
  22989. CreateUserId = dto.Userid,
  22990. ParentId = 0,
  22991. Details = trip
  22992. });
  22993. //最后一条到达的时间安排公务
  22994. if (tbSelect.Last().Equals(item) && i != timeArr.Count - 1)
  22995. {
  22996. bool isCheckCountry = false;
  22997. if (end_Object.Country != arriveCountry)
  22998. {
  22999. arriveCountry = end_Object.Country;
  23000. isCheckCountry = true;
  23001. }
  23002. if (nextDayNum == 0)
  23003. {
  23004. //需要入境的情况
  23005. if (isCheckCountry)
  23006. {
  23007. foreach (var fallTime in fallTimesCheckCountry)
  23008. {
  23009. var fallTimeItem1 = NewData.AddHours(fallTime.Item1.Hour).AddMinutes(fallTime.Item1.Minute);
  23010. if (DateTime.Compare(fallToTime, fallTimeItem1) < 0)
  23011. {
  23012. foreach (var addTime in fallTime.Item2)
  23013. {
  23014. chiarr.Add(new Grp_ApprovalTravelDetails
  23015. {
  23016. Time = addTime,
  23017. CreateTime = DateTime.Now,
  23018. CreateUserId = dto.Userid,
  23019. ParentId = 0,
  23020. Details = "公务活动"
  23021. });
  23022. }
  23023. break;
  23024. }
  23025. }
  23026. }
  23027. else
  23028. {
  23029. foreach (var fallTime in fallTimesNotCheckCountry)
  23030. {
  23031. var fallTimeItem1 = NewData.AddHours(fallTime.Item1.Hour).AddMinutes(fallTime.Item1.Minute);
  23032. if (DateTime.Compare(fallToTime, fallTimeItem1) < 0)
  23033. {
  23034. foreach (var addTime in fallTime.Item2)
  23035. {
  23036. chiarr.Add(new Grp_ApprovalTravelDetails
  23037. {
  23038. Time = addTime,
  23039. CreateTime = DateTime.Now,
  23040. CreateUserId = dto.Userid,
  23041. ParentId = 0,
  23042. Details = "公务活动"
  23043. });
  23044. }
  23045. break;
  23046. }
  23047. }
  23048. }
  23049. }
  23050. }
  23051. }
  23052. //添加乘车语句
  23053. //chiarr.Add(new Grp_ApprovalTravelDetails
  23054. //{
  23055. // Time = (fallToTime.AddHours(2.5).ToString("HH:mm") + "-" + fallToTime.AddHours(3).ToString("HH:mm")),
  23056. // CreateTime = DateTime.Now,
  23057. // CreateUserId = dto.Userid,
  23058. // ParentId = 0,
  23059. // Details = "乘车前往市区(约xx公里,大约需要xx分钟)"
  23060. //});
  23061. //if (i != timeArr.Count - 1)
  23062. //{
  23063. // fallToTime = fallToTime.AddHours(2.5);
  23064. // foreach (var item in Times)
  23065. // {
  23066. // //排列公务时间
  23067. // if (fallToTime.Hour < item.Item1)
  23068. // {
  23069. // chiarr.Add(new Grp_ApprovalTravelDetails
  23070. // {
  23071. // Time = $"{item.Item2} - {item.Item3}",
  23072. // CreateTime = DateTime.Now,
  23073. // CreateUserId = dto.Userid,
  23074. // ParentId = 0,
  23075. // Details = "公务活动"
  23076. // });
  23077. // }
  23078. // }
  23079. //}
  23080. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  23081. var last = threeCodeStr.Last();
  23082. foreach (var item in threeCodeStr)
  23083. {
  23084. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  23085. if (item.Equals(last))
  23086. {
  23087. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  23088. }
  23089. }
  23090. cityPath = cityPath.Trim('-');
  23091. }
  23092. else
  23093. {
  23094. foreach (var item in Times)
  23095. {
  23096. chiarr.Add(new Grp_ApprovalTravelDetails
  23097. {
  23098. Time = $"{item.Item2} - {item.Item3}",
  23099. CreateTime = DateTime.Now,
  23100. CreateUserId = dto.Userid,
  23101. ParentId = 0,
  23102. Details = "公务活动"
  23103. });
  23104. }
  23105. }
  23106. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  23107. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  23108. appro.Date = NewData.Month + "月" + NewData.Day + "日(" + week + ")" + "第" + intToString(i + 1) + "天 ";
  23109. appro.Diid = dto.Diid;
  23110. appro.CreateUserId = dto.Userid;
  23111. appro.CreateTime = DateTime.Now;
  23112. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  23113. appro.Id = thisId;
  23114. //foreach (var item in gwinfo)
  23115. //{
  23116. // Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  23117. // chi.Details = "拜访" + item.Client;
  23118. // if (!string.IsNullOrWhiteSpace(item.ReqSample))
  23119. // {
  23120. // chi.Details += "," + item.ReqSample;
  23121. // }
  23122. // chi.ParentId = thisId;
  23123. // chi.Time = item.Time;
  23124. // chiarr.Add(chi);
  23125. //}
  23126. if (chiarr.Count < 6)
  23127. {
  23128. for (int j = chiarr.Count; j < 6; j++)
  23129. {
  23130. chiarr.Add(new
  23131. Grp_ApprovalTravelDetails());
  23132. }
  23133. }
  23134. resultArr.Add(new
  23135. {
  23136. appro.Id,
  23137. appro.Date,
  23138. appro.Diid,
  23139. chiList = chiarr.Select(x1 => new
  23140. {
  23141. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  23142. x1.Details,
  23143. x1.ParentId,
  23144. x1.Id
  23145. })
  23146. });
  23147. }
  23148. _sqlSugar.CommitTran();
  23149. jw = JsonView(true, "生成成功!", resultArr);
  23150. }
  23151. catch (Exception ex)
  23152. {
  23153. jw.Code = 400;
  23154. jw.Msg = "生成失败!" + ex.Message;
  23155. }
  23156. return Ok(jw);
  23157. }
  23158. /// <summary>
  23159. /// 报批行程word导出
  23160. /// </summary>
  23161. /// <param name="dto"></param>
  23162. /// <returns></returns>
  23163. [HttpPost]
  23164. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  23165. {
  23166. var jw = JsonView(false);
  23167. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  23168. if (group == null)
  23169. {
  23170. jw.Msg = "暂无该团组!";
  23171. return Ok(jw);
  23172. }
  23173. //模板路径
  23174. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/";
  23175. var fileName = string.Empty;
  23176. string titleFont = string.Empty, timeFont = string.Empty, contentFont = string.Empty;
  23177. bool bold = false;
  23178. if (dto.FileIndex == 1)
  23179. {
  23180. fileName = "公务行程导出模板.docx"; //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  23181. }
  23182. else if (dto.FileIndex == 2)
  23183. {
  23184. fileName = "省外办-报批.docx";
  23185. bold = false;
  23186. titleFont = "方正黑体简体";
  23187. timeFont = "Times New Roman";
  23188. contentFont = "方正仿宋_GBK";
  23189. }
  23190. else if (dto.FileIndex == 3)
  23191. {
  23192. fileName = "市外办-报批.docx";
  23193. titleFont = "方正黑体简体";
  23194. timeFont = "Times New Roman";
  23195. contentFont = "方正仿宋简体";
  23196. }
  23197. tempPath = tempPath + fileName;
  23198. //载入模板
  23199. Document doc = new Document(tempPath);
  23200. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  23201. //获取所填表格的序数
  23202. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  23203. Aspose.Words.Tables.Row titleRowClone = null;
  23204. Aspose.Words.Tables.Row CenterRowClone = null;
  23205. int index = 0;
  23206. int indexChi = 0;
  23207. int SetIndex = 0;
  23208. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  23209. //获取数据,放到datatable
  23210. foreach (var item in ApprovalTravelArr)
  23211. {
  23212. if (index > 0)
  23213. {
  23214. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  23215. tableOne.AppendChild(titleRowClone);
  23216. }
  23217. var textTime = item.Date;
  23218. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  23219. SetCells(tableOne, doc, SetIndex, 0, textTime, titleFont, bold);
  23220. SetIndex++;
  23221. if (ChiRep.Count > 0)
  23222. {
  23223. foreach (var itemChi in ChiRep)
  23224. {
  23225. var txtTime = itemChi.Time;
  23226. var txtDetail = itemChi.Details;
  23227. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  23228. {
  23229. //SetCells(tableOne, doc, SetIndex, 0, "", timeFont, bold);
  23230. //SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  23231. //indexChi++;
  23232. //SetIndex++;
  23233. break;
  23234. }
  23235. if (indexChi > 0)
  23236. {
  23237. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  23238. tableOne.AppendChild(CenterRowClone);
  23239. }
  23240. SetCells(tableOne, doc, SetIndex, 0, txtTime, timeFont, bold);
  23241. SetCells(tableOne, doc, SetIndex, 1, txtDetail, contentFont, bold);
  23242. indexChi++;
  23243. SetIndex++;
  23244. }
  23245. }
  23246. //else
  23247. //{
  23248. // if (indexChi > 0)
  23249. // {
  23250. // CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  23251. // tableOne.AppendChild(CenterRowClone);
  23252. // }
  23253. // SetCells(tableOne, doc, SetIndex, 0, "",timeFont, bold);
  23254. // SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  23255. // indexChi++;
  23256. // SetIndex++;
  23257. //}
  23258. index++;
  23259. }
  23260. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + fileName;
  23261. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName, Aspose.Words.SaveFormat.Docx); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  23262. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  23263. jw.Code = 200;
  23264. jw.Msg = "";
  23265. return Ok(jw);
  23266. }
  23267. private string ParseBlackTime(string time)
  23268. {
  23269. // 匹配可能只有分钟的情况
  23270. string pattern = @"(?:(\d+)H)?(?:(\d+)M)?";
  23271. System.Text.RegularExpressions.Match match = Regex.Match(time, pattern);
  23272. if (match.Success)
  23273. {
  23274. string hours = match.Groups[1].Value;
  23275. string minutes = match.Groups[2].Value;
  23276. // 如果小时部分为空,则只显示分钟
  23277. if (string.IsNullOrEmpty(hours))
  23278. {
  23279. return $"{minutes}分钟";
  23280. }
  23281. // 如果分钟部分为空,则只显示小时
  23282. else if (string.IsNullOrEmpty(minutes))
  23283. {
  23284. return $"{hours}小时";
  23285. }
  23286. // 否则显示完整格式
  23287. else
  23288. {
  23289. return $"{hours}小时{minutes}分钟";
  23290. }
  23291. }
  23292. else
  23293. {
  23294. return "未知时长";
  23295. }
  23296. }
  23297. private string intToString(int numberVal)
  23298. {
  23299. string numberval = numberVal.ToString();
  23300. Dictionary<char, string> Number = new Dictionary<char, string>();
  23301. Number.Add('1', "一");
  23302. Number.Add('2', "二");
  23303. Number.Add('3', "三");
  23304. Number.Add('4', "四");
  23305. Number.Add('5', "五");
  23306. Number.Add('6', "六");
  23307. Number.Add('7', "七");
  23308. Number.Add('8', "八");
  23309. Number.Add('9', "九");
  23310. string stringNumberVal = string.Empty;
  23311. for (int i = 0; i < numberval.Length; i++)
  23312. {
  23313. if (i == 0)
  23314. {
  23315. stringNumberVal += Number[numberval[i]];
  23316. }
  23317. else if (i >= 1)
  23318. {
  23319. if (numberval[i] == '0')
  23320. {
  23321. stringNumberVal = "十";
  23322. }
  23323. else
  23324. {
  23325. stringNumberVal += "十" + Number[numberval[i]];
  23326. }
  23327. }
  23328. }
  23329. return stringNumberVal;
  23330. }
  23331. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val, string font, bool bold)
  23332. {
  23333. //获取table中的某个单元格,从0开始
  23334. Cell lshCell = table.Rows[rows].Cells[cells];
  23335. //将单元格中段落移除
  23336. foreach (Paragraph item in lshCell.Paragraphs)
  23337. {
  23338. lshCell.Paragraphs.Remove(item);
  23339. }
  23340. if (val.Contains("\r\n"))
  23341. {
  23342. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  23343. foreach (var item in spArr)
  23344. {
  23345. //新建一个段落
  23346. Paragraph p = new Paragraph(doc);
  23347. var r = new Run(doc, item);
  23348. //设置字体
  23349. if (!string.IsNullOrEmpty(font))
  23350. {
  23351. r.Font.Name = font;
  23352. }
  23353. r.Font.Bold = bold;
  23354. //把设置的值赋给之前新建的段落
  23355. p.AppendChild(r);
  23356. //将此段落加到单元格内
  23357. lshCell.AppendChild(p);
  23358. }
  23359. }
  23360. else
  23361. {
  23362. //新建一个段落
  23363. Paragraph p = new Paragraph(doc);
  23364. var r = new Run(doc, val);
  23365. //设置字体
  23366. if (!string.IsNullOrEmpty(font))
  23367. {
  23368. r.Font.Name = font;
  23369. }
  23370. r.Font.Bold = bold;
  23371. //把设置的值赋给之前新建的段落
  23372. p.AppendChild(r);
  23373. //将此段落加到单元格内
  23374. lshCell.AppendChild(p);
  23375. }
  23376. }
  23377. /// <summary>
  23378. /// 报批行程AI续写
  23379. /// </summary>
  23380. /// <returns></returns>
  23381. [HttpPost]
  23382. public async Task<IActionResult> ApprovalJourneyAiWrite(ApprovalJourneyAiWriteDto dto)
  23383. {
  23384. var jw = JsonView(false);
  23385. if (dto.ClientPurpose.IsNullOrWhiteSpace() || dto.ClientName.IsNullOrWhiteSpace())
  23386. {
  23387. jw.Msg = "参数有误!";
  23388. return Ok(jw);
  23389. }
  23390. KiMiApiClient kiMi = new KiMiApiClient();
  23391. List<SeedMessages> messages = new List<SeedMessages>() {
  23392. new SeedMessages
  23393. {
  23394. Role = KimiRole.system,
  23395. Content = "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长中文和英文的对话。你会为用户提供安全,有帮助,准确的回答。"
  23396. },
  23397. new SeedMessages
  23398. {
  23399. Role = KimiRole.user,
  23400. Content = $@"参考这个模板格式来编写一份{dto.ClientName}拜访{dto.ClientPurpose},结合{dto.ClientName}的业务,描述拜访目的,字数在200字内(直接给出拜访目的,不输出其他内容)"
  23401. }
  23402. };
  23403. var kimi_result = await kiMi.SeedMessageByFullConterObject(messages);
  23404. string data = kimi_result.Choices[0]?.Message.Content;
  23405. if (string.IsNullOrWhiteSpace(data))
  23406. {
  23407. jw.Data = "Ai续写失败!";
  23408. }
  23409. else
  23410. {
  23411. jw = JsonView(true, "success!", data);
  23412. }
  23413. return Ok(jw);
  23414. }
  23415. #endregion
  23416. #region 团组接待意见调查
  23417. /// <summary>
  23418. /// 团组接待意见调查 - 信息管理
  23419. /// 基础数据(团组)
  23420. /// </summary>
  23421. /// <returns></returns>
  23422. [HttpGet]
  23423. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23424. public async Task<IActionResult> OpinionaireInit()
  23425. {
  23426. var groupData = await _groupRepository.Query(x => x.IsDel == 0)
  23427. .Select(x => new
  23428. {
  23429. x.Id,
  23430. GroupName = $"[{x.VisitDate.ToString("yyyy-MM-dd")}]{x.TeamName}"
  23431. })
  23432. .OrderByDescending(x => x.Id)
  23433. .ToListAsync();
  23434. return Ok(JsonView(groupData, groupData.Count));
  23435. }
  23436. /// <summary>
  23437. /// 团组接待意见调查 - 信息管理
  23438. /// 列表
  23439. /// </summary>
  23440. /// <param name="groupId"></param>
  23441. /// <returns></returns>
  23442. [HttpGet("{groupId}")]
  23443. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23444. public async Task<IActionResult> OpinionaireManageList(int groupId)
  23445. {
  23446. if (groupId < 1) Ok(JsonView(false, "请传入有效的diId"));
  23447. var data = await _opinionaireRep.Query(x => x.DiId == groupId)
  23448. .Select(x => new
  23449. {
  23450. x.Id,
  23451. x.TourGuideName,
  23452. x.CityName,
  23453. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x.CreateUserId == x1.Id).Select(x1 => x1.CnName),
  23454. x.CreateTime
  23455. })
  23456. .OrderBy(x => x.Id)
  23457. .ToListAsync();
  23458. return Ok(JsonView(data));
  23459. }
  23460. /// <summary>
  23461. /// 团组接待意见调查 - 信息管理
  23462. /// 保存
  23463. /// </summary>
  23464. /// <param name="dto"></param>
  23465. /// <returns></returns>
  23466. [HttpPost]
  23467. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23468. public async Task<IActionResult> OpinionaireManageSave(OpinionaireManageSaveDto dto)
  23469. {
  23470. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  23471. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  23472. if (dto.DiId < 1) Ok(JsonView(false, "请传入有效的diId"));
  23473. if (dto.Items.Length < 1) Ok(JsonView(false, "请传入需要保存的信息"));
  23474. var addData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id == 0).ToList());
  23475. var updData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id > 0).ToList());
  23476. _opinionaireRep.BeginTran();
  23477. if (addData != null && addData.Count > 0)
  23478. {
  23479. foreach (var item in addData)
  23480. {
  23481. item.CreateUserId = currUserInfo.UserId;
  23482. item.DiId = dto.DiId;
  23483. }
  23484. var add = await _opinionaireRep._sqlSugar.Insertable(addData).ExecuteCommandAsync();
  23485. }
  23486. if (updData != null && updData.Count > 0)
  23487. {
  23488. var upd = await _opinionaireRep._sqlSugar
  23489. .Updateable(updData)
  23490. .UpdateColumns(x => new { x.CityName, x.TourGuideName })
  23491. .WhereColumns(x => new { x.Id })
  23492. .ExecuteCommandAsync();
  23493. }
  23494. _opinionaireRep.CommitTran();
  23495. return Ok(JsonView("操作成功!"));
  23496. }
  23497. /// <summary>
  23498. /// 团组接待意见调查 - 信息管理
  23499. /// 删除
  23500. /// </summary>
  23501. /// <param name="id"></param>
  23502. /// <returns></returns>
  23503. [HttpDelete("{id}")]
  23504. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23505. public async Task<IActionResult> OpinionaireManageDel(int id)
  23506. {
  23507. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  23508. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  23509. if (id < 1) Ok(JsonView(false, "请传入有效的id"));
  23510. var del = await _opinionaireRep.SoftDeleteAsync(x => x.Id == id, currUserInfo.UserId);
  23511. if (!del) return Ok(JsonView("操作失败!"));
  23512. return Ok(JsonView("操作成功!"));
  23513. }
  23514. /// <summary>
  23515. /// 团组接待意见调查 - 用户
  23516. /// 列表
  23517. /// </summary>
  23518. /// <param name="diId"></param>
  23519. /// <returns></returns>
  23520. [HttpGet("{diId}")]
  23521. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23522. public async Task<IActionResult> OpinionaireUserList(int diId)
  23523. {
  23524. if (diId < 1) Ok(JsonView(false, "请传入有效的diId"));
  23525. var sql = string.Format(@"
  23526. SELECT
  23527. o.Id,
  23528. o.DiId,
  23529. di.TeamName AS 'GroupName',
  23530. di.VisitPNumber AS 'PeopleNumber',
  23531. di.ClientName AS 'LeadGroup',
  23532. di.VisitCountry AS 'Travel',
  23533. di.VisitDays AS 'Days',
  23534. o.CityName,
  23535. o.TourGuideName,
  23536. o.Catering,
  23537. o.CateringReason,
  23538. o.Stay,
  23539. o.StayReason,
  23540. o.[Route],
  23541. o.RouteReason,
  23542. o.OfficialActivity,
  23543. o.OfficialActivityReason,
  23544. o.TourGuide,
  23545. o.TourGuideReason,
  23546. o.[Translate],
  23547. o.TranslateReason,
  23548. o.Trip,
  23549. o.TripReason,
  23550. o.ESFileName,
  23551. o.SignatureDate,
  23552. o.Remark
  23553. FROM
  23554. Grp_Opinionaire o
  23555. LEFT JOIN Grp_DelegationInfo di ON o.DiId = di.Id
  23556. WHERE
  23557. o.IsDel = 0
  23558. AND o.DiId = {0}
  23559. ORDER BY
  23560. o.Id ASC", diId);
  23561. var data = await _sqlSugar.SqlQueryable<OpinionaireUserListView>(sql).ToListAsync();
  23562. if (data.Count < 1) return Ok(JsonView(false, "暂无数据"));
  23563. return Ok(JsonView(data));
  23564. }
  23565. /// <summary>
  23566. /// 团组接待意见调查 - 用户
  23567. /// 保存
  23568. /// </summary>
  23569. /// <param name="dto"></param>
  23570. /// <returns></returns>
  23571. [HttpPost]
  23572. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23573. public async Task<IActionResult> OpinionaireUserSave([FromForm] OpinionaireUserSaveInfo[] dto)
  23574. {
  23575. if (dto.Length < 1) Ok(JsonView(false, "请传入有效的参数"));
  23576. foreach (var item in dto)
  23577. {
  23578. if (string.IsNullOrEmpty(item.Catering)) Ok(JsonView(false, "请选择餐饮评分!"));
  23579. if (string.IsNullOrEmpty(item.Stay)) Ok(JsonView(false, "请选择住宿评分!"));
  23580. if (string.IsNullOrEmpty(item.Route)) Ok(JsonView(false, "请选择行程评分!"));
  23581. if (string.IsNullOrEmpty(item.OfficialActivity)) Ok(JsonView(false, "请选择公务活动评分!"));
  23582. if (string.IsNullOrEmpty(item.Translate)) Ok(JsonView(false, "请选择翻译评分!"));
  23583. if (string.IsNullOrEmpty(item.Trip)) Ok(JsonView(false, "请选择行程评分!"));
  23584. if (string.IsNullOrEmpty(item.SignatureDate)) Ok(JsonView(false, "请填写签名日期!"));
  23585. if (item.File.Length < 1) Ok(JsonView(false, "请上传签名图片!"));
  23586. }
  23587. var filePathBase = $"{AppSettingsHelper.Get("GrpFileBasePath")}OpinionaireElectronicSignature";
  23588. if (!Directory.Exists(filePathBase))
  23589. {
  23590. Directory.CreateDirectory(filePathBase);
  23591. }
  23592. #region 上传文件
  23593. var filePaths = new List<string>();
  23594. foreach (var item in dto)
  23595. {
  23596. var file = item.File;
  23597. // 将文件保存到指定位置
  23598. var filePath = Path.Combine(filePathBase, file.FileName);
  23599. using (var stream = new FileStream(filePath, FileMode.Create))
  23600. {
  23601. await file.CopyToAsync(stream);
  23602. }
  23603. //验证文件是否上传成功
  23604. if (!System.IO.File.Exists(filePath))
  23605. {
  23606. foreach (var filePathStr in filePaths)
  23607. {
  23608. System.IO.File.Delete(filePathStr);
  23609. }
  23610. return Ok(JsonView(false, "文件上传失败!"));
  23611. }
  23612. item.ESFileName = file.FileName;
  23613. }
  23614. #endregion
  23615. var infos = _mapper.Map<List<Grp_Opinionaire>>(dto);
  23616. var upd = await _sqlSugar.Updateable<Grp_Opinionaire>(infos)
  23617. .UpdateColumns(x => new
  23618. {
  23619. x.Catering,
  23620. x.CateringReason,
  23621. x.Stay,
  23622. x.StayReason,
  23623. x.Route,
  23624. x.RouteReason,
  23625. x.OfficialActivity,
  23626. x.OfficialActivityReason,
  23627. x.TourGuide,
  23628. x.TourGuideReason,
  23629. x.Translate,
  23630. x.TranslateReason,
  23631. x.Trip,
  23632. x.TripReason,
  23633. x.ESFileName,
  23634. x.SignatureDate,
  23635. x.Remark
  23636. })
  23637. .WhereColumns(x => new { x.Id })
  23638. .ExecuteCommandAsync();
  23639. if (upd < 1)
  23640. {
  23641. foreach (var filePathStr in filePaths)
  23642. {
  23643. System.IO.File.Delete(filePathStr);
  23644. }
  23645. return Ok(JsonView(false));
  23646. }
  23647. return Ok(JsonView(true));
  23648. }
  23649. #endregion
  23650. #region 团组餐厅相关信息
  23651. /// <summary>
  23652. /// 团组相关餐厅信息
  23653. /// 基础数据(团组)
  23654. /// </summary>
  23655. /// <returns></returns>
  23656. [HttpGet]
  23657. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23658. public async Task<IActionResult> RestaurantInit()
  23659. {
  23660. return Ok(await _restaurantRep.InitAsync());
  23661. }
  23662. /// <summary>
  23663. /// 团组相关餐厅信息
  23664. /// Item
  23665. /// </summary>
  23666. /// <param name="dto"></param>
  23667. /// <returns></returns>
  23668. [HttpPost]
  23669. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23670. public async Task<IActionResult> RestaurantItem(RestaurantItemDto dto)
  23671. {
  23672. int portType = dto.PortType,
  23673. groupId = dto.GroupId;
  23674. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  23675. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  23676. return Ok(await _restaurantRep.ItemAsync(portType, groupId));
  23677. }
  23678. /// <summary>
  23679. /// 团组相关餐厅信息
  23680. /// List
  23681. /// </summary>
  23682. /// <param name="dto"></param>
  23683. /// <returns></returns>
  23684. [HttpPost]
  23685. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23686. public async Task<IActionResult> RestaurantList(RestaurantItemDto dto)
  23687. {
  23688. int portType = dto.PortType,
  23689. groupId = dto.GroupId;
  23690. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  23691. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  23692. var sql = string.Format(@" SELECT
  23693. ri.Id,
  23694. ri.GroupId,
  23695. ri.Date,
  23696. ri.StartTime,
  23697. ri.EndTime,
  23698. CASE WHEN ri.Type = 1 THEN '早餐'
  23699. WHEN ri.Type = 2 THEN '午餐'
  23700. WHEN ri.Type = 3 THEN '晚餐'
  23701. ELSE '其他'
  23702. END AS 'Type',
  23703. ri.Name,
  23704. ri.Address,
  23705. ri.Tel,
  23706. ri.Remark,
  23707. ri.CreateTime,
  23708. u.CnName AS CreateUserName
  23709. FROM
  23710. Grp_RestaurantInfo ri
  23711. LEFT JOIN Sys_Users u ON ri.CreateUserId = u.Id
  23712. WHERE
  23713. ri.IsDel = 0
  23714. AND ri.GroupId = {0}
  23715. ORDER BY
  23716. ri.Date ASC
  23717. ", groupId);
  23718. var infos = await _sqlSugar.SqlQueryable<RestaurantItemView>(sql).ToListAsync();
  23719. if (!infos.Any()) Ok(JsonView(false, "数据未填写!"));
  23720. return Ok(JsonView(infos));
  23721. }
  23722. /// <summary>
  23723. /// 团组相关餐厅信息
  23724. /// Info
  23725. /// </summary>
  23726. /// <param name="dto"></param>
  23727. /// <returns></returns>
  23728. [HttpPost]
  23729. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23730. public async Task<IActionResult> RestaurantInfo(RestaurantInfoDto dto)
  23731. {
  23732. int portType = dto.PortType,
  23733. id = dto.Id;
  23734. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  23735. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  23736. return Ok(await _restaurantRep.InfoAsync(portType, id));
  23737. }
  23738. /// <summary>
  23739. /// 团组相关餐厅信息
  23740. /// Op
  23741. /// </summary>
  23742. /// <param name="dto"></param>
  23743. /// <returns></returns>
  23744. [HttpPost]
  23745. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23746. public async Task<IActionResult> RestaurantOp(RestaurantOpDto dto)
  23747. {
  23748. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  23749. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  23750. if (string.IsNullOrEmpty(dto.Name)) return Ok(JsonView(false, "餐厅名称为空!"));
  23751. return Ok(await _restaurantRep.OpAsync(dto));
  23752. }
  23753. /// <summary>
  23754. /// 团组相关餐厅信息
  23755. /// Del
  23756. /// </summary>
  23757. /// <param name="dto"></param>
  23758. /// <returns></returns>
  23759. [HttpPost]
  23760. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23761. public async Task<IActionResult> RestaurantDel(RestaurantDelDto dto)
  23762. {
  23763. int userId = dto.DeleteUserId;
  23764. var id = dto.Id;
  23765. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  23766. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  23767. return Ok(await _restaurantRep.DelAsync(dto));
  23768. }
  23769. #endregion
  23770. #region 团组会务成本
  23771. /// <summary>
  23772. /// 团组会务成本数据初始化
  23773. /// </summary>
  23774. /// <returns></returns>
  23775. [HttpPost]
  23776. public async Task<IActionResult> ConferenceAffairsInIt(ConferenceAffairsInItDto Dto)
  23777. {
  23778. var expr = _sqlSugar.Queryable<Grp_DelegationInfo>()
  23779. .OrderByDescending(x => x.CreateTime)
  23780. .Where(x => x.IsDel == 0)
  23781. .Select<DelegationEasyView>();
  23782. DelegationEasyView di = Dto.GroupId == 0 ?
  23783. expr.First() :
  23784. expr.First(x => x.Id == Dto.GroupId);
  23785. if (di == null)
  23786. {
  23787. return Ok(JsonView(false, "团组信息不存在!"));
  23788. }
  23789. var typeData = await _sqlSugar.Queryable<Sys_SetData>()
  23790. .Where(x => x.IsDel == 0 && x.STid == 21)
  23791. .Select(x => new { x.Id, Text = x.Name })
  23792. .ToListAsync();
  23793. var hwids = _sqlSugar.Queryable<Sys_SetData>()
  23794. .Where(x => x.IsDel == 0 && x.STid == 10 && x.Name.Contains("会务活动"))
  23795. .Select(x => x.Id)
  23796. .ToList();
  23797. //仅检索会务团组
  23798. var groupList = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  23799. .Where(x => x.IsDel == 0 && hwids.Contains(x.TeamDid))
  23800. .OrderByDescending(x => x.VisitDate)
  23801. .Select(x => new { x.Id, x.TeamName })
  23802. .ToListAsync();
  23803. var currenyList = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(1, di.Id, 98);
  23804. var userList = await _sqlSugar.Queryable<Sys_Users>()
  23805. .Where(x => x.IsDel == 0)
  23806. .Select(x => new { x.Id, x.CnName })
  23807. .ToListAsync();
  23808. var units = await _sqlSugar.Queryable<Sys_SetData>()
  23809. .Where(x => x.IsDel == 0 && x.STid == 119)
  23810. .Select(x => new { x.Id, Text = x.Name })
  23811. .ToListAsync();
  23812. var FileType = new[]
  23813. {
  23814. new { Id = 0 , Name = "成本下载" },
  23815. new { Id = 1 , Name = "报价下载" },
  23816. new { Id = 2 , Name = "总表下载" },
  23817. };
  23818. var GM = new List<int>();
  23819. var permissionControlDB = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1448)?.Remark;
  23820. try
  23821. {
  23822. GM = JsonConvert.DeserializeObject<List<int>>(permissionControlDB);
  23823. }
  23824. catch (Exception ex)
  23825. {
  23826. GM = new List<int>() { 21 };
  23827. }
  23828. var isReview = Dto.UserId == 21;
  23829. var isGM = GM.Contains(Dto.UserId);
  23830. var ConferenceAffairsCost = _sqlSugar.Queryable<Grp_ConferenceAffairsCost>()
  23831. .Where(x => x.IsDel == 0)
  23832. .Select<ConferenceAffairsCostView>()
  23833. .First(x => x.Diid == di.Id);
  23834. if (ConferenceAffairsCost == null)
  23835. {
  23836. ConferenceAffairsCost = new ConferenceAffairsCostView();
  23837. ConferenceAffairsCost.Diid = di.Id;
  23838. }
  23839. #region 权限校验
  23840. var ids = _sqlSugar.Queryable<Grp_ConferenceAffairsCostControl>()
  23841. .Where(x => x.Diid == di.Id && x.IsDel == 0)
  23842. .Select(x => x.UserId)
  23843. .Distinct()
  23844. .ToList();
  23845. if (!ids.Contains(Dto.UserId) && !isGM)
  23846. {
  23847. return Ok(JsonView(201, "暂无权限!", new
  23848. {
  23849. typeData,
  23850. groupList,
  23851. currenyList,
  23852. isGM,
  23853. userList,
  23854. units,
  23855. isReview,
  23856. operatorUser = ids,
  23857. di,
  23858. FileType
  23859. }));
  23860. }
  23861. #endregion
  23862. var ConferenceAffairsCostChi = _sqlSugar.Queryable<Grp_ConferenceAffairsCostChild>()
  23863. .Where(x => x.IsDel == 0 && x.Diid == di.Id)
  23864. .Select<ConferenceAffairsCostChildView>()
  23865. .OrderBy(x => x.Index)
  23866. .ToList();
  23867. for (int i = 1; i <= ConferenceAffairsCostChi.Count; i++)
  23868. {
  23869. ConferenceAffairsCostChi[i - 1].Index = i;
  23870. }
  23871. var backData = new
  23872. {
  23873. ConferenceAffairsCost,
  23874. ConferenceAffairsCostChi,
  23875. typeData,
  23876. groupList,
  23877. currenyList,
  23878. isGM,
  23879. userList,
  23880. units,
  23881. isReview,
  23882. operatorUser = ids,
  23883. di,
  23884. FileType
  23885. };
  23886. return Ok(JsonView(true, "SUCCESS", backData));
  23887. }
  23888. /// <summary>
  23889. /// 会务成本保存
  23890. /// </summary>
  23891. /// <returns></returns>
  23892. [HttpPost]
  23893. public async Task<IActionResult> ConferenceAffairsSave(ConferenceAffairsSaveDto Dto)
  23894. {
  23895. _sqlSugar.BeginTran();
  23896. var data = _mapper.Map<Grp_ConferenceAffairsCost>(Dto.ConferenceAffairsCost);
  23897. var childResult = new
  23898. {
  23899. success = 0,
  23900. error = 0
  23901. };
  23902. try
  23903. {
  23904. if (data.Id == 0)
  23905. {
  23906. _sqlSugar.Updateable<Grp_ConferenceAffairsCost>()
  23907. .Where(x => x.Diid == Dto.GroupId)
  23908. .SetColumns(x => new Grp_ConferenceAffairsCost
  23909. {
  23910. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  23911. DeleteUserId = Dto.UserId
  23912. })
  23913. .ExecuteCommand();
  23914. data.Diid = Dto.GroupId;
  23915. data.CreateTime = DateTime.Now;
  23916. data.CreateUserId = Dto.UserId;
  23917. data.Id = _sqlSugar.Insertable<Grp_ConferenceAffairsCost>(data)
  23918. .ExecuteReturnIdentity();
  23919. }
  23920. else
  23921. {
  23922. _sqlSugar.Updateable<Grp_ConferenceAffairsCost>(data)
  23923. .ExecuteCommand();
  23924. data.Id = data.Id;
  23925. }
  23926. if (Dto.ConferenceAffairsCostChild.Any())
  23927. {
  23928. var datas = _mapper.Map<List<Grp_ConferenceAffairsCostChild>>(Dto.ConferenceAffairsCostChild);
  23929. var insertArr = datas.Where(x => x.Id == 0).ToList();
  23930. var updateArr = datas.Where(x => x.Id != 0 && x.ReviewStatus != 1).ToList();
  23931. var notUpdateArr = datas.Where(x => x.Id != 0 && x.ReviewStatus == 1).ToList();
  23932. insertArr.ForEach(x => { x.Diid = Dto.GroupId; x.ConferenceAffairsCostId = data.Id; });
  23933. var inrsetCount = insertArr.Any() ? _sqlSugar.Insertable<Grp_ConferenceAffairsCostChild>(insertArr).ExecuteCommand() : 0;
  23934. var updateCount = updateArr.Any() ? _sqlSugar.Updateable<Grp_ConferenceAffairsCostChild>(updateArr)
  23935. .IgnoreColumns(x => new { x.ConferenceAffairsCostId })
  23936. .ExecuteCommand() : 0;
  23937. childResult = childResult with
  23938. {
  23939. error = notUpdateArr.Count(),
  23940. success = inrsetCount + updateCount
  23941. };
  23942. }
  23943. _sqlSugar.CommitTran();
  23944. }
  23945. catch (Exception ex)
  23946. {
  23947. _sqlSugar.RollbackTran();
  23948. return Ok(JsonView(false, "失败!" + ex.Message));
  23949. }
  23950. return Ok(JsonView(true, "操作成功!", childResult));
  23951. }
  23952. [HttpPost]
  23953. public async Task<IActionResult> ConferenceAffairsAudit(ConferenceAffairsAuditDto Dto)
  23954. {
  23955. var count = 0;
  23956. if (Dto.ConferenceAffairsCostChildids.Any())
  23957. {
  23958. count = _sqlSugar.Updateable<Grp_ConferenceAffairsCostChild>().
  23959. Where(x => Dto.ConferenceAffairsCostChildids.Contains(x.Id)).
  23960. SetColumns(x => new Grp_ConferenceAffairsCostChild
  23961. {
  23962. ReviewStatus = Dto.ReviewStatus
  23963. }).
  23964. ExecuteCommand();
  23965. }
  23966. return Ok(JsonView(true, "操作成功!", count));
  23967. }
  23968. /// <summary>
  23969. /// 会务成本所有数据清除
  23970. /// </summary>
  23971. /// <param name="Dto"></param>
  23972. /// <returns></returns>
  23973. [HttpPost]
  23974. public async Task<IActionResult> ConferenceAffairsDelete(ConferenceAffairsDeleteDto Dto)
  23975. {
  23976. if (Dto.GroupId < 1) return Ok(JsonView(false, "请传入有效的Id"));
  23977. if (Dto.UserId < 1) return Ok(JsonView(false, "请传入有效的用户Id"));
  23978. _sqlSugar.BeginTran();
  23979. try
  23980. {
  23981. var delCount = _sqlSugar.Updateable<Grp_ConferenceAffairsCost>()
  23982. .Where(x => x.Diid == Dto.GroupId)
  23983. .SetColumns(x => new Grp_ConferenceAffairsCost
  23984. {
  23985. IsDel = 1,
  23986. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  23987. DeleteUserId = Dto.UserId
  23988. })
  23989. .ExecuteCommand();
  23990. if (delCount > 0)
  23991. {
  23992. _sqlSugar.Updateable<Grp_ConferenceAffairsCostChild>()
  23993. .Where(x => x.Diid == Dto.GroupId)
  23994. .SetColumns(x => new Grp_ConferenceAffairsCostChild
  23995. {
  23996. IsDel = 1,
  23997. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  23998. DeleteUserId = Dto.UserId
  23999. })
  24000. .ExecuteCommand();
  24001. _sqlSugar.Updateable<Grp_ConferenceAffairsCostControl>()
  24002. .Where(x => x.Diid == Dto.GroupId && x.IsDel == 0)
  24003. .SetColumns(x => new Grp_ConferenceAffairsCostControl
  24004. {
  24005. IsDel = 1,
  24006. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  24007. DeleteUserId = Dto.UserId
  24008. })
  24009. .ExecuteCommand();
  24010. }
  24011. _sqlSugar.CommitTran();
  24012. }
  24013. catch (Exception ex)
  24014. {
  24015. _sqlSugar.RollbackTran();
  24016. return Ok(JsonView(false, "操作失败!" + ex.Message));
  24017. }
  24018. return Ok(JsonView(true, "操作成功!"));
  24019. }
  24020. /// <summary>
  24021. /// 子项数据删除
  24022. /// </summary>
  24023. /// <param name="Dto"></param>
  24024. /// <returns></returns>
  24025. [HttpPost]
  24026. public async Task<IActionResult> ConferenceAffairSinglesDelete(ConferenceAffairsDeleteSingleDto Dto)
  24027. {
  24028. var isAudit = _sqlSugar.Queryable<Grp_ConferenceAffairsCostChild>().Where(x => x.IsDel == 0 && Dto.ids.Contains(x.Id))
  24029. .Any(x => x.ReviewStatus == 1);
  24030. if (isAudit) return Ok(JsonView(false, "包含已审核数据无法删除!"));
  24031. var count = _sqlSugar.Updateable<Grp_ConferenceAffairsCostChild>()
  24032. .Where(x => Dto.ids.Contains(x.Id) && x.IsDel == 0)
  24033. .SetColumns(x => new Grp_ConferenceAffairsCostChild
  24034. {
  24035. IsDel = 1,
  24036. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  24037. DeleteUserId = Dto.UserId
  24038. })
  24039. .ExecuteCommand();
  24040. return Ok(JsonView(true, "SUCCESS!", count));
  24041. }
  24042. /// <summary>
  24043. /// 会务成本权限分配
  24044. /// </summary>
  24045. /// <param name="Dto"></param>
  24046. /// <returns></returns>
  24047. [HttpPost]
  24048. public async Task<IActionResult> PermissionSetting(PermissionSettingDto Dto)
  24049. {
  24050. _sqlSugar.BeginTran();
  24051. var count = 0;
  24052. try
  24053. {
  24054. _sqlSugar.Updateable<Grp_ConferenceAffairsCostControl>()
  24055. .Where(x => x.Diid == Dto.GroupId && x.IsDel == 0)
  24056. .SetColumns(x => new Grp_ConferenceAffairsCostControl
  24057. {
  24058. IsDel = 1,
  24059. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  24060. DeleteUserId = Dto.CreateUserId
  24061. })
  24062. .ExecuteCommand();
  24063. count = _sqlSugar.Insertable<Grp_ConferenceAffairsCostControl>(Dto.UserIds.Select(x => new Grp_ConferenceAffairsCostControl
  24064. {
  24065. CreateTime = DateTime.Now,
  24066. CreateUserId = Dto.CreateUserId,
  24067. UserId = x,
  24068. Diid = Dto.GroupId,
  24069. }).ToList()).ExecuteCommand();
  24070. _sqlSugar.CommitTran();
  24071. }
  24072. catch (Exception ex)
  24073. {
  24074. _sqlSugar.RollbackTran();
  24075. return Ok(JsonView(false, "操作失败!" + ex.Message));
  24076. }
  24077. return Ok(JsonView(true, "操作成功!", count));
  24078. }
  24079. /// <summary>
  24080. /// 团组会务成本文件下载
  24081. /// </summary>
  24082. /// <returns></returns>
  24083. [HttpPost]
  24084. public async Task<IActionResult> ConferenceAffairsFileDown(ConferenceAffairsFileDownDto Dto)
  24085. {
  24086. var FileType = new[]
  24087. {
  24088. new { Id = 0 , Name = "成本下载" },
  24089. new { Id = 1 , Name = "报价下载" },
  24090. new { Id = 2 , Name = "总表下载" },
  24091. };
  24092. if (Dto.GroupId < 1) return Ok(JsonView(false, "请传入有效的Id"));
  24093. if (Dto.FileTypeId < 0 || Dto.FileTypeId > 2) return Ok(JsonView(false, "请传入有效的文件类型"));
  24094. var di = _sqlSugar.Queryable<Grp_DelegationInfo>()
  24095. .Where(x => x.IsDel == 0 && x.Id == Dto.GroupId)
  24096. .Select<DelegationEasyView>()
  24097. .First();
  24098. var main = _sqlSugar.Queryable<Grp_ConferenceAffairsCost>()
  24099. .First(x => x.Diid == Dto.GroupId && x.IsDel == 0);
  24100. if (main == null)
  24101. {
  24102. return Ok(JsonView(false, "团组会务成本信息不存在!"));
  24103. }
  24104. JsonView jw = JsonView(false);
  24105. //总表下载
  24106. var loadPath = $"{AppSettingsHelper.Get("ExcelBasePath")}ConferenceAffairs/template/";
  24107. var outputPath = $"{AppSettingsHelper.Get("ExcelBasePath")}ConferenceAffairs/output/total/";
  24108. var networkPath = outputPath.Replace(AppSettingsHelper.Get("ExcelBasePath"), AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath"));
  24109. var field = string.Empty;
  24110. var fileTypeName = string.Empty;
  24111. field = @$"
  24112. a.[Index],a.PriceName,a.CostPrice,a.Count,a.Coefficient,a.BaoJiaPrice,a.AddedValue,a.Details,a.Remark,a.Rate,
  24113. b.Name as PriceTypeStr ,
  24114. c.Name as CurrencyStr ,
  24115. d.Name as UnitStr ,
  24116. case a.ReviewStatus
  24117. WHEN 1 THEN '已通过'
  24118. WHEN 0 THEN '未审核'
  24119. WHEN -1 THEN '未通过'
  24120. ELSE '未审核'
  24121. END AS ReviewStatusStr
  24122. ";
  24123. if (Dto.FileTypeId == 0)
  24124. {
  24125. fileTypeName = "会务成本成本表";
  24126. loadPath += $"{fileTypeName}.xlsx";
  24127. outputPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  24128. networkPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  24129. }
  24130. else if (Dto.FileTypeId == 1)
  24131. {
  24132. fileTypeName = "会务成本报价表";
  24133. loadPath += $"{fileTypeName}.xlsx";
  24134. outputPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  24135. networkPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  24136. }
  24137. else if (Dto.FileTypeId == 2)
  24138. {
  24139. fileTypeName = "会务成本总表";
  24140. loadPath += $"{fileTypeName}.xlsx";
  24141. outputPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  24142. networkPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  24143. }
  24144. var chiExcelContent = _sqlSugar.SqlQueryable<ConferenceAffairsExcelContent>(@$"
  24145. SELECT
  24146. {field}
  24147. FROM Grp_ConferenceAffairsCostChild a
  24148. LEFT JOIN Sys_SetData b on b.IsDel = 0 AND b.Id = a.PriceType
  24149. LEFT JOIN Sys_SetData c on c.IsDel = 0 AND c.Id = a.Currency
  24150. LEFT JOIN Sys_SetData d on d.IsDel = 0 AND d.Id = a.Unit
  24151. WHERE a.isdel = 0
  24152. AND a.Diid = {main.Diid}
  24153. AND a.ConferenceAffairsCostId = {main.Id}
  24154. ").ToList();
  24155. var currLists = chiExcelContent.Select(x => new CurrList
  24156. {
  24157. CurrName = x.CurrencyStr,
  24158. CurrRate = x.Rate
  24159. })
  24160. .Distinct()
  24161. .ToList();
  24162. var designer = new WorkbookDesigner
  24163. {
  24164. Workbook = new Workbook(loadPath)
  24165. };
  24166. var MostCurr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.IsDel == 0 && x.Id == main.MostCurr);
  24167. MostCurr ??= new Sys_SetData { Name = "暂无!" };
  24168. designer.SetDataSource("TeamName", di.TeamName);
  24169. designer.SetDataSource("City", main.City);
  24170. designer.SetDataSource("AllCost", main.CostAll);
  24171. designer.SetDataSource("AllBaoJia", main.BaoJiaAll);
  24172. designer.SetDataSource("Curr", MostCurr.Name);
  24173. designer.SetDataSource("Curr1", MostCurr.Name);
  24174. DataTable dt = CommonFun.GetDataTableFromIList<ConferenceAffairsExcelContent>(chiExcelContent);
  24175. dt.TableName = "TB";
  24176. designer.SetDataSource(dt);
  24177. DataTable dt1 = CommonFun.GetDataTableFromIList<CurrList>(currLists);
  24178. dt1.TableName = "currTb";
  24179. designer.SetDataSource(dt1);
  24180. designer.Process();
  24181. designer.Workbook.Save(outputPath);
  24182. jw = JsonView(true, "操作成功!", new
  24183. {
  24184. FileName = $"{di.TeamName}_{fileTypeName}.xlsx",
  24185. FilePath = networkPath
  24186. });
  24187. return Ok(jw);
  24188. }
  24189. [HttpPost]
  24190. public async Task<IActionResult> QueryConferenceAffairsChild(QueryConferenceAffairsChildDto Dto)
  24191. {
  24192. return Ok(JsonView(true, "SUCCESS", _sqlSugar.Queryable<Grp_ConferenceAffairsCostChild>().Where(x => x.IsDel == 0 && x.Diid == Dto.GroupId)
  24193. .Select(x => x.PriceName).ToList()));
  24194. }
  24195. #endregion
  24196. #region 团组签证流程
  24197. /// <summary>
  24198. /// 团组签证流程 - 团组列表(分页)
  24199. /// </summary>
  24200. /// <returns></returns>
  24201. [HttpPost]
  24202. public async Task<IActionResult> VisaProcessGroupNames(VisaProcessGroupNamesDto dto)
  24203. {
  24204. int currUserId = dto.CurrUserId <= 0 ? 1 : dto.CurrUserId;
  24205. string groupName = dto.GroupName.Trim();
  24206. int pageIndex = dto.PageIndex <= 0 ? 1 : dto.PageIndex;
  24207. int pageSize = dto.PageSize <= 0 ? 10 : dto.PageSize;
  24208. int portType = dto.PortType;
  24209. RefAsync<int> total = 0;
  24210. var query = _sqlSugar.Queryable<Grp_GroupsTaskAssignment>()
  24211. .InnerJoin<Grp_DelegationInfo>((x, y) => x.DIId == y.Id)
  24212. .Where((x, y) => x.IsDel == 0 && x.CTId == 80 && x.UId == currUserId);
  24213. //构建单字模糊查询
  24214. if (!string.IsNullOrEmpty(groupName))
  24215. {
  24216. var characters = groupName.ToCharArray();
  24217. foreach (var character in characters)
  24218. {
  24219. var charString = character.ToString();
  24220. query = query.Where((x, y) =>
  24221. SqlFunc.Contains(y.TeamName, charString));
  24222. }
  24223. }
  24224. var groups = await query
  24225. .OrderByDescending((x, y) => y.VisitDate)
  24226. .Select((x, y) => new
  24227. {
  24228. y.Id,
  24229. GroupName = y.TeamName,
  24230. y.VisitDate
  24231. })
  24232. .Distinct()
  24233. .ToPageListAsync(pageIndex, pageSize, total);
  24234. var msg = "SUCCESS";
  24235. if (total <= 0) msg = "暂无可操作的团组,请联系经理分配团组!";
  24236. var groups1 = groups.Select(x => new { x.Id, x.GroupName }).ToList();
  24237. return Ok(JsonView(true, msg, groups1, total));
  24238. }
  24239. /// <summary>
  24240. /// 团组签证流程 - 详情
  24241. /// </summary>
  24242. /// <returns></returns>
  24243. [HttpPost]
  24244. public async Task<IActionResult> VisaProcessInfoByGroupId(VisaProcessInfoByGroupIdDto dto)
  24245. {
  24246. var res = await _visaProcessRep.Info(dto);
  24247. if (res.Code != 200) return Ok(JsonView(false, res.Msg));
  24248. return Ok(JsonView(true, res.Msg, res.Data));
  24249. }
  24250. /// <summary>
  24251. /// 团组签证流程 - 流程创建测试
  24252. /// </summary>
  24253. /// <returns></returns>
  24254. [HttpPost]
  24255. public async Task<IActionResult> VisaProcessAdd(int groupId, int currUserId)
  24256. {
  24257. return Ok(await _visaProcessRep.Create(currUserId, groupId));
  24258. }
  24259. /// <summary>
  24260. /// 团组签证流程 - 流程Top4Init 测试
  24261. /// </summary>
  24262. /// <returns></returns>
  24263. [HttpPost]
  24264. public async Task<IActionResult> VisaProcessTop4StepInit(int groupId, int currUserId)
  24265. {
  24266. return Ok(await _visaProcessRep.UpdateBatchTop4Step(groupId, currUserId));
  24267. }
  24268. /// <summary>
  24269. /// 团组签证流程 - 设置状态为已完成
  24270. /// </summary>
  24271. /// <returns></returns>
  24272. [HttpPost]
  24273. public async Task<IActionResult> VisaProcessSetCompleted(int id, int currUserId)
  24274. {
  24275. //参数验证
  24276. var stepValid = await _sqlSugar.Queryable<Grp_VisaProcessSteps>().Where(x => x.Id == id && x.IsDel == 0).AnyAsync();
  24277. if (!stepValid) return Ok(JsonView(false, "签证流程ID无效。"));
  24278. var userValid = await _sqlSugar.Queryable<Sys_Users>().Where(x => x.Id == currUserId && x.IsDel == 0).AnyAsync();
  24279. if (!userValid) return Ok(JsonView(false, "用户ID无效。"));
  24280. var res = await _visaProcessRep.SetCompleted(id, currUserId);
  24281. if (res.Code != 200) return Ok(JsonView(false, res.Msg));
  24282. return Ok(JsonView(true, res.Msg));
  24283. }
  24284. /// <summary>
  24285. /// 团组签证流程 - 修改各步骤内容
  24286. /// </summary>
  24287. /// <returns></returns>
  24288. [HttpPost]
  24289. public async Task<IActionResult> VisaProcessSetContent(VisaProcessSetContent dto)
  24290. {
  24291. //参数验证
  24292. var stepValid = await _sqlSugar.Queryable<Grp_VisaProcessSteps>().Where(x => x.Id == dto.StepId && x.IsDel == 0).FirstAsync();
  24293. if (stepValid == null) return Ok(JsonView(false, "签证流程ID无效。"));
  24294. var userValid = await _sqlSugar.Queryable<Sys_Users>().Where(x => x.Id == dto.CurrUserId && x.IsDel == 0).AnyAsync();
  24295. if (!userValid) return Ok(JsonView(false, "用户ID无效。"));
  24296. if (dto.StepContents == null && dto.StepContents.Count < 1)
  24297. {
  24298. return Ok(JsonView(false, "步骤内容无效。"));
  24299. }
  24300. //各步骤值处理
  24301. object stepVal;
  24302. if (stepValid.Step == 7) stepVal = dto.StepContents;
  24303. else stepVal = dto.StepContents[0].ToString();
  24304. var stepInfo = new Grp_VisaProcessSteps
  24305. {
  24306. Id = dto.StepId,
  24307. DataType = stepValid.DataType,
  24308. TypedValue = stepVal,
  24309. LastUpdateUserId = dto.CurrUserId
  24310. };
  24311. var res = await _visaProcessRep.Update(stepInfo);
  24312. if (res.Code != 200) return Ok(JsonView(false, res.Msg));
  24313. return Ok(JsonView(true, res.Msg));
  24314. }
  24315. /// <summary>
  24316. /// 团组签证流程 - 上传文件
  24317. /// </summary>
  24318. /// <returns></returns>
  24319. [HttpPost]
  24320. public async Task<IActionResult> VisaProcessUploadFiles([FromForm] VisaProcessUploadFilesDto dto)
  24321. {
  24322. //参数验证
  24323. var stepValid = await _sqlSugar.Queryable<Grp_VisaProcessSteps>().Where(x => x.Id == dto.StepId && x.IsDel == 0).FirstAsync();
  24324. if (stepValid == null) return Ok(JsonView(false, "签证流程ID无效。"));
  24325. var userValid = await _sqlSugar.Queryable<Sys_Users>().Where(x => x.Id == dto.CurrUserId && x.IsDel == 0).AnyAsync();
  24326. if (!userValid) return Ok(JsonView(false, "用户ID无效。"));
  24327. //验证文件是否存在
  24328. if (dto.Files == null || dto.Files.Count < 1) return Ok(JsonView(false, "请选择文件。"));
  24329. //验证该步骤是否可以上传文件
  24330. var uploadSteps = new List<int>() {
  24331. 5, //实际出签时间
  24332. 6, //是否需要开出境证明
  24333. 7, //是否需要办理电子入境卡手续
  24334. };
  24335. if (!uploadSteps.Contains(stepValid.Step))
  24336. {
  24337. return Ok(JsonView(false, $"该步骤不可上传附件。可上传附件步骤({string.Join("、", uploadSteps)})"));
  24338. }
  24339. //验证根目录
  24340. string rootRrl = AppSettingsHelper.Get("OfficeBaseUrl");
  24341. string rootPath = AppSettingsHelper.Get("OfficeTempBasePath");
  24342. if (!System.IO.Directory.Exists(rootPath))
  24343. {
  24344. System.IO.Directory.CreateDirectory(rootPath);
  24345. }
  24346. //验证签证流程上传文件夹 //按照团组名称存储文件夹 GrpFile/VisaProcessFiles/
  24347. var groupName = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  24348. .Where(x => x.IsDel == 0 && x.Id == stepValid.GroupId)
  24349. .Select(x => $"{x.TeamName}({x.Id})")
  24350. .FirstAsync();
  24351. //创建团组文件夹
  24352. var groupPath = rootPath + "GrpFile/VisaProcessFiles/" + groupName;
  24353. if (!System.IO.Directory.Exists(groupPath))
  24354. {
  24355. System.IO.Directory.CreateDirectory(groupPath);
  24356. }
  24357. List<string> filePaths = new List<string>();
  24358. //保存文件
  24359. foreach (var file in dto.Files)
  24360. {
  24361. // 生成存储文件名
  24362. var fileName = CommonFun.GenerateStoredFileName($"Step{stepValid.Step}.{file.FileName.Split(".")[1]}");
  24363. var filePath = Path.Combine(groupPath, fileName);
  24364. // 保存文件到磁盘
  24365. using (var stream = new FileStream(filePath, FileMode.Create))
  24366. {
  24367. await file.CopyToAsync(stream);
  24368. }
  24369. filePaths.Add($"GrpFile/VisaProcessFiles/{groupName}/{fileName}");
  24370. }
  24371. //数据库存储
  24372. var stepInfo = new Grp_VisaProcessSteps
  24373. {
  24374. Id = dto.StepId,
  24375. TypedFileNameValue = filePaths,
  24376. LastUpdateUserId = dto.CurrUserId
  24377. };
  24378. var res = await _sqlSugar.Updateable<Grp_VisaProcessSteps>()
  24379. .SetColumns(s => new Grp_VisaProcessSteps
  24380. {
  24381. AttachUrl = stepInfo.AttachUrl,
  24382. LastUpdateUserId = dto.CurrUserId,
  24383. LastUpdateTime = DateTime.Now
  24384. })
  24385. .Where(s => s.Id == dto.StepId && s.IsDel == 0)
  24386. .ExecuteCommandAsync();
  24387. if (res < 1) Ok(JsonView(false, "文件上传失败。"));
  24388. return Ok(JsonView(true));
  24389. }
  24390. /// <summary>
  24391. /// 团组签证流程 - step 7 资料下载
  24392. /// </summary>
  24393. /// <returns></returns>
  24394. [HttpPost]
  24395. public async Task<IActionResult> VisaProcessDownload(int groupId)
  24396. {
  24397. //验证根目录
  24398. string rootRrl = AppSettingsHelper.Get("OfficeBaseUrl");
  24399. string rootPath = AppSettingsHelper.Get("OfficeTempBasePath");
  24400. if (!System.IO.Directory.Exists(rootPath))
  24401. {
  24402. System.IO.Directory.CreateDirectory(rootPath);
  24403. }
  24404. //验证签证流程上传文件夹 //按照团组名称存储文件夹 GrpFile/VisaProcessFiles/
  24405. var groupName = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  24406. .Where(x => x.IsDel == 0 && x.Id == groupId)
  24407. .Select(x => $"{x.TeamName}({x.Id})")
  24408. .FirstAsync();
  24409. //创建团组文件夹
  24410. var timestamp = DateTime.Now.ToString("yyyyMMddHHmmss");
  24411. var randomStr = Guid.NewGuid().ToString("N").Substring(0, 8);
  24412. var dirName = $"{groupName}_相关资料_{timestamp}";
  24413. var sourceDirectoryPath = $"{rootPath}/GrpFile/VisaProcessFiles/{groupName}";
  24414. var path = $"{rootPath}/GrpFile/VisaProcessFiles/{groupName}/{dirName}";
  24415. if (!System.IO.Directory.Exists(path))
  24416. {
  24417. System.IO.Directory.CreateDirectory(path);
  24418. }
  24419. //验证接团客户名单
  24420. string sql = string.Format(@"
  24421. SELECT
  24422. tcl.Id,
  24423. tcl.DiId,
  24424. tcl.IsAccompany,
  24425. temp.*,
  24426. u.CnName AS Operator,
  24427. tcl.CreateTime AS OperatingTime,
  24428. ssd.name AS ShippingSpaceType
  24429. FROM
  24430. Grp_TourClientList tcl
  24431. LEFT JOIN (
  24432. SELECT
  24433. dc.Id AS DcId,
  24434. dc.LastName,
  24435. dc.FirstName,
  24436. ccom.CompanyFullName,
  24437. dc.Job,
  24438. cc.CertNo AS IDCardNo,
  24439. dc.Sex,
  24440. dc.BirthDay
  24441. FROM
  24442. Crm_DeleClient dc
  24443. LEFT JOIN Crm_CustomerCompany ccom ON dc.CrmCompanyId = ccom.Id
  24444. AND ccom.IsDel = 0
  24445. LEFT JOIN Crm_CustomerCert cc ON dc.Id = cc.DcId
  24446. AND cc.SdId = 773
  24447. AND cc.IsDel = 0
  24448. WHERE
  24449. dc.IsDel = 0
  24450. ) temp ON temp.DcId = tcl.ClientId
  24451. LEFT JOIN Sys_Users u ON tcl.CreateUserId = u.Id
  24452. LEFT JOIN sys_setdata ssd ON ssd.isdel = 0 AND ssd.id = tcl.ShippingSpaceTypeid
  24453. WHERE
  24454. tcl.IsDel = 0
  24455. AND tcl.DiId = {0}", groupId);
  24456. var groupClientList = await _sqlSugar.SqlQueryable<TourClientInfosView>(sql).ToListAsync();
  24457. //解密
  24458. foreach (var item in groupClientList)
  24459. {
  24460. EncryptionProcessor.DecryptProperties(item);
  24461. }
  24462. if (groupClientList == null || groupClientList.Count < 1)
  24463. {
  24464. return Ok(JsonView(false, $"团组客户名单未录入客户信息,不可生成相关资料。"));
  24465. }
  24466. #region 生成文件
  24467. //酒店信息
  24468. var hotelInfos = await _sqlSugar.Queryable<Grp_HotelReservations>()
  24469. .Where(x => x.IsDel == 0 && x.DiId == groupId)
  24470. .OrderBy(x => x.CheckInDate)
  24471. .ToListAsync();
  24472. //航班信息
  24473. var airInfos = await _sqlSugar.Queryable<Grp_AirTicketReservations>()
  24474. .Where(x => x.IsDel == 0 && x.DIId == groupId)
  24475. .OrderBy(x => x.FlightsDate)
  24476. .ToListAsync();
  24477. foreach (var clientInfo in groupClientList)
  24478. {
  24479. var clientId = clientInfo.DcId;
  24480. var guestName = $"{clientInfo.LastName}{clientInfo.FirstName}";
  24481. #region 个人信息资料
  24482. #endregion
  24483. #region 机票航班信息
  24484. var clientAirInfos = airInfos.Where(x => x.ClientName.Contains(clientId.ToString())).ToList();
  24485. if (clientAirInfos != null && clientAirInfos.Count > 0)
  24486. {
  24487. //创建表格
  24488. Document airDoc = new Document();
  24489. DocumentBuilder airBuilder = new DocumentBuilder(airDoc);
  24490. GeneralMethod.SetupDocumentStyles(airBuilder);
  24491. GeneralMethod.AddTitle(airBuilder, $"{guestName} - 机票信息");
  24492. GeneralMethod.AddAirInfoSections(airBuilder, clientAirInfos, "机票航班信息");
  24493. var airRandomStr = Guid.NewGuid().ToString("N").Substring(0, 8);
  24494. var airFileName = $"{guestName}_机票信息_{airRandomStr}.docx";
  24495. airDoc.Save($"{path}/{airFileName}");
  24496. }
  24497. #endregion
  24498. #region 酒店信息
  24499. var clientHotelInfos = hotelInfos.Where(x => x.GuestName.Contains(clientId.ToString())).ToList();
  24500. if (clientHotelInfos != null && clientHotelInfos.Count > 0)
  24501. {
  24502. //创建表格
  24503. Document hotelDoc = new Document();
  24504. DocumentBuilder HotelBuilder = new DocumentBuilder(hotelDoc);
  24505. GeneralMethod.SetupDocumentStyles(HotelBuilder);
  24506. GeneralMethod.AddTitle(HotelBuilder, $"{guestName} - 酒店信息");
  24507. GeneralMethod.AddHotelInfoSections(HotelBuilder, clientHotelInfos, "酒店信息");
  24508. var hotelRandomStr = Guid.NewGuid().ToString("N").Substring(0, 8);
  24509. var hotelFileName = $"{guestName}_酒店信息_{hotelRandomStr}.docx";
  24510. hotelDoc.Save($"{path}/{hotelFileName}");
  24511. }
  24512. #endregion
  24513. }
  24514. #endregion
  24515. //打包文件夹
  24516. var sourceDirectory = $"{sourceDirectoryPath}/{dirName}";
  24517. var zipFilePath = $"{sourceDirectoryPath}/{dirName}.zip";
  24518. if (System.IO.File.Exists(zipFilePath))
  24519. {
  24520. System.IO.File.Delete(zipFilePath);
  24521. }
  24522. ZipFile.CreateFromDirectory(sourceDirectory, zipFilePath, CompressionLevel.Fastest, false);
  24523. // 等待并验证
  24524. await Task.Delay(300); // 给系统时间完成文件操作
  24525. if (System.IO.File.Exists(zipFilePath))
  24526. {
  24527. var fileInfo = new FileInfo(zipFilePath);
  24528. var url = $"{rootRrl}GrpFile/VisaProcessFiles/{groupName}/{dirName}.zip";
  24529. return Ok(JsonView(url));
  24530. }
  24531. return Ok(JsonView(false));
  24532. }
  24533. #endregion
  24534. /// <summary>
  24535. /// 123132123
  24536. /// </summary>
  24537. /// <param name="_dto"></param>
  24538. /// <returns></returns>
  24539. [HttpPost]
  24540. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  24541. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  24542. {
  24543. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  24544. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  24545. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  24546. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  24547. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  24548. dicDetail.Add(789, 1034);
  24549. dicDetail.Add(790, 1035);
  24550. dicDetail.Add(791, 1036);
  24551. dicDetail.Add(792, 1037);
  24552. dicDetail.Add(793, 1038);
  24553. dicDetail.Add(794, 1039);
  24554. dicDetail.Add(795, 1040);
  24555. dicDetail.Add(796, 1041);
  24556. dicDetail.Add(797, 1042);
  24557. dicDetail.Add(798, 1043);
  24558. dicDetail.Add(801, 1044);
  24559. dicDetail.Add(802, 1045);
  24560. dicDetail.Add(803, 1046);
  24561. Dictionary<int, int> dic = new Dictionary<int, int>();
  24562. dic.Add(806, 1027);
  24563. dic.Add(807, 1028);
  24564. dic.Add(808, 1029);
  24565. dic.Add(809, 1030);
  24566. dic.Add(810, 1031);
  24567. dic.Add(811, 1032);
  24568. dic.Add(812, 1033);
  24569. foreach (var item in list_visa)
  24570. {
  24571. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  24572. temp.Coefficient = item.coefficient;
  24573. DateTime dtCrt;
  24574. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  24575. if (b1)
  24576. {
  24577. temp.CreateTime = dtCrt;
  24578. }
  24579. else
  24580. {
  24581. temp.CreateTime = DateTime.Now;
  24582. }
  24583. temp.CreateUserId = item.Operators;
  24584. temp.DeleteTime = "";
  24585. temp.DeleteUserId = 0;
  24586. temp.DiId = int.Parse(item.DIID);
  24587. temp.FilePath = item.FilePath;
  24588. temp.IsDel = item.IsDel;
  24589. temp.Price = item.Price;
  24590. temp.PriceCount = 1;
  24591. temp.PriceCurrency = item.Currency;
  24592. int detailId = 0;
  24593. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  24594. {
  24595. detailId = dicDetail[item.PriceTypeDetail];
  24596. }
  24597. temp.PriceDetailType = detailId;
  24598. temp.PriceDt = DateTime.Now;
  24599. temp.PriceName = item.PriceName;
  24600. temp.PriceSum = item.Price;
  24601. int tid = 0;
  24602. if (dic.ContainsKey(item.PriceType))
  24603. {
  24604. tid = dic[item.PriceType];
  24605. }
  24606. temp.PriceType = tid;
  24607. temp.Remark = item.Remark;
  24608. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  24609. }
  24610. return Ok(JsonView(true, "操作成功!"));
  24611. }
  24612. [HttpPost]
  24613. public IActionResult TimeTest()
  24614. {
  24615. var jw = JsonView(false, "error");
  24616. _sqlSugar.BeginTran();
  24617. try
  24618. {
  24619. var clientList = _sqlSugar.Queryable<Crm_NewClientData>()
  24620. .Select(x => new Crm_NewClientData
  24621. {
  24622. Id = x.Id,
  24623. Client = x.Client,
  24624. Contact = x.Contact,
  24625. Location = x.Location,
  24626. })
  24627. .ToList();
  24628. var ids = clientList.Where(x => !string.IsNullOrEmpty(x.Client) && x.Client.Contains("重庆")).Select(x => x.Id).ToList();
  24629. _sqlSugar.Queryable<Crm_NewClientData>().Where(x => ids.Contains(x.Id)).ToList();
  24630. Stopwatch stopwatch = new Stopwatch();
  24631. // 开始计时
  24632. stopwatch.Start();
  24633. foreach (var item in clientList)
  24634. {
  24635. EncryptionProcessor.DecryptProperties(item);
  24636. }
  24637. stopwatch.Stop();
  24638. jw.Code = 200;
  24639. jw.Data = stopwatch.ElapsedMilliseconds;
  24640. jw.Msg = "运算耗时: " + stopwatch.ElapsedMilliseconds + " 毫秒,解密条数: " + clientList.Count;
  24641. }
  24642. catch (Exception ex)
  24643. {
  24644. jw.Code = 400;
  24645. jw.Msg = ex.Message;
  24646. }
  24647. return Ok(jw);
  24648. }
  24649. [HttpPost]
  24650. public async Task<IActionResult> TimeTest1()
  24651. {
  24652. var infos = await _sqlSugar.Queryable<Crm_DeleClient>().ToListAsync();
  24653. return Ok(infos);
  24654. }
  24655. }
  24656. }