GroupsController.cs 1.3 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876
  1. using Aspose.Cells;
  2. using Aspose.Words;
  3. using Aspose.Words.Drawing;
  4. using Aspose.Words.Tables;
  5. using DiffMatchPatch;
  6. using Dm.util;
  7. using Microsoft.AspNetCore.SignalR;
  8. using NPOI.SS.Formula.Functions;
  9. using NPOI.SS.UserModel;
  10. using NPOI.SS.Util;
  11. using NPOI.XSSF.UserModel;
  12. using OASystem.API.Middlewares;
  13. using OASystem.API.OAMethodLib;
  14. using OASystem.API.OAMethodLib.APNs;
  15. using OASystem.API.OAMethodLib.DeepSeekAPI;
  16. using OASystem.API.OAMethodLib.File;
  17. using OASystem.API.OAMethodLib.Hub.HubClients;
  18. using OASystem.API.OAMethodLib.Hub.Hubs;
  19. using OASystem.API.OAMethodLib.JuHeAPI;
  20. using OASystem.API.OAMethodLib.KiMiApi;
  21. using OASystem.API.OAMethodLib.Logging;
  22. using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
  23. using OASystem.Domain.AesEncryption;
  24. using OASystem.Domain.Attributes;
  25. using OASystem.Domain.Dtos.CRM;
  26. using OASystem.Domain.Dtos.FileDto;
  27. using OASystem.Domain.Dtos.Financial;
  28. using OASystem.Domain.Dtos.Groups;
  29. using OASystem.Domain.Entities.Customer;
  30. using OASystem.Domain.Entities.Financial;
  31. using OASystem.Domain.Entities.Groups;
  32. using OASystem.Domain.ViewModels.CRM;
  33. using OASystem.Domain.ViewModels.Financial;
  34. using OASystem.Domain.ViewModels.Groups;
  35. using OASystem.Domain.ViewModels.OCR;
  36. using OASystem.Infrastructure.Repositories.CRM;
  37. using OASystem.Infrastructure.Repositories.Financial;
  38. using OASystem.Infrastructure.Repositories.Groups;
  39. using Quartz.Logging;
  40. using Quartz.Util;
  41. using SQLitePCL;
  42. using SqlSugar.Extensions;
  43. using System.Collections;
  44. using System.ComponentModel.DataAnnotations;
  45. using System.Data;
  46. using System.Diagnostics;
  47. using System.Globalization;
  48. using System.IO;
  49. using System.IO.Compression;
  50. using System.Linq.Expressions;
  51. using System.Text.Json;
  52. using System.Text.RegularExpressions;
  53. using System.Threading.Tasks;
  54. using System.Web;
  55. using static OASystem.API.OAMethodLib.JWTHelper;
  56. using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
  57. using static OpenAI.GPT3.ObjectModels.SharedModels.IOpenAiModels;
  58. using Bookmark = Aspose.Words.Bookmark;
  59. using Cell = Aspose.Words.Tables.Cell;
  60. using Table = Aspose.Words.Tables.Table;
  61. namespace OASystem.API.Controllers
  62. {
  63. /// <summary>
  64. /// 团组相关
  65. /// </summary>
  66. //[Authorize]
  67. [Route("api/[controller]/[action]")]
  68. public class GroupsController : ControllerBase
  69. {
  70. private readonly ILogger<GroupsController> _logger;
  71. private readonly ITextFileLogger _eec_textLogger;
  72. private readonly IGroupTextFileLogger _groupTextLogger;
  73. private readonly GrpScheduleRepository _grpScheduleRep;
  74. private readonly IMapper _mapper;
  75. private readonly DelegationInfoRepository _groupRepository;
  76. private readonly TaskAssignmentRepository _taskAssignmentRep;
  77. private readonly AirTicketResRepository _airTicketResRep;
  78. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  79. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  80. private readonly DelegationEnDataRepository _delegationEnDataRep;
  81. private readonly DelegationVisaRepository _delegationVisaRep;
  82. private readonly VisaPriceRepository _visaPriceRep;
  83. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  84. private readonly HotelPriceRepository _hotelPriceRep;
  85. private readonly CustomersRepository _customersRep;
  86. private readonly MessageRepository _message;
  87. private readonly SqlSugarClient _sqlSugar;
  88. private readonly TourClientListRepository _tourClientListRep;
  89. private readonly TeamRateRepository _teamRateRep;
  90. #region 成本相关
  91. private readonly CheckBoxsRepository _checkBoxs;
  92. private readonly GroupCostRepository _GroupCostRepository;
  93. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  94. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  95. #endregion
  96. private readonly SetDataRepository _setDataRep;
  97. private string url;
  98. private string path;
  99. private readonly EnterExitCostRepository _enterExitCostRep;
  100. private readonly IHubContext<ChatHub, IChatClient> _hubContext;
  101. private readonly UsersRepository _usersRep;
  102. private readonly IJuHeApiService _juHeApi;
  103. private readonly InvertedListRepository _invertedListRep;
  104. private readonly VisaFeeInfoRepository _visaFeeInfoRep;
  105. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  106. private readonly ThreeCodeRepository _threeCodeRepository;
  107. private readonly HotelInquiryRepository _hotelInquiryRep;
  108. private readonly FeeAuditRepository _feeAuditRep;
  109. private readonly VisaCommissionRepository _visaCommissionRep;
  110. private readonly ForeignReceivablesRepository _ffrRep; //对外收款账单仓库
  111. private readonly OpinionaireRepository _opinionaireRep; //对外收款账单仓库
  112. private readonly List<CurrencyInfo> _currencyInit;
  113. private readonly List<int> _portTypeData;
  114. private readonly TableOperationRecordRepository _tableorRep;
  115. private readonly EnterExitCostDraftRepository _enterExitCostDraftRep;
  116. private readonly RestaurantRepository _restaurantRep;
  117. private readonly EnterExitCostQuoteRepository _enterExitCostQuoteRep;
  118. private readonly GroupOrderPreInfoRepository _grpOrderPreInfoRep;
  119. private readonly VisaProcessRepository _visaProcessRep;
  120. private readonly ProcessOverviewRepository _processOverviewRep;
  121. private readonly IDeepSeekService _deepSeekService;
  122. /// <summary>
  123. /// 构造函数
  124. /// </summary>
  125. /// <param name="logger"></param>
  126. /// <param name="eec_textLogger"></param>
  127. /// <param name="groupTextLogger"></param>
  128. /// <param name="mapper"></param>
  129. /// <param name="hubContext"></param>
  130. /// <param name="sqlSugar"></param>
  131. /// <param name="grpScheduleRep"></param>
  132. /// <param name="groupRepository"></param>
  133. /// <param name="taskAssignmentRep"></param>
  134. /// <param name="airTicketResRep"></param>
  135. /// <param name="decreasePaymentsRep"></param>
  136. /// <param name="InvitationOfficialActivitiesRep"></param>
  137. /// <param name="delegationEnDataRep"></param>
  138. /// <param name="enterExitCostRep"></param>
  139. /// <param name="delegationVisaRep"></param>
  140. /// <param name="message"></param>
  141. /// <param name="visaPriceRep"></param>
  142. /// <param name="carTouristGuideGroundRep"></param>
  143. /// <param name="checkBoxs"></param>
  144. /// <param name="GroupCostRepository"></param>
  145. /// <param name="CostTypeHotelNumberRepository"></param>
  146. /// <param name="GroupCostParameterRepository"></param>
  147. /// <param name="hotelPriceRep"></param>
  148. /// <param name="customersRep"></param>
  149. /// <param name="setDataRep"></param>
  150. /// <param name="tourClientListRep"></param>
  151. /// <param name="teamRateRep"></param>
  152. /// <param name="usersRep"></param>
  153. /// <param name="juHeApi"></param>
  154. /// <param name="invertedListRep"></param>
  155. /// <param name="visaFeeInfoRep"></param>
  156. /// <param name="ticketBlackCodeRep"></param>
  157. /// <param name="hotelInquiryRep"></param>
  158. /// <param name="threeCodeRepository"></param>
  159. /// <param name="feeAuditRep"></param>
  160. /// <param name="visaCommissionRep"></param>
  161. /// <param name="ffrRep"></param>
  162. /// <param name="opinionaireRep"></param>
  163. /// <param name="tableorRep"></param>
  164. /// <param name="enterExitCostDraftRep"></param>
  165. /// <param name="restaurantRep"></param>
  166. /// <param name="enterExitCostQuoteRep"></param>
  167. /// <param name="grpOrderPreInfoRep"></param>
  168. /// <param name="visaProcessRep"></param>
  169. /// <param name="processOverviewRep"></param>
  170. public GroupsController(
  171. ILogger<GroupsController> logger,
  172. ITextFileLogger eec_textLogger,
  173. IGroupTextFileLogger groupTextLogger,
  174. IMapper mapper,
  175. IHubContext<ChatHub, IChatClient> hubContext,
  176. SqlSugarClient sqlSugar,
  177. GrpScheduleRepository grpScheduleRep,
  178. DelegationInfoRepository groupRepository,
  179. TaskAssignmentRepository taskAssignmentRep,
  180. AirTicketResRepository airTicketResRep,
  181. DecreasePaymentsRepository decreasePaymentsRep,
  182. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep,
  183. DelegationEnDataRepository delegationEnDataRep,
  184. EnterExitCostRepository enterExitCostRep,
  185. DelegationVisaRepository delegationVisaRep,
  186. MessageRepository message,
  187. VisaPriceRepository visaPriceRep,
  188. CarTouristGuideGroundRepository carTouristGuideGroundRep,
  189. CheckBoxsRepository checkBoxs,
  190. GroupCostRepository GroupCostRepository,
  191. CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  192. GroupCostParameterRepository GroupCostParameterRepository,
  193. HotelPriceRepository hotelPriceRep,
  194. CustomersRepository customersRep,
  195. SetDataRepository setDataRep,
  196. TourClientListRepository tourClientListRep,
  197. TeamRateRepository teamRateRep,
  198. UsersRepository usersRep,
  199. IJuHeApiService juHeApi,
  200. InvertedListRepository invertedListRep,
  201. VisaFeeInfoRepository visaFeeInfoRep,
  202. TicketBlackCodeRepository ticketBlackCodeRep,
  203. HotelInquiryRepository hotelInquiryRep,
  204. ThreeCodeRepository threeCodeRepository,
  205. FeeAuditRepository feeAuditRep,
  206. VisaCommissionRepository visaCommissionRep,
  207. ForeignReceivablesRepository ffrRep,
  208. OpinionaireRepository opinionaireRep,
  209. TableOperationRecordRepository tableorRep,
  210. EnterExitCostDraftRepository enterExitCostDraftRep,
  211. RestaurantRepository restaurantRep,
  212. EnterExitCostQuoteRepository enterExitCostQuoteRep,
  213. GroupOrderPreInfoRepository grpOrderPreInfoRep,
  214. VisaProcessRepository visaProcessRep,
  215. ProcessOverviewRepository processOverviewRep
  216. )
  217. {
  218. _logger = logger;
  219. _eec_textLogger = eec_textLogger;
  220. _groupTextLogger = groupTextLogger;
  221. _mapper = mapper;
  222. _grpScheduleRep = grpScheduleRep;
  223. _groupRepository = groupRepository;
  224. _taskAssignmentRep = taskAssignmentRep;
  225. _airTicketResRep = airTicketResRep;
  226. _sqlSugar = sqlSugar;
  227. url = AppSettingsHelper.Get("ExcelBaseUrl");
  228. path = AppSettingsHelper.Get("ExcelBasePath");
  229. if (!System.IO.Directory.Exists(path))
  230. {
  231. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  232. }
  233. _decreasePaymentsRep = decreasePaymentsRep;
  234. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  235. _delegationEnDataRep = delegationEnDataRep;
  236. _enterExitCostRep = enterExitCostRep;
  237. _delegationVisaRep = delegationVisaRep;
  238. _message = message;
  239. _visaPriceRep = visaPriceRep;
  240. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  241. _checkBoxs = checkBoxs;
  242. _GroupCostRepository = GroupCostRepository;
  243. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  244. _GroupCostParameterRepository = GroupCostParameterRepository;
  245. _hotelPriceRep = hotelPriceRep;
  246. _customersRep = customersRep;
  247. _setDataRep = setDataRep;
  248. _tourClientListRep = tourClientListRep;
  249. _teamRateRep = teamRateRep;
  250. _hubContext = hubContext;
  251. _usersRep = usersRep;
  252. _juHeApi = juHeApi;
  253. _invertedListRep = invertedListRep;
  254. _visaFeeInfoRep = visaFeeInfoRep;
  255. _ticketBlackCodeRep = ticketBlackCodeRep;
  256. _hotelInquiryRep = hotelInquiryRep;
  257. _threeCodeRepository = threeCodeRepository;
  258. _feeAuditRep = feeAuditRep;
  259. _visaCommissionRep = visaCommissionRep;
  260. _ffrRep = ffrRep;
  261. _opinionaireRep = opinionaireRep;
  262. _currencyInit = new List<CurrencyInfo>()
  263. {
  264. new(){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  265. new(){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  266. new(){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  267. new(){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  268. new(){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  269. };
  270. _portTypeData = new List<int>() { 2, 3 };
  271. _tableorRep = tableorRep;
  272. _enterExitCostDraftRep = enterExitCostDraftRep;
  273. _restaurantRep = restaurantRep;
  274. _enterExitCostQuoteRep = enterExitCostQuoteRep;
  275. _grpOrderPreInfoRep = grpOrderPreInfoRep;
  276. _visaProcessRep = visaProcessRep;
  277. _processOverviewRep = processOverviewRep;
  278. }
  279. #region 流程管控
  280. /// <summary>
  281. /// 获取团组流程管控信息
  282. /// </summary>
  283. /// <param name="_jsonDto">查询参数</param>
  284. /// <returns></returns>
  285. [HttpPost]
  286. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  287. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  288. {
  289. if (string.IsNullOrEmpty(_jsonDto.Paras))
  290. {
  291. return Ok(JsonView(false, "参数为空"));
  292. }
  293. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  294. if (_ScheduleDto != null)
  295. {
  296. if (_ScheduleDto.SearchType == 2)//获取列表
  297. {
  298. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  299. return Ok(JsonView(_grpScheduleViewList));
  300. }
  301. else//获取对象
  302. {
  303. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  304. if (_grpScheduleView != null)
  305. {
  306. return Ok(JsonView(_grpScheduleView));
  307. }
  308. }
  309. }
  310. else
  311. {
  312. return Ok(JsonView(false, "参数反序列化失败"));
  313. }
  314. return Ok(JsonView(false, "暂无数据!"));
  315. }
  316. /// <summary>
  317. /// 修改团组流程管控详细表数据
  318. /// </summary>
  319. /// <param name="dto"></param>
  320. /// <returns></returns>
  321. [HttpPost]
  322. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  323. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  324. {
  325. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  326. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  327. .SetColumns(it => it.Duty == _detail.Duty)
  328. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  329. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  330. .SetColumns(it => it.JobContent == _detail.JobContent)
  331. .SetColumns(it => it.Remark == _detail.Remark)
  332. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  333. .Where(s => s.Id == dto.Id)
  334. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  335. .ExecuteCommandAsync();
  336. if (result > 0)
  337. {
  338. return Ok(JsonView(true, "保存成功!"));
  339. }
  340. return Ok(JsonView(false, "保存失败!"));
  341. }
  342. /// <summary>
  343. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  344. /// </summary>
  345. /// <param name="dto"></param>
  346. /// <returns></returns>
  347. [HttpPost]
  348. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  349. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  350. {
  351. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  352. _detail.IsDel = 1;
  353. _detail.DeleteUserId = dto.Duty;
  354. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  355. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  356. .SetColumns(it => it.IsDel == _detail.IsDel)
  357. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  358. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  359. .Where(it => it.Id == dto.Id)
  360. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  361. //.WhereColumns(s => s.Id == dto.Id)
  362. .ExecuteCommandAsync();
  363. if (result > 0)
  364. {
  365. return Ok(JsonView(true, "删除成功!"));
  366. }
  367. return Ok(JsonView(false, "删除失败!"));
  368. }
  369. /// <summary>
  370. /// 增加团组流程管控详细表数据
  371. /// </summary>
  372. /// <param name="dto"></param>
  373. /// <returns></returns>
  374. [HttpPost]
  375. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  376. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  377. {
  378. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  379. if (DateTime.Now < _detail.ExpectBeginDt)
  380. {
  381. _detail.StepStatus = 0;
  382. }
  383. else
  384. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  385. _detail.StepStatus = 1;
  386. }
  387. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  388. if (result > 0)
  389. {
  390. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  391. return Ok(JsonView(true, "添加成功!", _result));
  392. }
  393. return Ok(JsonView(false, "添加失败!"));
  394. }
  395. #endregion
  396. #region 团组前期信息
  397. /// <summary>
  398. /// 团组前期信息H5-URL(员工对应地址)
  399. /// </summary>
  400. /// <param name="name">用户名称</param>
  401. /// <returns></returns>
  402. [HttpGet]
  403. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  404. public async Task<IActionResult> GroupOrderPreInfoH5URLList([FromQuery] string name)
  405. {
  406. var userURLs = await _sqlSugar.Queryable<Sys_Users>()
  407. .Where(x => x.IsDel == 0)
  408. .WhereIF(!string.IsNullOrEmpty(name), x => x.CnName.Contains(name))
  409. .OrderBy(x => x.Id)
  410. .Select(x => new
  411. {
  412. name = x.CnName,
  413. url = $"http://oa.pan-american-intl.com:4399/#/MarketplacePick?userid={x.Id}",
  414. })
  415. .ToListAsync();
  416. return Ok(JsonView(true, "操作成功!", userURLs, userURLs.Count));
  417. }
  418. /// <summary>
  419. /// 团组前期信息 List
  420. /// </summary>
  421. /// <returns></returns>
  422. [HttpPost]
  423. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  424. public async Task<IActionResult> GroupOrderPreInfoList(GroupOrderPreInfoListDto dto)
  425. {
  426. var search = dto.Search;
  427. int[] nameTempIds = new int[] { 1, 12, 28 },
  428. countryTempIds = new int[] { 2, 13, 29 },
  429. daysTempIds = new int[] { 4, 15, 31 },
  430. ppNumTempIds = new int[] { 6 };
  431. var list = await _sqlSugar.Queryable<Grp_OrderPreInfo>()
  432. .LeftJoin<Sys_Users>((opi, u) => opi.CreateUserId == u.Id)
  433. .Where((opi, u) => opi.IsDel == 0)
  434. .OrderByDescending((opi, u) => opi.CreateTime)
  435. .Select((opi, u) => new GroupOrderPreInfoListView()
  436. {
  437. Id = opi.Id,
  438. Name = opi.Name,
  439. UnitName = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && nameTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  440. VisitCountryVal = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && countryTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  441. VisitDays = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && daysTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  442. VisiPpNum = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && ppNumTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  443. Operator = u.CnName,
  444. OperationTime = opi.CreateTime
  445. })
  446. //.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search) || x.UnitName.Contains(search) || x.VisitCountrys.Contains(search))
  447. //.ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  448. .ToListAsync();
  449. var listPageData = list.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search) || x.UnitName.Contains(search) || x.VisitCountrys.Contains(search)).ToList();
  450. int total = list.Count;
  451. int totalPageCount = (int)Math.Ceiling(list.Count / (double)dto.PageSize);
  452. var listPageData1 = listPageData
  453. .Skip((dto.PageIndex - 1) * dto.PageSize)
  454. .Take(dto.PageSize)
  455. .ToList();
  456. var infoIds = listPageData1.Select(x => x.Id).ToList();
  457. var typeDatas = await _sqlSugar.Queryable<Sys_SetData>()
  458. .Where(x => x.IsDel == 0 && x.STid == 109)
  459. .ToArrayAsync();
  460. var items = await _sqlSugar.Queryable<Grp_OrderPreItem>()
  461. .LeftJoin<Sys_FormTemp>((opi, ft) => opi.FormTempId == ft.Id)
  462. .Where((opi, ft) => opi.IsDel == 0 && infoIds.Contains(opi.ParentId))
  463. .Select((opi, ft) => new { opi.ParentId, opi.FormTempId, ft.TempId })
  464. .ToListAsync();
  465. foreach (var item in listPageData1)
  466. {
  467. var typeDatas1 = typeDatas.Select(x => new
  468. {
  469. x.Id,
  470. x.Name,
  471. IsNull = !items.Any(x1 => item.Id == x1.ParentId && x.Id == x1.TempId)
  472. }).ToArray();
  473. item.VersionDetails = typeDatas1;
  474. }
  475. return Ok(JsonView(listPageData1, listPageData1.Count));
  476. }
  477. /// <summary>
  478. /// 团组前期信息 Init
  479. /// </summary>
  480. /// <returns></returns>
  481. [HttpGet("{userId}")]
  482. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  483. public async Task<IActionResult> GroupOrderPreInfo(int userId)
  484. {
  485. return Ok(await _grpOrderPreInfoRep.DataInit(userId));
  486. }
  487. /// <summary>
  488. /// 国家数据源
  489. /// </summary>
  490. /// <param name="pageIndex">当前页码</param>
  491. /// <param name="pageSize">每页条数</param>
  492. /// <param name="search">查询条件</param>
  493. /// <returns></returns>
  494. [HttpGet]
  495. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  496. public async Task<IActionResult> CountryInit([FromQuery] int pageIndex, [FromQuery] int pageSize, [FromQuery] string search)
  497. {
  498. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => x.Country).Distinct().ToListAsync();
  499. if (pageIndex == 0 && pageSize == 0)
  500. {
  501. //所有数据
  502. return Ok(JsonView(countrys, countrys.Count));
  503. }
  504. //分页
  505. int skip = (pageIndex - 1) * pageSize;
  506. int take = pageSize;
  507. if (!string.IsNullOrEmpty(search))
  508. {
  509. IEnumerable<char> charSequence = search.Select(c => c);
  510. var pageResult1 = countrys.Where(x => charSequence.All(x1 => x.Contains(x1))).ToList();
  511. var pageData = pageResult1.Skip(skip).Take(take).ToList();
  512. return Ok(JsonView(pageData, pageResult1.Count));
  513. }
  514. var pageResult2 = countrys.Skip(skip).Take(take).ToList();
  515. return Ok(JsonView(pageResult2, countrys.Count));
  516. }
  517. /// <summary>
  518. /// 城市数据源
  519. /// </summary>
  520. /// <param name="countryLabel">国家名称 多个使用英文逗号隔开</param>
  521. /// <param name="pageIndex">当前页码</param>
  522. /// <param name="pageSize">每页条数</param>
  523. /// <param name="search">查询条件</param>
  524. /// <returns></returns>
  525. [HttpGet("{countryLabel}")]
  526. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  527. public async Task<IActionResult> CityByCountry(
  528. string countryLabel,
  529. [FromQuery] int pageIndex,
  530. [FromQuery] int pageSize,
  531. [FromQuery] string search)
  532. {
  533. countryLabel = HttpUtility.UrlDecode(countryLabel);
  534. var countryList = countryLabel.Split(',', StringSplitOptions.RemoveEmptyEntries).ToArray();
  535. var citys = Array.Empty<string?>();
  536. if (countryList.Any())
  537. {
  538. var cityDatas = await _sqlSugar
  539. .Queryable<Grp_NationalTravelFee>()
  540. .Where(x => x.IsDel == 0 && countryList.Contains(x.Country) && !string.IsNullOrEmpty(x.City))
  541. .ToArrayAsync();
  542. foreach (var item in cityDatas)
  543. {
  544. if (item.City.Contains("城市"))
  545. {
  546. item.City = item.Country + "-所有城市";
  547. }
  548. }
  549. var cityDatas1 = cityDatas.OrderBy(x => x.Country);
  550. citys = cityDatas1.Select(x => x.City).Distinct().ToArray();
  551. }
  552. if (pageIndex == 0 && pageSize == 0)
  553. {
  554. //所有数据
  555. return Ok(JsonView(citys, citys?.Length ?? 0));
  556. }
  557. //分页
  558. int skip = (pageIndex - 1) * pageSize;
  559. int take = pageSize;
  560. if (!string.IsNullOrEmpty(search))
  561. {
  562. IEnumerable<char> charSequence = search.Select(c => c);
  563. var pageResult1 = citys.Where(x => charSequence.All(x1 => x.Contains(x1))).ToList();
  564. var pageData = pageResult1.Skip(skip).Take(take).ToList();
  565. return Ok(JsonView(pageData, pageResult1.Count));
  566. }
  567. var pageResult2 = citys.Skip(skip).Take(take).ToList();
  568. return Ok(JsonView(pageResult2, citys?.Length ?? 0));
  569. }
  570. /// <summary>
  571. /// 团组前期信息 Info
  572. /// </summary>
  573. /// <param name="dto">Id</param>
  574. /// <returns></returns>
  575. [HttpGet("{Id}/{TempId}")]
  576. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  577. public async Task<IActionResult> GroupOrderPreInfo([FromRoute] GroupOrderPreInfoDto dto)
  578. {
  579. return Ok(await _grpOrderPreInfoRep.InfoAsync(dto.Id, dto.TempId));
  580. }
  581. /// <summary>
  582. /// 团组前期信息 移动端 Info
  583. /// </summary>
  584. /// <param name="dto">Id</param>
  585. /// <returns></returns>
  586. [HttpGet("{Id}/{TempId}")]
  587. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  588. public async Task<IActionResult> GroupOrderPreMobileInfo([FromRoute] GroupOrderPreInfoDto dto)
  589. {
  590. return Ok(await _grpOrderPreInfoRep.MobileInfoAsync(dto.Id, dto.TempId));
  591. }
  592. /// <summary>
  593. /// 团组前期信息 Save
  594. /// </summary>
  595. /// <param name="dto">Id</param>
  596. /// <returns></returns>
  597. [HttpPost]
  598. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  599. public async Task<IActionResult> GroupOrderPreInfoSave(GroupOrderPreInfoOpDto dto)
  600. {
  601. return Ok(await _grpOrderPreInfoRep.OpAsync(dto));
  602. }
  603. /// <summary>
  604. /// 团组前期信息 Del
  605. /// </summary>
  606. /// <param name="dto">Id</param>
  607. /// <returns></returns>
  608. [HttpPost]
  609. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  610. public async Task<IActionResult> GroupOrderPreInfoDel(GroupOrderPreInfoDelDto dto)
  611. {
  612. return Ok(await _grpOrderPreInfoRep.DelAsync(dto));
  613. }
  614. /// <summary>
  615. /// 团组前期信息 文件下载
  616. /// </summary>
  617. /// <param name="dto">Id</param>
  618. /// <returns></returns>
  619. [HttpGet("{Id}/{TempId}")]
  620. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  621. public async Task<IActionResult> GroupOrderPreInfoFileDownload([FromRoute] GroupOrderPreInfoDto dto)
  622. {
  623. int id = dto.Id, tempId = dto.TempId;
  624. var view = await _grpOrderPreInfoRep.InfoAsync(id, tempId);
  625. var data = view.Data as GrpOrderPreInfoView;
  626. #region Excel
  627. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  628. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  629. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "GroupOrderPreInfo/";
  630. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "GroupOrderPreInfo/";
  631. var fileNamePrefix = string.Empty;
  632. if (tempId == 1405)
  633. {
  634. tempPath += $"前期需客户提供信息_无商邀版Temp.xlsx";
  635. fileNamePrefix = $"{data.Name}_无商邀版";
  636. }
  637. else if (tempId == 1406)
  638. {
  639. tempPath += $"前期需客户提供信息_有商邀版Temp.xlsx";
  640. fileNamePrefix = $"{data.Name}_有商邀版";
  641. }
  642. else
  643. {
  644. //tempId == 1404 默认下载
  645. tempPath += $"前期需客户提供信息_单接送机Temp.xlsx";
  646. fileNamePrefix = $"{data.Name}_单接送机";
  647. }
  648. foreach (var item in data.Items)
  649. {
  650. var obj = item.NewValue;
  651. if (obj == null) item.OriginVal = "";
  652. else if (obj.Equals("有") || obj.Equals("无"))
  653. {
  654. item.OriginVal = obj.ToString();
  655. }
  656. else if (obj is object[] objArray)
  657. {
  658. string[] stringArray = Array.ConvertAll(objArray, item => item?.ToString() ?? string.Empty);
  659. item.OriginVal = string.Join("、", stringArray);
  660. }
  661. else if (obj is string[] stringArray)
  662. {
  663. item.OriginVal = string.Join("、", stringArray);
  664. }
  665. else if (obj.Equals("-"))
  666. {
  667. item.OriginVal = "";
  668. }
  669. }
  670. var fileName = $"{fileNamePrefix}{CommonFun.GUID}.xlsx";
  671. fileName = CommonFun.ValidFileName(fileName);
  672. //载入模板
  673. var designer = new WorkbookDesigner
  674. {
  675. Workbook = new Workbook(tempPath)
  676. };
  677. if (tempId == 1406)
  678. {
  679. var view1 = data.Items.Where(x => x.Index < 11).ToArray();
  680. var view2 = data.Items.Where(x => x.Index > 10).ToArray();
  681. for (int i = 1; i <= view2.Length; i++)
  682. {
  683. view2[i - 1].Index = i;
  684. }
  685. designer.SetDataSource("View1", view1);
  686. designer.SetDataSource("View2", view2);
  687. }
  688. else
  689. {
  690. designer.SetDataSource("View", data.Items);
  691. }
  692. designer.Process();
  693. if (!Directory.Exists(savePath))
  694. {
  695. Directory.CreateDirectory(savePath);
  696. }
  697. string serverPath = $"{savePath}{fileName}";
  698. designer.Workbook.Save(serverPath);
  699. string rst = $"{servicePath}{ftpPath}{fileName}";
  700. #endregion
  701. return Ok(JsonView(new { url = rst }));
  702. }
  703. #endregion
  704. #region 团组基本信息
  705. /// <summary>
  706. /// 接团信息列表
  707. /// </summary>
  708. /// <param name="dto">团组列表请求dto</param>
  709. /// <returns></returns>
  710. [HttpPost]
  711. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  712. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  713. {
  714. var groupData = await _groupRepository.GetGroupList(dto);
  715. if (groupData.Code != 0)
  716. {
  717. return Ok(JsonView(false, groupData.Msg));
  718. }
  719. return Ok(JsonView(groupData.Data));
  720. }
  721. /// <summary>
  722. /// 分页查询团组列表
  723. /// </summary>
  724. /// <param name="dto"></param>
  725. /// <returns></returns>
  726. [HttpPost]
  727. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  728. public async Task<IActionResult> QueryGroupListOffset(QueryGroupListOffsetDto dto)
  729. {
  730. var watch = new Stopwatch();
  731. watch.Start();
  732. RefAsync<int> total = 0;
  733. var countyDatas = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  734. .Where((di) => di.IsDel == 0 && !string.IsNullOrWhiteSpace(di.TeamName))
  735. .WhereIF(!string.IsNullOrEmpty(dto.Search), (di) => di.TeamName.Contains(dto.Search))
  736. .OrderBy((di) => new { id = SqlFunc.Desc(di.Id) })
  737. .Select((di) => new { id = di.Id, name = di.TeamName, di.ClientName, di.VisitPNumber, di.VisitCountry, di.VisitDays, di.VisitStartDate, di.VisitEndDate, di.TourCode })
  738. .Distinct()
  739. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  740. watch.Stop();
  741. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  742. }
  743. /// <summary>
  744. /// 接团信息列表 Page Init
  745. /// </summary>
  746. /// <returns></returns>
  747. [HttpPost]
  748. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  749. public async Task<IActionResult> PostGroupPageListInit()
  750. {
  751. var depDatas = await GeneralMethod.GroupOpAffiliationBranchInit();
  752. var rankDatas = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 56).Select(x => new { x.Id, x.Name }).ToListAsync();
  753. rankDatas.Insert(0, new { Id = 0, Name = "全部" });
  754. var _view = new
  755. {
  756. depData = depDatas,
  757. rankData = rankDatas
  758. };
  759. return Ok(JsonView(true, "查询成功!", _view));
  760. }
  761. /// <summary>
  762. /// 接团信息列表 Page
  763. /// </summary>
  764. /// <param name="dto">团组列表请求dto</param>
  765. /// <returns></returns>
  766. [HttpPost]
  767. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  768. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  769. {
  770. #region 参数验证
  771. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  772. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  773. #region 页面操作权限验证
  774. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  775. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  776. #endregion
  777. #endregion
  778. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  779. {
  780. string sqlWhere = string.Empty;
  781. if (dto.IsSure == 0) //未完成
  782. {
  783. sqlWhere += string.Format(@" And IsSure = 0");
  784. }
  785. else if (dto.IsSure == 1) //已完成
  786. {
  787. sqlWhere += string.Format(@" And IsSure = 1");
  788. }
  789. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  790. {
  791. string tj = dto.SearchCriteria;
  792. 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}%')",
  793. tj, tj, tj, tj, tj);
  794. }
  795. if (int.TryParse(dto.Rank, out int rankId))
  796. {
  797. if (rankId > 0) sqlWhere += string.Format("And gdi.TeamLevSId = {0}", rankId);
  798. }
  799. string sqlWhere1 = string.Empty;
  800. if (!string.IsNullOrEmpty(dto.Department) && !dto.Department.Equals("全部"))
  801. {
  802. sqlWhere1 = string.Format("Where Department = '{0}'", dto.Department);
  803. }
  804. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,Department,
  805. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  806. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  807. JietuanOperator,IsSure,CreateTime,IsBid,Step
  808. From (
  809. Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
  810. CASE WHEN gdi.JietuanOperator = 4 OR gdi.JietuanOperator = 21 THEN '国交部'
  811. ELSE (Select DepName FROM OA2023DB.dbo.Sys_Department WHERE Id = su.DepId) END AS 'Department',
  812. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,gdi.Step,
  813. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  814. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  815. su.CnName JietuanOperator,IsSure,gdi.CreateTime,gdi.IsBid
  816. From Grp_DelegationInfo gdi
  817. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  818. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  819. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  820. Where gdi.IsDel = 0 {0}
  821. ) temp {1}", sqlWhere, sqlWhere1);
  822. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  823. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  824. //处理 团组模块实际操作人
  825. _DelegationList.ForEach(async x =>
  826. {
  827. var operators = GeneralMethod.GetGroupModuleOperators(x.Id);
  828. var operatorNames = new StringBuilder();
  829. //operatorNames.AppendLine("各模块实际操作人:");
  830. if (operators.Any())
  831. {
  832. operators.ForEach(y =>
  833. {
  834. string label = string.Empty;
  835. if (y.OperationUsers.Any())
  836. {
  837. var users = y.OperationUsers.Select(x => x.UserName).ToList();
  838. label = string.Join('、', users);
  839. }
  840. else label = "暂未指定";
  841. operatorNames.AppendLine($"{y.CTableName}:{label}");
  842. operatorNames.AppendLine();
  843. });
  844. }
  845. x.OperatorLabel = operatorNames.ToString().TrimEnd('\n', '\r');
  846. });
  847. var _view = new
  848. {
  849. PageFuncAuth = pageFunAuthView,
  850. Data = _DelegationList
  851. };
  852. return Ok(JsonView(true, "查询成功!", _view, total));
  853. }
  854. else
  855. {
  856. return Ok(JsonView(false, "查询失败"));
  857. }
  858. }
  859. /// <summary>
  860. /// 团组列表
  861. /// </summary>
  862. /// <returns></returns>
  863. [HttpPost]
  864. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  865. {
  866. #region 参数验证
  867. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  868. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  869. #region 页面操作权限验证
  870. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  871. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  872. #endregion
  873. #endregion
  874. if (dto.PortType != 1 && dto.PortType != 2)
  875. {
  876. return Ok(JsonView(false, "查询失败!"));
  877. }
  878. string orderbyStr = "order by gdi.CreateTime Desc";
  879. string sqlWhere = string.Empty;
  880. if (dto.IsSure == 0) //未完成
  881. {
  882. sqlWhere += string.Format(@" And IsSure = 0");
  883. }
  884. else if (dto.IsSure == 1) //已完成
  885. {
  886. sqlWhere += string.Format(@" And IsSure = 1");
  887. }
  888. //团组类型
  889. if (dto.TeamDid > 0)
  890. {
  891. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  892. }
  893. //团组名称
  894. if (!string.IsNullOrEmpty(dto.TeamName))
  895. {
  896. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  897. }
  898. //客户名称
  899. if (!string.IsNullOrEmpty(dto.ClientName))
  900. {
  901. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  902. }
  903. //客户单位
  904. if (!string.IsNullOrEmpty(dto.ClientUnit))
  905. {
  906. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  907. }
  908. //出访时间
  909. if (!string.IsNullOrEmpty(dto.visitDataTime))
  910. {
  911. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  912. orderbyStr = "order by gdi.VisitDate";
  913. }
  914. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  915. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  916. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  917. JietuanOperator,IsSure,CreateTime
  918. From (
  919. Select row_number() over({0}) as Row_Number,
  920. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  921. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  922. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  923. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  924. From Grp_DelegationInfo gdi
  925. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  926. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  927. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  928. Where gdi.IsDel = 0 {1}
  929. ) temp ", orderbyStr, sqlWhere);
  930. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  931. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  932. #region 处理所属部门
  933. /*
  934. * 1.sq 和 gyy 等显示 市场部
  935. * 2.王鸽和主管及张总还有管理员号统一国交部
  936. * 2-1. 4 管理员 ,21 张海麟
  937. */
  938. var userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  939. var userIds1 = new List<int>() { 4, 21 };
  940. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  941. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  942. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  943. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  944. .ToList();
  945. foreach (var item in _DelegationList)
  946. {
  947. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  948. }
  949. #endregion
  950. var _view = new
  951. {
  952. PageFuncAuth = pageFunAuthView,
  953. Data = _DelegationList
  954. };
  955. return Ok(JsonView(true, "查询成功!", _view, total));
  956. }
  957. /// <summary>
  958. /// 接团信息详情
  959. /// </summary>
  960. /// <param name="dto">团组info请求dto</param>
  961. /// <returns></returns>
  962. [HttpPost]
  963. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  964. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  965. {
  966. var groupData = await _groupRepository.GetGroupInfo(dto);
  967. if (groupData.Code != 0)
  968. {
  969. return Ok(JsonView(false, groupData.Msg));
  970. }
  971. return Ok(JsonView(groupData.Data));
  972. }
  973. /// <summary>
  974. /// 接团信息 编辑添加
  975. /// 基础信息数据源
  976. /// </summary>
  977. /// <param name="dto"></param>
  978. /// <returns></returns>
  979. [HttpPost]
  980. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  981. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  982. {
  983. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  984. if (groupData.Code != 0)
  985. {
  986. return Ok(JsonView(false, groupData.Msg));
  987. }
  988. return Ok(JsonView(groupData.Data));
  989. }
  990. /// <summary>
  991. /// 成本修改团组信息
  992. /// </summary>
  993. /// <param name="dto"></param>
  994. /// <returns></returns>
  995. [HttpPost]
  996. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  997. public async Task<IActionResult> GroupCostEditGroupInfo(GroupCostEditGroupInfoDto dto)
  998. {
  999. var jw = JsonView(false, "操作失败");
  1000. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  1001. if (di == null)
  1002. {
  1003. jw.Msg = "参数有误!";
  1004. return Ok(jw);
  1005. }
  1006. #region 添加出访起止时间
  1007. var startTime = new DateTime();
  1008. var endTime = new DateTime();
  1009. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1010. {
  1011. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1012. }
  1013. else
  1014. {
  1015. jw.Msg = "参数有误!";
  1016. return Ok(jw);
  1017. }
  1018. #endregion
  1019. di.VisitDate = startTime;
  1020. di.VisitPNumber = dto.VisitPNumber;
  1021. di.VisitDays = dto.VisitDays;
  1022. di.VisitStartDate = startTime;
  1023. di.VisitEndDate = endTime;
  1024. var count = _sqlSugar.Updateable(di)
  1025. .UpdateColumns(x => new { x.VisitDate, x.VisitPNumber, x.VisitDays, x.VisitStartDate, x.VisitEndDate })
  1026. .ExecuteCommand();
  1027. return Ok(count > 0 ? JsonView(true, "操作成功") : jw);
  1028. }
  1029. /// <summary>
  1030. /// 接团信息 编辑添加
  1031. /// 省份-城市 基础信息数据源
  1032. /// </summary>
  1033. /// <param name="dto"></param>
  1034. /// <returns></returns>
  1035. [HttpPost]
  1036. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1037. public async Task<IActionResult> GroupProvCityBasicSource(GroupProvCityBasicSourceDto dto)
  1038. {
  1039. int pageIndex = dto.PageIndex, pageSize = dto.PageSize;
  1040. string search = dto.Search;
  1041. var data = await _groupRepository.CityBasicSource();
  1042. int total = data.Length;
  1043. data = data.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search))
  1044. .Skip((pageIndex - 1) * pageSize)
  1045. .Take(pageSize)
  1046. .ToArray();
  1047. return Ok(JsonView(data, total));
  1048. }
  1049. /// <summary>
  1050. /// 接团信息 操作(增改)
  1051. /// </summary>
  1052. /// <param name="dto"></param>
  1053. /// <returns></returns>
  1054. [HttpPost]
  1055. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1056. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  1057. {
  1058. // 创建 Stopwatch 实例
  1059. Stopwatch stopwatch = Stopwatch.StartNew();
  1060. decimal ffrPrice = 0.00M;
  1061. DateTime? visitDt = null;
  1062. if (dto.Status == 2)
  1063. {
  1064. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1065. if (groupInfo != null)
  1066. {
  1067. ffrPrice = groupInfo.PaymentMoney;
  1068. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1069. }
  1070. }
  1071. var groupData = await _groupRepository.GroupOperation(dto);
  1072. if (groupData.Code != 0)
  1073. {
  1074. return Ok(JsonView(false, groupData.Msg));
  1075. }
  1076. int diId = 0;
  1077. try
  1078. {
  1079. //添加时 默认加入团组汇率
  1080. if (dto.Status == 1) //添加
  1081. {
  1082. diId = groupData.Data;
  1083. //添加默认币种
  1084. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1085. //默认分配权限
  1086. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1087. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1088. var _managerIds = new List<int>() { 22, 32, 21 };
  1089. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1090. if (userIds.Count > 0)
  1091. {
  1092. userIds.Add(208);
  1093. //创建团组管控
  1094. GroupStepForDelegation.CreateWorkStep(diId);
  1095. //发送消息
  1096. string groupName = dto.TeamName;
  1097. string createGroupUser = string.Empty;
  1098. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1099. if (userInfo != null) createGroupUser = userInfo.CnName;
  1100. string title = $"系统通知";
  1101. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1102. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1103. }
  1104. //默认创建倒推表
  1105. await _invertedListRep._Create(dto.UserId, diId);
  1106. //默认创建签证流程
  1107. await _visaProcessRep.Create(dto.UserId, diId);
  1108. //默认创建团组流程总览信息
  1109. await _processOverviewRep.ProcessInitAsync(diId, dto.UserId);
  1110. }
  1111. else if (dto.Status == 2)
  1112. {
  1113. diId = dto.Id;
  1114. }
  1115. #region 签证人员团组时间通知
  1116. #region 计算出访起止时间
  1117. var startTime = new DateTime();
  1118. var endTime = new DateTime();
  1119. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1120. {
  1121. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1122. }
  1123. #endregion
  1124. #endregion
  1125. #region 团组操作默认添加/修改收款账单
  1126. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1127. {
  1128. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1129. .Where(x => x.IsDel == 0 &&
  1130. x.Diid == diId &&
  1131. x.Remark.Equals("预付款")
  1132. )
  1133. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1134. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1135. .FirstAsync();
  1136. ffrInfo = new Fin_ForeignReceivables()
  1137. {
  1138. Diid = diId,
  1139. PriceName = dto.ClientUnit,
  1140. Price = dto.PaymentMoney,
  1141. Count = 1,
  1142. Unit = $"元",
  1143. ItemSumPrice = dto.PaymentMoney,
  1144. Rate = 1.0000M,
  1145. Currency = 836,
  1146. AddingWay = 0,
  1147. CreateUserId = dto.UserId,
  1148. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1149. Remark = $"预付款"
  1150. };
  1151. if (ffrInfo == null) //Add
  1152. {
  1153. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1154. }
  1155. else //修改
  1156. {
  1157. await _sqlSugar.Updateable(ffrInfo)
  1158. .UpdateColumns(x => new
  1159. {
  1160. x.PriceName,
  1161. x.Price,
  1162. x.ItemSumPrice,
  1163. x.CreateTime,
  1164. x.CreateUserId
  1165. })
  1166. .WhereColumns(x => x.Id)
  1167. .ExecuteCommandAsync();
  1168. }
  1169. }
  1170. #endregion
  1171. if (diId > 0)
  1172. {
  1173. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1174. }
  1175. // 停止计时
  1176. stopwatch.Stop();
  1177. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  1178. }
  1179. catch (Exception ex)
  1180. {
  1181. // 停止计时
  1182. stopwatch.Stop();
  1183. Logs("[response]" + JsonConvert.SerializeObject(dto));
  1184. Logs(ex.Message);
  1185. //return Ok(JsonView(false, $"{ex.Message}[{stopwatch.ElapsedMilliseconds}ms]"));
  1186. }
  1187. // 停止计时
  1188. stopwatch.Stop();
  1189. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  1190. }
  1191. /// <summary>
  1192. /// 接团流程操作(增改)
  1193. /// 安卓端使用 建团时添加客户名单
  1194. /// </summary>
  1195. /// <param name="dto"></param>
  1196. /// <returns></returns>
  1197. [HttpPost]
  1198. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1199. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  1200. {
  1201. #region 参数验证
  1202. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  1203. #region 页面操作权限验证
  1204. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  1205. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  1206. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  1207. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  1208. #endregion
  1209. #endregion
  1210. try
  1211. {
  1212. //_sqlSugar.BeginTran();
  1213. decimal ffrPrice = 0.00M;
  1214. DateTime? visitDt = null;
  1215. if (dto.Status == 2)
  1216. {
  1217. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1218. if (groupInfo != null)
  1219. {
  1220. ffrPrice = groupInfo.PaymentMoney;
  1221. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1222. }
  1223. }
  1224. var _dto = new GroupOperationDto();
  1225. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  1226. var groupData = await _groupRepository.GroupOperation(_dto);
  1227. if (groupData.Code != 0)
  1228. {
  1229. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  1230. }
  1231. int diId = 0;
  1232. //添加时 默认加入团组汇率
  1233. if (dto.Status == 1) //添加
  1234. {
  1235. diId = groupData.Data;
  1236. //添加默认币种
  1237. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1238. //默认分配权限
  1239. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1240. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1241. var _managerIds = new List<int>() { 21, 22, 32 };
  1242. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1243. if (userIds.Count > 0)
  1244. {
  1245. userIds.Add(208);
  1246. //创建团组管控
  1247. GroupStepForDelegation.CreateWorkStep(diId);
  1248. //发送消息
  1249. string groupName = dto.TeamName;
  1250. string createGroupUser = string.Empty;
  1251. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1252. if (userInfo != null) createGroupUser = userInfo.CnName;
  1253. string title = $"系统通知";
  1254. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1255. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1256. }
  1257. #region 应用推送
  1258. try
  1259. {
  1260. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1261. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1262. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1263. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1264. {
  1265. var userList = new List<string>() { users.QiyeChatUserId };
  1266. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1267. }
  1268. }
  1269. catch (Exception ex)
  1270. {
  1271. }
  1272. #endregion
  1273. //默认创建倒推表
  1274. await _invertedListRep._Create(dto.UserId, diId);
  1275. //默认创建签证流程
  1276. await _visaProcessRep.Create(dto.UserId, diId);
  1277. //默认创建团组流程总览信息
  1278. await _processOverviewRep.ProcessInitAsync(diId, dto.UserId);
  1279. }
  1280. if (dto.Status == 2)
  1281. {
  1282. diId = dto.Id;
  1283. if (diId == 0)
  1284. {
  1285. //_sqlSugar.RollbackTran();
  1286. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  1287. }
  1288. }
  1289. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1290. if (viewData.Code != 0)
  1291. {
  1292. //_sqlSugar.RollbackTran();
  1293. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1294. }
  1295. #region 团组操作默认添加/修改收款账单
  1296. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1297. {
  1298. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1299. .Where(x => x.IsDel == 0 &&
  1300. x.Diid == diId &&
  1301. x.Remark.Equals("预付款")
  1302. )
  1303. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1304. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1305. .FirstAsync();
  1306. ffrInfo = new Fin_ForeignReceivables()
  1307. {
  1308. Diid = diId,
  1309. PriceName = dto.ClientUnit,
  1310. Price = dto.PaymentMoney,
  1311. Count = 1,
  1312. Unit = $"元",
  1313. ItemSumPrice = dto.PaymentMoney,
  1314. Rate = 1.0000M,
  1315. Currency = 836,
  1316. AddingWay = 0,
  1317. CreateUserId = dto.UserId,
  1318. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1319. Remark = $"预付款"
  1320. };
  1321. if (ffrInfo == null) //Add
  1322. {
  1323. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1324. }
  1325. else //修改
  1326. {
  1327. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1328. .UpdateColumns(x => new
  1329. {
  1330. x.PriceName,
  1331. x.Price,
  1332. x.ItemSumPrice,
  1333. x.CreateTime,
  1334. x.CreateUserId
  1335. })
  1336. .WhereColumns(x => x.Id)
  1337. .ExecuteCommandAsync();
  1338. }
  1339. }
  1340. #endregion
  1341. #region 签证人员团组时间通知
  1342. #region 计算出访起止时间
  1343. var startTime = new DateTime();
  1344. var endTime = new DateTime();
  1345. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1346. {
  1347. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1348. }
  1349. #endregion
  1350. if (diId > 0)
  1351. {
  1352. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1353. }
  1354. #endregion
  1355. //_sqlSugar.CommitTran();
  1356. return Ok(JsonView(true, "添加成功"));
  1357. }
  1358. catch (Exception ex)
  1359. {
  1360. _sqlSugar.RollbackTran();
  1361. return Ok(JsonView(false, ex.Message));
  1362. }
  1363. }
  1364. /// <summary>
  1365. /// 接团流程操作(增改)
  1366. /// 安卓端使用 建团时添加客户名单
  1367. /// </summary>
  1368. /// <param name="dto"></param>
  1369. /// <returns></returns>
  1370. [HttpPost]
  1371. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1372. public async Task<IActionResult> GroupProcessOperation1(GroupProcessOperationDto dto)
  1373. {
  1374. #region 参数验证
  1375. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  1376. #region 页面操作权限验证
  1377. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  1378. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  1379. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  1380. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  1381. #endregion
  1382. #endregion
  1383. _sqlSugar.BeginTran();
  1384. decimal ffrPrice = 0.00M;
  1385. DateTime? visitDt = null;
  1386. if (dto.Status == 2)
  1387. {
  1388. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1389. if (groupInfo != null)
  1390. {
  1391. ffrPrice = groupInfo.PaymentMoney;
  1392. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1393. }
  1394. }
  1395. var _dto = new GroupOperationDto();
  1396. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  1397. var groupData = await _groupRepository.GroupOperation(_dto);
  1398. if (groupData.Code != 0)
  1399. {
  1400. _sqlSugar.RollbackTran();
  1401. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  1402. }
  1403. try
  1404. {
  1405. int diId = 0;
  1406. //添加时 默认加入团组汇率
  1407. if (dto.Status == 1) //添加
  1408. {
  1409. diId = groupData.Data;
  1410. //添加默认币种
  1411. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1412. //默认分配权限
  1413. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1414. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1415. var _managerIds = new List<int>() { 21, 22, 32 };
  1416. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1417. if (userIds.Count > 0)
  1418. {
  1419. userIds.Add(208);
  1420. //创建团组管控
  1421. GroupStepForDelegation.CreateWorkStep(diId);
  1422. //发送消息
  1423. string groupName = dto.TeamName;
  1424. string createGroupUser = string.Empty;
  1425. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1426. if (userInfo != null) createGroupUser = userInfo.CnName;
  1427. string title = $"系统通知";
  1428. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1429. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1430. }
  1431. #region 应用推送
  1432. try
  1433. {
  1434. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1435. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1436. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1437. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1438. {
  1439. var userList = new List<string>() { users.QiyeChatUserId };
  1440. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1441. }
  1442. }
  1443. catch (Exception ex)
  1444. {
  1445. _sqlSugar.CommitTran();
  1446. return Ok(JsonView(true, "操作成功! 应用推送异常:" + groupData.Msg));
  1447. }
  1448. #endregion
  1449. //默认创建倒推表
  1450. await _invertedListRep._Create(dto.UserId, diId);
  1451. }
  1452. else if (dto.Status == 2)
  1453. {
  1454. diId = dto.Id;
  1455. if (diId == 0)
  1456. {
  1457. _sqlSugar.RollbackTran();
  1458. return Ok(JsonView(false, "操作失败! 未添加团组id" + groupData.Msg));
  1459. }
  1460. }
  1461. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1462. if (viewData.Code != 0)
  1463. {
  1464. _sqlSugar.RollbackTran();
  1465. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1466. }
  1467. #region 团组操作默认添加/修改收款账单
  1468. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1469. {
  1470. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1471. .Where(x => x.IsDel == 0 &&
  1472. x.Diid == diId &&
  1473. x.Remark.Equals("预付款")
  1474. )
  1475. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1476. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1477. .FirstAsync();
  1478. ffrInfo = new Fin_ForeignReceivables()
  1479. {
  1480. Diid = diId,
  1481. PriceName = dto.ClientUnit,
  1482. Price = dto.PaymentMoney,
  1483. Count = 1,
  1484. Unit = $"元",
  1485. ItemSumPrice = dto.PaymentMoney,
  1486. Rate = 1.0000M,
  1487. Currency = 836,
  1488. AddingWay = 0,
  1489. CreateUserId = dto.UserId,
  1490. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1491. Remark = $"预付款"
  1492. };
  1493. if (ffrInfo == null) //Add
  1494. {
  1495. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1496. }
  1497. else //修改
  1498. {
  1499. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1500. .UpdateColumns(x => new
  1501. {
  1502. x.PriceName,
  1503. x.Price,
  1504. x.ItemSumPrice,
  1505. x.CreateTime,
  1506. x.CreateUserId
  1507. })
  1508. .WhereColumns(x => x.Id)
  1509. .ExecuteCommandAsync();
  1510. }
  1511. }
  1512. #endregion
  1513. #region 签证人员团组时间通知
  1514. #region 计算出访起止时间
  1515. var startTime = new DateTime();
  1516. var endTime = new DateTime();
  1517. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1518. {
  1519. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1520. }
  1521. #endregion
  1522. if (diId > 0)
  1523. {
  1524. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1525. }
  1526. #endregion
  1527. _sqlSugar.CommitTran();
  1528. return Ok(JsonView(true));
  1529. }
  1530. catch (Exception ex)
  1531. {
  1532. _sqlSugar.RollbackTran();
  1533. return Ok(JsonView(false, ex.Message));
  1534. }
  1535. }
  1536. /// <summary>
  1537. /// 接团信息 操作(删除)
  1538. /// </summary>
  1539. /// <param name="dto"></param>
  1540. /// <returns></returns>
  1541. [HttpPost]
  1542. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1543. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  1544. {
  1545. var diId = dto.Id;
  1546. if (diId < 1) return Ok(JsonView(false, MsgTips.Id));
  1547. #region 删除 验证
  1548. /*
  1549. * 1、收款账单数据:0 条
  1550. * 2、收款退还数据:0 条
  1551. * 3、机票费用数据:0 条
  1552. * 4、签证费用数据:0 条
  1553. * 5、保险费用数据:0 条
  1554. * 6、酒店费用数据:0 条
  1555. * 7、公务出访数据:1 条
  1556. * 8、邀请公务活动费用数据:1 条
  1557. * 9、OP费用数据:5 条
  1558. * 10、其他费用数据:0 条
  1559. * 11、团组日付报销费用数据:0 条
  1560. *
  1561. * 温馨提示:该团组已产生费用,不允许删除;如需删除,请先删除对应版块费用,谢谢!
  1562. */
  1563. //收款账单
  1564. int frCount = _sqlSugar.Queryable<Fin_ForeignReceivables>().Where(x => x.IsDel == 0 && x.Diid == diId).Count();
  1565. //收款退还
  1566. int fraomCount = _sqlSugar.Queryable<Fin_PaymentRefundAndOtherMoney>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1567. //机票费用
  1568. int arCount = _sqlSugar.Queryable<Grp_AirTicketReservations>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
  1569. //签证费用
  1570. int viCount = _sqlSugar.Queryable<Grp_VisaInfo>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
  1571. //保险费用
  1572. int cCount = _sqlSugar.Queryable<Grp_Customers>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1573. //酒店费用
  1574. int hrCount = _sqlSugar.Queryable<Grp_HotelReservations>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1575. //公务出访
  1576. int oaCount = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1577. //邀请公务活动费用
  1578. int ioaCount = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1579. //OP费用
  1580. int ctggrCount = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1581. //其他费用
  1582. int dpCount = _sqlSugar.Queryable<Grp_DecreasePayments>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1583. //团组日付报销费用
  1584. int dfpCount = _sqlSugar.Queryable<Fin_DailyFeePayment>().Where(x => x.IsDel == 0 && x.GroupId == diId).Count();
  1585. var feeCount = frCount + fraomCount + arCount + viCount + cCount + hrCount + oaCount + ioaCount + ctggrCount + dpCount + dfpCount;
  1586. if (feeCount > 0)
  1587. {
  1588. var delMsgTips = new StringBuilder();
  1589. delMsgTips.AppendLine($"1、收款账单数据:{frCount} 条");
  1590. delMsgTips.AppendLine($"2、收款退换数据:{fraomCount} 条");
  1591. delMsgTips.AppendLine($"3、机票费用数据:{arCount} 条");
  1592. delMsgTips.AppendLine($"4、签证费用数据:{viCount} 条");
  1593. delMsgTips.AppendLine($"5、保险费用数据:{cCount} 条");
  1594. delMsgTips.AppendLine($"6、酒店费用数据:{hrCount} 条");
  1595. delMsgTips.AppendLine($"7、公务出访数据:{oaCount} 条");
  1596. delMsgTips.AppendLine($"8、邀请公务活动费用数据:{ioaCount} 条");
  1597. delMsgTips.AppendLine($"9、OP费用数据:{ctggrCount} 条");
  1598. delMsgTips.AppendLine($"10、其他费用数据:{dpCount} 条");
  1599. delMsgTips.AppendLine($"11、团组日付报销费用数据:{dfpCount} 条");
  1600. delMsgTips.AppendLine($"");
  1601. delMsgTips.AppendLine($"温馨提示:该团组已产生费用,不允许删除;如需删除,请先删除对应版块费用,谢谢!");
  1602. return Ok(JsonView(false, delMsgTips.ToString()));
  1603. }
  1604. #endregion
  1605. var groupData = await _groupRepository.GroupDel(dto);
  1606. if (groupData.Code != 0)
  1607. {
  1608. return Ok(JsonView(false, groupData.Msg));
  1609. }
  1610. return Ok(JsonView(true));
  1611. }
  1612. /// <summary>
  1613. /// 获取团组销售报价号
  1614. /// 团组添加时 使用
  1615. /// </summary>
  1616. /// <returns></returns>
  1617. [HttpPost]
  1618. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1619. public async Task<IActionResult> GetGroupSalesQuoteNo()
  1620. {
  1621. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  1622. if (groupData.Code != 0)
  1623. {
  1624. return Ok(JsonView(false, groupData.Msg));
  1625. }
  1626. object salesQuoteNo = new
  1627. {
  1628. SalesQuoteNo = groupData.Data
  1629. };
  1630. return Ok(JsonView(salesQuoteNo));
  1631. }
  1632. /// <summary>
  1633. /// 设置确认出团
  1634. /// </summary>
  1635. /// <param name="dto"></param>
  1636. /// <returns></returns>
  1637. [HttpPost]
  1638. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1639. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  1640. {
  1641. var groupData = await _groupRepository.ConfirmationGroup(dto);
  1642. if (groupData.Code != 0)
  1643. {
  1644. return Ok(JsonView(false, groupData.Msg));
  1645. }
  1646. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  1647. #region OA消息推送
  1648. try
  1649. {
  1650. string groupName = groupInfo.TeamName;
  1651. var userIds = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).Select(x => x.Id).ToList();
  1652. string title = $"系统通知";
  1653. string content = $"团组[{groupName}]已确认出团!";
  1654. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  1655. }
  1656. catch (Exception ex)
  1657. {
  1658. }
  1659. #endregion
  1660. #region 应用推送
  1661. try
  1662. {
  1663. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  1664. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  1665. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1666. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1667. {
  1668. var userList = new List<string>() { users.QiyeChatUserId };
  1669. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  1670. }
  1671. }
  1672. catch (Exception ex)
  1673. {
  1674. }
  1675. #endregion
  1676. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  1677. return Ok(JsonView(true, "操作成功!", groupData.Data));
  1678. }
  1679. /// <summary>
  1680. /// 获取团组名称data And 签证国别Data
  1681. /// </summary>
  1682. /// <param name="dto"></param>
  1683. /// <returns></returns>
  1684. [HttpPost]
  1685. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1686. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  1687. {
  1688. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  1689. if (groupData.Code != 0)
  1690. {
  1691. return Ok(JsonView(false, groupData.Msg));
  1692. }
  1693. return Ok(JsonView(groupData.Data));
  1694. }
  1695. /// <summary>
  1696. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  1697. /// </summary>
  1698. /// <returns></returns>
  1699. [HttpPost]
  1700. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1701. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  1702. {
  1703. try
  1704. {
  1705. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  1706. if (groupData.Code != 0)
  1707. {
  1708. return Ok(JsonView(false, groupData.Msg));
  1709. }
  1710. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1711. }
  1712. catch (Exception ex)
  1713. {
  1714. return Ok(JsonView(false, ex.Message));
  1715. throw;
  1716. }
  1717. }
  1718. /// <summary>
  1719. /// 团组清单 Excel
  1720. /// </summary>
  1721. /// <param name="beginDt">开始时间 EG:“2024-01-01”</param>
  1722. /// <param name="endDt">结束时间 EG;“2024-12-31”</param>
  1723. /// <returns></returns>
  1724. [HttpGet]
  1725. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1726. public async Task<IActionResult> GroupListFile([FromQuery] string beginDt, [FromQuery] string endDt)
  1727. {
  1728. bool beginBool = DateTime.TryParse($"{beginDt} 00:00:00", out DateTime _beginDt),
  1729. endBool = DateTime.TryParse($"{endDt} 23:59:59", out DateTime _endDt);
  1730. if (!beginBool && !endBool)
  1731. {
  1732. return Ok(JsonView(false, "开始或结束时间不正确!"));
  1733. }
  1734. string sql = string.Format(@"
  1735. SELECT
  1736. ROW_NUMBER,
  1737. Id,
  1738. SalesQuoteNo,
  1739. TourCode,
  1740. TeamTypeId,
  1741. TeamType,
  1742. TeamLevId,
  1743. TeamLev,
  1744. TeamName,
  1745. ClientName,
  1746. ClientUnit,
  1747. VisitDate,
  1748. VisitDays,
  1749. VisitPNumber,
  1750. JietuanOperatorId,
  1751. JietuanOperator,
  1752. IsSure,
  1753. CreateUserName,
  1754. IsBid
  1755. FROM
  1756. (
  1757. SELECT
  1758. ROW_NUMBER() OVER(
  1759. ORDER BY
  1760. gdi.VisitDate Desc
  1761. ) AS ROW_NUMBER,
  1762. gdi.Id,
  1763. SalesQuoteNo,
  1764. TourCode,
  1765. ssd.Id TeamTypeId,
  1766. ssd.Name TeamType,
  1767. ssd1.Id TeamLevId,
  1768. ssd1.Name TeamLev,
  1769. TeamName,
  1770. ClientName,
  1771. ClientUnit,
  1772. VisitDate,
  1773. VisitDays,
  1774. VisitPNumber,
  1775. JietuanOperator JietuanOperatorId,
  1776. su.CnName JietuanOperator,
  1777. IsSure,
  1778. gdi.CreateTime,
  1779. su1.CnName As CreateUserName,
  1780. gdi.IsBid
  1781. FROM
  1782. Grp_DelegationInfo gdi
  1783. LEFT JOIN Sys_SetData ssd ON gdi.TeamDid = ssd.Id
  1784. LEFT JOIN Sys_SetData ssd1 ON gdi.TeamLevSId = ssd1.Id
  1785. LEFT JOIN Sys_Users su ON gdi.JietuanOperator = su.Id
  1786. LEFT JOIN Sys_Users su1 ON gdi.CreateUserId = su1.Id
  1787. WHERE
  1788. gdi.IsDel = 0
  1789. AND gdi.IsBid = 0
  1790. AND gdi.VisitDate BETWEEN '{0}' AND '{1}'
  1791. ) temp", _beginDt.ToString("yyyy-MM-dd HH:mm:ss"), _endDt.ToString("yyyy-MM-dd HH:mm:ss"));
  1792. var groupList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToListAsync();
  1793. #region 处理所属部门
  1794. /*
  1795. * 1.sq 和 gyy 等显示 市场部
  1796. * 2.王鸽和主管及张总还有管理员号统一国交部
  1797. * 2-1. 4 管理员 ,21 张海麟
  1798. */
  1799. var userIds = groupList.Select(it => it.JietuanOperatorId).ToList();
  1800. var userIds1 = new List<int>() { 4, 21 };
  1801. var userDepDatas = await _sqlSugar.Queryable<Sys_Users>()
  1802. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  1803. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  1804. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  1805. .ToListAsync();
  1806. var droupIds = groupList.Select(it => it.Id).ToList();
  1807. var deleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  1808. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  1809. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  1810. .Where((tcl, dc, cc) => tcl.IsDel == 0 && droupIds.Contains(tcl.DiId))
  1811. .Select((tcl, dc, cc) => new ClientInfoInfo_Group
  1812. {
  1813. DiId = tcl.DiId,
  1814. LastName = dc.LastName,
  1815. FirstName = dc.FirstName,
  1816. Sex = dc.Sex,
  1817. Birthday = dc.BirthDay,
  1818. Company = cc.CompanyFullName,
  1819. Job = dc.Job,
  1820. CreateTime = tcl.CreateTime,
  1821. })
  1822. .ToList();
  1823. foreach (var item in groupList)
  1824. {
  1825. item.Department = userDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  1826. string groupFirstName = "";
  1827. var currDatas = deleClientList.Where(x => x.DiId == item.Id).ToList();
  1828. if (currDatas.Any())
  1829. {
  1830. groupFirstName = AesEncryptionHelper.Decrypt(currDatas[0].LastName) + AesEncryptionHelper.Decrypt(currDatas[0].FirstName);
  1831. }
  1832. item.GroupFirst = groupFirstName;
  1833. }
  1834. #endregion
  1835. #region Excel
  1836. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  1837. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  1838. var savePath = AppSettingsHelper.Get("GrpListFileBasePath");
  1839. var ftpPath = AppSettingsHelper.Get("GrpListFileFtpPath");
  1840. var fileName = $"团组清单({beginDt}~{endDt}){DateTime.Now:yyyyMMddHHmmss}.xlsx";
  1841. //载入模板
  1842. var designer = new WorkbookDesigner
  1843. {
  1844. Workbook = new Workbook($"{tempPath}团组清单模板.xlsx")
  1845. };
  1846. designer.SetDataSource("Titel", $"团组清单({beginDt}~{endDt})");
  1847. DataTable dt = CommonFun.GetDataTableFromIList<DelegationListView>(groupList); ;
  1848. dt.TableName = "GroupList";
  1849. designer.SetDataSource(dt);
  1850. designer.Process();
  1851. if (!Directory.Exists(savePath))
  1852. {
  1853. Directory.CreateDirectory(savePath);
  1854. }
  1855. string serverPath = $"{savePath}{fileName}";
  1856. designer.Workbook.Save(serverPath);
  1857. string rst = $"{servicePath}{ftpPath}{fileName}";
  1858. #endregion
  1859. return Ok(JsonView(true, "操作成功!", rst));
  1860. }
  1861. /// <summary>
  1862. /// 团组合同下载(1.付款80% 2.付全款)
  1863. /// </summary>
  1864. /// <param name="dto"></param>
  1865. /// <returns></returns>
  1866. /// <exception cref="Exception"></exception>
  1867. [HttpPost]
  1868. public async Task<IActionResult> DownGroupContractFile(DownGroupContractFileDto dto)
  1869. {
  1870. var jw = JsonView(false);
  1871. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  1872. .FirstAsync(x => x.Id == dto.GroupId && x.IsDel == 0);
  1873. if (di == null)
  1874. {
  1875. jw.Msg = "团组Id有误!";
  1876. return Ok(jw);
  1877. }
  1878. #region 权限校验
  1879. var allDownFile = new List<int>() { 21 };
  1880. try
  1881. {
  1882. var setting = _sqlSugar.Queryable<Sys_SetData>()
  1883. .First(x => x.Id == 1418 && x.IsDel == 0);
  1884. allDownFile.AddRange(JsonConvert.DeserializeObject<List<int>>(setting.Remark));
  1885. }
  1886. catch (Exception)
  1887. { }
  1888. var guojiaoDownFile = new List<int>() { 330, 383 };
  1889. var shichangDownFile = new List<int>() { 95 };
  1890. if (allDownFile.Contains(dto.UserId))
  1891. {
  1892. }
  1893. else if (guojiaoDownFile.Contains(dto.UserId))
  1894. {
  1895. var guojiaobuDi = new List<int>() { 4, 21 };
  1896. var departmentStr = _sqlSugar.Queryable<Sys_Department>()
  1897. .LeftJoin<Sys_Users>((d, u) => d.Id == u.DepId && u.IsDel == 0)
  1898. .Where((d, u) => u.Id == di.JietuanOperator)
  1899. .Select((d, u) => d.DepName)
  1900. .First();
  1901. if (!guojiaobuDi.Contains(di.JietuanOperator) && departmentStr != "策划部" && departmentStr != "国交部")
  1902. {
  1903. jw.Msg = "暂无下载权限!";
  1904. return Ok(jw);
  1905. }
  1906. }
  1907. else if (shichangDownFile.Contains(dto.UserId))
  1908. {
  1909. var dic = new Dictionary<int, int[]>()
  1910. {
  1911. { 95, new int []{ 95 , 337 , 302, 350, 355, 357, 353 , 359 , 361, 368, 364, 366, 369} }
  1912. };
  1913. try
  1914. {
  1915. var sqSetting = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1417);
  1916. if (sqSetting != null)
  1917. {
  1918. Dictionary<int, int[]> result = JsonConvert.DeserializeObject<Dictionary<int, int[]>>(sqSetting.Remark);
  1919. foreach (var item in result.Keys)
  1920. {
  1921. if (dic.ContainsKey(item))
  1922. {
  1923. int[] dilatation = new int[dic[item].Length + result[item].Length];
  1924. Array.Copy(dic[item], dilatation, dic[item].Length);
  1925. Array.Copy(result[item], 0, dilatation, dic[item].Length, result[item].Length);
  1926. dic[item] = dilatation;
  1927. }
  1928. else
  1929. {
  1930. dic.Add(item, result[item]);
  1931. }
  1932. }
  1933. }
  1934. if (!dic[95].Contains(di.CreateUserId))
  1935. {
  1936. jw.Msg = "暂无下载权限!";
  1937. return Ok(jw);
  1938. }
  1939. }
  1940. catch (Exception)
  1941. { }
  1942. }
  1943. else if (dto.UserId == di.CreateUserId)
  1944. {
  1945. }
  1946. else
  1947. {
  1948. jw.Msg = "暂无下载权限!";
  1949. return Ok(jw);
  1950. }
  1951. #endregion
  1952. var blackCodeList = await _sqlSugar.Queryable<Air_TicketBlackCode>()
  1953. .Where(x => x.DiId == dto.GroupId && x.IsDel == 0)
  1954. .ToListAsync();
  1955. if (!blackCodeList.Any())
  1956. {
  1957. jw.Msg = "该团无机票行程代码!";
  1958. return Ok(jw);
  1959. }
  1960. var groupEnterExitCost = await _sqlSugar.Queryable<Grp_EnterExitCost>()
  1961. .FirstAsync(x => x.DiId == dto.GroupId && x.IsDel == 0);
  1962. if (groupEnterExitCost == null)
  1963. {
  1964. jw.Msg = "暂无三公费用信息!";
  1965. return Ok(jw);
  1966. }
  1967. var rateList = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(groupEnterExitCost.CurrencyRemark);
  1968. rateList ??= new List<CurrencyInfo>();
  1969. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == di.Id).ToList();
  1970. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  1971. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  1972. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  1973. .Where((x, a, b) => x.IsDel == 0 && x.Diid == di.Id)
  1974. .Select((x, a, b) => new
  1975. {
  1976. x.Index,
  1977. itemName = a.Name,
  1978. CurrencyStr = b.Name,
  1979. x.Cost,
  1980. x.SubTotal,
  1981. x.Remark
  1982. })
  1983. .OrderBy((x) => x.Index)
  1984. .ToList();
  1985. decimal stayFeeTotal = groupEnterExitCost.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  1986. decimal mealsFeeTotal = groupEnterExitCost.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  1987. decimal miscellaneousFeeTotal = groupEnterExitCost.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  1988. decimal tainFeeTotal = groupEnterExitCost.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  1989. decimal otherPriceTotal = groupEnterExitCost.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  1990. decimal insidePayTotal = groupEnterExitCost.ChoiceOne == 1 ? groupEnterExitCost.InsidePay : 0.00M;
  1991. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  1992. decimal subJJC = 0.00M,
  1993. subGWC = 0.00M,
  1994. subTDC = 0.00M;
  1995. //经济舱
  1996. if (groupEnterExitCost.SumJJC == 1)
  1997. {
  1998. subJJC = otherFeeTotal + groupEnterExitCost.OutsideJJPay;
  1999. }
  2000. //公务舱
  2001. if (groupEnterExitCost.SumGWC == 1)
  2002. {
  2003. subGWC = otherFeeTotal + groupEnterExitCost.OutsideGWPay;
  2004. }
  2005. //头等舱
  2006. if (groupEnterExitCost.SumTDC == 1)
  2007. {
  2008. subTDC = otherFeeTotal + groupEnterExitCost.OutsideTDPay;
  2009. }
  2010. var groupClints = await _sqlSugar.Queryable<Grp_TourClientList>()
  2011. .LeftJoin<Sys_SetData>((x, s) => s.Id == x.ShippingSpaceTypeId && s.IsDel == 0)
  2012. .LeftJoin<Crm_DeleClient>((x, s, dc) => x.ClientId == dc.Id && dc.IsDel == 0)
  2013. .LeftJoin<Crm_CustomerCompany>((x, s, dc, cc) => dc.CrmCompanyId == cc.Id && cc.IsDel == 0)
  2014. .Where((x, s, dc, cc) => x.DiId == dto.GroupId && x.IsDel == 0)
  2015. .Select((x, s, dc, cc) => new GroupClints
  2016. {
  2017. Id = x.Id,
  2018. Name = s.Name,
  2019. IsAccompany = x.IsAccompany,
  2020. CompanyFullName = cc.CompanyFullName
  2021. })
  2022. .ToListAsync();
  2023. groupClints.ForEach(x => x.CompanyFullName = AesEncryptionHelper.Decrypt(x.CompanyFullName));
  2024. //获取舱位人数
  2025. var cabinCount = groupClints.Where(x => x.IsAccompany != 2 && !x.CompanyFullName.Contains("泛美国际"))
  2026. .GroupBy(x => x.Name)
  2027. .Select(x => new { Cabin = x.Key, Count = x.Count() })
  2028. .ToList();
  2029. string cityPath = string.Empty;
  2030. string startCity = string.Empty;
  2031. string endCity = string.Empty;
  2032. foreach (var item in blackCodeList)
  2033. {
  2034. string city = GeneralMethod.GetGroupCityLine(item, "-");
  2035. cityPath += city + "\r\n";
  2036. if (item.Equals(blackCodeList.First()))
  2037. {
  2038. var sp = city.Split('-');
  2039. startCity = sp[0];
  2040. endCity = sp[^1];
  2041. }
  2042. }
  2043. di.VisitCountry = Regex.Replace(di.VisitCountry, @"[|-]", "、");
  2044. var bookMarkDic = new Dictionary<string, string>
  2045. {
  2046. { "ClientUnit", di.ClientUnit },
  2047. { "VisitCountry", di.VisitCountry },
  2048. { "VisitDate", di.VisitDate.ToString("yyyy年MM月dd日") },
  2049. { "VisitPNumber", di.VisitPNumber.ToString() },
  2050. { "CityPath", cityPath },
  2051. { "StartCity", startCity },
  2052. { "EndCity", endCity },
  2053. { "StayDays", $"{di.VisitDays}天{di.VisitDays - 1}晚" }
  2054. };
  2055. Document doc = null;
  2056. var percentage = 0.8M;
  2057. var fileNameadd = "预付";
  2058. if (dto.FileType == 1)
  2059. {
  2060. doc = new Document($"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Template/团组合同bookmarkFormat.doc");
  2061. }
  2062. else if (dto.FileType == 2)
  2063. {
  2064. doc = new Document($"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Template/团组合同全款无表格.doc");
  2065. percentage = 1;
  2066. fileNameadd = "全款";
  2067. }
  2068. else
  2069. {
  2070. throw new Exception("FileType有误!");
  2071. }
  2072. var builder = new DocumentBuilder(doc);
  2073. decimal totalPrice = 0.00M;
  2074. Table firstTable = (Table)doc.GetChild(NodeType.Table, 0, true);
  2075. if (firstTable != null)
  2076. {
  2077. // 遍历表格的行和单元格
  2078. foreach (Aspose.Words.Tables.Row row in firstTable.Rows)
  2079. {
  2080. for (int i = 0; i < row.Cells.Count; i++)
  2081. {
  2082. var cell = row.Cells[i];
  2083. // 读取单元格内容
  2084. string cellTextFirst = row.Cells[0].FirstParagraph.ToString(Aspose.Words.SaveFormat.Text).Trim();
  2085. if (cellTextFirst.Contains("舱位"))
  2086. {
  2087. break;
  2088. }
  2089. if (cellTextFirst == "经济舱" || cellTextFirst == "公务舱")
  2090. {
  2091. if (i == 2)
  2092. {
  2093. if (cellTextFirst == "经济舱")
  2094. {
  2095. // 设置单元格内容
  2096. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2097. cell.FirstParagraph.AppendChild(new Run(doc, subJJC.ToString())); // 添加
  2098. }
  2099. else
  2100. {
  2101. // 设置单元格内容
  2102. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2103. cell.FirstParagraph.AppendChild(new Run(doc, subGWC.ToString())); // 添加
  2104. }
  2105. }
  2106. if (i == 3)
  2107. {
  2108. var count = cabinCount.Find(x => x.Cabin == cellTextFirst)?.Count;
  2109. if (count != null)
  2110. {
  2111. // 设置单元格内容
  2112. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2113. cell.FirstParagraph.AppendChild(new Run(doc, count.ToString())); // 添加
  2114. }
  2115. }
  2116. if (i == 4)
  2117. {
  2118. var rowPrice = 0.00M;
  2119. var count = cabinCount.Find(x => x.Cabin == cellTextFirst)?.Count;
  2120. count ??= 0;
  2121. if (cellTextFirst == "经济舱")
  2122. {
  2123. rowPrice = subJJC * (int)count;
  2124. }
  2125. else
  2126. {
  2127. rowPrice = subGWC * (int)count;
  2128. }
  2129. totalPrice += rowPrice;
  2130. // 设置单元格内容
  2131. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2132. cell.FirstParagraph.AppendChild(new Run(doc, rowPrice.ToString())); // 添加
  2133. }
  2134. }
  2135. }
  2136. }
  2137. }
  2138. bookMarkDic.Add("TotalPrice", (totalPrice).ToString("#0.00"));
  2139. bookMarkDic.Add("TotalPrice1", (totalPrice * percentage).ToString("#0.00"));
  2140. bookMarkDic.Add("TotalPriceChinese", decimal.Parse((totalPrice * percentage).ToString("#0.00")).ConvertCNYUpper());
  2141. //--合同表格部分
  2142. bookMarkDic.Add("TimeNowDate", DateTime.Now.ToString("yyyy年MM月dd日"));
  2143. bookMarkDic.Add("ClientUnit1", di.ClientUnit);
  2144. bookMarkDic.Add("VisitCountry1", di.VisitCountry);
  2145. bookMarkDic.Add("DayCount", di.VisitDays.ToString());
  2146. bookMarkDic.Add("VisitingArea", di.VisitDate.ToString("yyyy年MM月dd日") + "-" + di.VisitEndDate.ToString("yyyy年MM月dd日"));
  2147. bookMarkDic.Add("CityPath1", cityPath);
  2148. bookMarkDic.Add("CityPath2", cityPath);
  2149. Table contractTable = (Table)doc.GetChild(NodeType.Table, 1, true);
  2150. if (contractTable != null)
  2151. {
  2152. //数据源
  2153. var _DayAndCostsAndCity = _sqlSugar.Queryable<Grp_DayAndCost>()
  2154. .LeftJoin<Grp_NationalTravelFee>((it, y) => it.NationalTravelFeeId == y.Id && y.IsDel == 0)
  2155. .LeftJoin<Sys_SetData>((it, y, s) => s.IsDel == 0 && s.Id == it.Currency)
  2156. .Where((it, y, s) => it.IsDel == 0 && it.DiId == di.Id)
  2157. .Select((it, y, s) => new
  2158. {
  2159. it.Cost,
  2160. it.SubTotal,
  2161. it.Type,
  2162. y.Id,
  2163. y.City,
  2164. s.Name,
  2165. CurrencyCodeCn = s.Remark
  2166. })
  2167. .ToList()
  2168. .Select(x => new
  2169. {
  2170. CurrencyCode = x.Name,
  2171. CityId = x.Id,
  2172. x.City,
  2173. di.VisitPNumber,
  2174. x.Type,
  2175. x.Cost,
  2176. x.SubTotal,
  2177. rateList.Find(y => y.CurrencyCode == x.Name)?.Rate,
  2178. x.CurrencyCodeCn,
  2179. });
  2180. var dac1 = _DayAndCostsAndCity.Where(it => it.Type == 1).GroupBy(x => x.CityId).ToList(); //住宿费
  2181. var dac2 = _DayAndCostsAndCity.Where(it => it.Type == 2).GroupBy(x => x.CityId).ToList(); //伙食费
  2182. var dac3 = _DayAndCostsAndCity.Where(it => it.Type == 3).GroupBy(x => x.CityId).ToList(); //公杂费
  2183. var dac4 = _DayAndCostsAndCity.Where(it => it.Type == 4).GroupBy(x => x.CityId).ToList(); //培训费
  2184. var tableSettings = new List<tableSetting>()
  2185. {
  2186. new(){ Index = 1 , Property = "City"},
  2187. new(){ Index = 2 , Property = "CurrencyCodeCn"},
  2188. new(){ Index = 3 , Property = "Cost"},
  2189. new(){ Index = 4 , Property = "VisitPNumber"},
  2190. //new tableSetting{ Index = 5 , Property = ""},
  2191. //new tableSetting{ Index = 6 , Property = ""},
  2192. new(){ Index = 7 , Property = "Rate"},
  2193. //new tableSetting{ Index = 8 , Property = ""},
  2194. };
  2195. //1.住宿费
  2196. int cloneRow = 8;
  2197. int startDayPrice = 8; //写入index
  2198. decimal ZSPriceSum = 0.00M, HSPriceSum = 0.00M, GZPriceSum = 0.00M;
  2199. foreach (var dac in dac1)
  2200. {
  2201. var first = dac.First();
  2202. var dayCount = dac.Count();
  2203. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2204. for (int i = 1; i < row.Cells.Count; i++)
  2205. {
  2206. var cell = row.Cells[i];
  2207. var findProperty = tableSettings.Find(x => x.Index == i);
  2208. if (findProperty != null)
  2209. {
  2210. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2211. // 设置单元格内容
  2212. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2213. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2214. }
  2215. else
  2216. {
  2217. switch (i)
  2218. {
  2219. case 5:
  2220. cell.FirstParagraph.Runs.Clear();
  2221. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2222. break;
  2223. case 6:
  2224. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2225. cell.FirstParagraph.Runs.Clear();
  2226. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2227. break;
  2228. case 8:
  2229. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2230. cell.FirstParagraph.Runs.Clear();
  2231. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2232. ZSPriceSum += xiaojiRMB;
  2233. break;
  2234. default:
  2235. break;
  2236. }
  2237. }
  2238. }
  2239. startDayPrice++;
  2240. if (!dac1.Last().Equals(dac))
  2241. {
  2242. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2243. // 将克隆的行追加到原行后面
  2244. contractTable.Rows.Insert(startDayPrice, newRow);
  2245. }
  2246. else
  2247. {
  2248. cloneRow += dac1.Count + 1;
  2249. startDayPrice = cloneRow;
  2250. }
  2251. }
  2252. //2.伙食费
  2253. foreach (var dac in dac2)
  2254. {
  2255. var first = dac.First();
  2256. var dayCount = dac.Count();
  2257. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2258. for (int i = 1; i < row.Cells.Count; i++)
  2259. {
  2260. var cell = row.Cells[i];
  2261. var findProperty = tableSettings.Find(x => x.Index == i);
  2262. if (findProperty != null)
  2263. {
  2264. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2265. // 设置单元格内容
  2266. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2267. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2268. }
  2269. else
  2270. {
  2271. switch (i)
  2272. {
  2273. case 5:
  2274. cell.FirstParagraph.Runs.Clear();
  2275. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2276. break;
  2277. case 6:
  2278. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2279. cell.FirstParagraph.Runs.Clear();
  2280. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2281. break;
  2282. case 8:
  2283. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2284. cell.FirstParagraph.Runs.Clear();
  2285. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2286. HSPriceSum += xiaojiRMB;
  2287. break;
  2288. default:
  2289. break;
  2290. }
  2291. }
  2292. }
  2293. startDayPrice++;
  2294. if (!dac2.Last().Equals(dac))
  2295. {
  2296. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2297. // 将克隆的行追加到原行后面
  2298. contractTable.Rows.Insert(startDayPrice, newRow);
  2299. }
  2300. else
  2301. {
  2302. cloneRow += dac2.Count + 1;
  2303. startDayPrice = cloneRow;
  2304. }
  2305. }
  2306. //3.公杂费
  2307. foreach (var dac in dac3)
  2308. {
  2309. var first = dac.First();
  2310. var dayCount = dac.Count();
  2311. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2312. for (int i = 1; i < row.Cells.Count; i++)
  2313. {
  2314. var cell = row.Cells[i];
  2315. var findProperty = tableSettings.Find(x => x.Index == i);
  2316. if (findProperty != null)
  2317. {
  2318. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2319. // 设置单元格内容
  2320. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2321. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2322. }
  2323. else
  2324. {
  2325. switch (i)
  2326. {
  2327. case 5:
  2328. cell.FirstParagraph.Runs.Clear();
  2329. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2330. break;
  2331. case 6:
  2332. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2333. cell.FirstParagraph.Runs.Clear();
  2334. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2335. break;
  2336. case 8:
  2337. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2338. cell.FirstParagraph.Runs.Clear();
  2339. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2340. GZPriceSum += xiaojiRMB;
  2341. break;
  2342. default:
  2343. break;
  2344. }
  2345. }
  2346. }
  2347. startDayPrice++;
  2348. if (!dac3.Last().Equals(dac))
  2349. {
  2350. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2351. // 将克隆的行追加到原行后面
  2352. contractTable.Rows.Insert(startDayPrice, newRow);
  2353. }
  2354. else
  2355. {
  2356. cloneRow += dac3.Count + 1;
  2357. startDayPrice = cloneRow;
  2358. }
  2359. }
  2360. //合并单元格
  2361. for (int i = 8; i < contractTable.Rows.Count - 1; i++)
  2362. {
  2363. var currentRow = contractTable.Rows[i];
  2364. var nextRow = contractTable.Rows[i + 1];
  2365. // 获取当前行和下一行的第一个单元格
  2366. Cell currentCell = currentRow.Cells[0];
  2367. Cell nextCell = nextRow.Cells[0];
  2368. // 检查单元格内容是否一致(去除尾部的换行符)
  2369. string currentText = currentCell.GetText().Trim();
  2370. string nextText = nextCell.GetText().Trim();
  2371. if (currentText == nextText)
  2372. {
  2373. // 如果当前单元格已经被合并,找到合并的起始单元格
  2374. if (currentCell.CellFormat.VerticalMerge == CellMerge.Previous)
  2375. {
  2376. // 找到合并的起始单元格
  2377. int mergeStartIndex = FindMergeStartRowIndex(contractTable, i);
  2378. // 将下一行的单元格设置为合并的后续单元格
  2379. nextCell.CellFormat.VerticalMerge = CellMerge.Previous;
  2380. }
  2381. else
  2382. {
  2383. // 如果当前单元格是合并的起始单元格
  2384. currentCell.CellFormat.VerticalMerge = CellMerge.First;
  2385. // 将下一行的单元格设置为合并的后续单元格
  2386. nextCell.CellFormat.VerticalMerge = CellMerge.Previous;
  2387. }
  2388. }
  2389. else
  2390. {
  2391. // 如果内容不一致,重置当前单元格的合并属性
  2392. if (currentCell.CellFormat.VerticalMerge == CellMerge.Previous)
  2393. {
  2394. // 如果当前单元格是合并的后续单元格,找到合并的起始单元格并重置
  2395. int mergeStartIndex = FindMergeStartRowIndex(contractTable, i);
  2396. contractTable.Rows[mergeStartIndex].Cells[0].CellFormat.VerticalMerge = CellMerge.First;
  2397. }
  2398. else
  2399. {
  2400. currentCell.CellFormat.VerticalMerge = CellMerge.None;
  2401. }
  2402. }
  2403. }
  2404. bookMarkDic.Add("ZSPriceSum", ZSPriceSum.ToString("F2"));
  2405. bookMarkDic.Add("HSPriceSum", HSPriceSum.ToString("F2"));
  2406. bookMarkDic.Add("GZPriceSum", GZPriceSum.ToString("F2"));
  2407. }
  2408. foreach (var bookmarkName in bookMarkDic.Keys)
  2409. {
  2410. Bookmark bookmark = doc.Range.Bookmarks[bookmarkName];
  2411. if (bookmark != null)
  2412. {
  2413. if (bookmarkName == "ClientUnit")
  2414. {
  2415. // 移动到书签位置
  2416. builder.MoveTo(bookmark.BookmarkStart);
  2417. // 设置字体样式为下划线
  2418. builder.Font.Underline = Aspose.Words.Underline.Single;
  2419. // 插入书签值
  2420. builder.Write(bookMarkDic[bookmarkName]);
  2421. // 清除字体格式,避免影响后续文本
  2422. builder.Font.ClearFormatting();
  2423. }
  2424. else
  2425. {
  2426. builder.MoveToBookmark(bookmarkName);
  2427. builder.Write(bookMarkDic[bookmarkName]);
  2428. }
  2429. }
  2430. }
  2431. string savePaht = $"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Export/{di.TeamName}_{fileNameadd}版本合同文件.doc";
  2432. doc.Save(savePaht);
  2433. jw.Msg = "生成成功!";
  2434. jw.Code = 200;
  2435. jw.Data = new { Url = AppSettingsHelper.Get("WordBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("WordBasePath"), AppSettingsHelper.Get("WordFtpPath")) };
  2436. return Ok(jw);
  2437. }
  2438. static int FindMergeStartRowIndex(Table table, int rowIndex)
  2439. {
  2440. int index = rowIndex;
  2441. while (index > 0 && table.Rows[index].Cells[0].CellFormat.VerticalMerge == CellMerge.Previous)
  2442. {
  2443. index--;
  2444. }
  2445. return index;
  2446. }
  2447. /// <summary>
  2448. /// 报批完成企微通知
  2449. /// </summary>
  2450. /// <param name="dto"></param>
  2451. /// <returns></returns>
  2452. [HttpPost]
  2453. public async Task<IActionResult> EnterpriseWeChatNotificationAsyncBaoPi(EnterpriseWeChatNotificationAsyncBaoPiDto dto)
  2454. {
  2455. int currUserId = dto.currUserId;
  2456. int diid = dto.diid;
  2457. var jw = JsonView(true);
  2458. var users = new List<string>();
  2459. var ssd = _sqlSugar.Queryable<Sys_SetData>()
  2460. .First(x => x.Id == 1460);
  2461. try
  2462. {
  2463. users = JsonConvert.DeserializeObject<List<string>>(ssd.Remark);
  2464. var groupModuleOperators = GeneralMethod.GetGroupModuleOperators(dto.diid);
  2465. //添加分配人员
  2466. // 79 车/导游地接
  2467. // 80 签证
  2468. // 81 邀请/公务活动
  2469. var setdataids = new List<int>() { 79, 81 };
  2470. foreach (var groupModule in groupModuleOperators)
  2471. {
  2472. if (setdataids.Contains(groupModule.CTableId))
  2473. {
  2474. users.AddRange(groupModule.OperationUsers.Select(x => x.UserId.ToString()));
  2475. }
  2476. }
  2477. var res = await AppNoticeLibrary.SendUserMsg_BaoPi_ToUser(users, diid);
  2478. //消息通知成功 更改团组step、记录日志
  2479. if (res)
  2480. {
  2481. var groupStep = 0; //0-新建 1-企微消息通知
  2482. //更改团组step
  2483. var updStatus = await _sqlSugar.Updateable<Grp_DelegationInfo>()
  2484. .SetColumns(x => new Grp_DelegationInfo()
  2485. {
  2486. Step = 2
  2487. })
  2488. .Where(x => x.Id == diid && x.IsDel == 0)
  2489. .ExecuteCommandAsync();
  2490. if (updStatus > 0) groupStep = 2;
  2491. string groupStepLabel = groupStep switch
  2492. {
  2493. 1 => "新建",
  2494. 2 => "企微消息通知(报批)",
  2495. _ => "未设置"
  2496. };
  2497. //记录日志
  2498. var teamName = _sqlSugar.Queryable<Grp_DelegationInfo>()
  2499. .Where(x => x.Id == diid && x.IsDel == 0)
  2500. .Select(x => x.TeamName)
  2501. .First() ?? "-";
  2502. var operationName = _sqlSugar.Queryable<Sys_Users>()
  2503. .Where(x => x.Id == currUserId && x.IsDel == 0)
  2504. .Select(x => x.CnName)
  2505. .First() ?? "-";
  2506. _groupTextLogger.LogInformation("团组:【{teamName}({groupId})】 操作人:【{operationName}】 操作时间:【{operationTime}】{logContent}", teamName, diid, operationName, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), groupStepLabel);
  2507. //设置 签证流程初始值
  2508. await _visaProcessRep.UpdateBatchTop4Step(dto.diid, dto.currUserId);
  2509. }
  2510. }
  2511. catch (Exception ex)
  2512. {
  2513. return Ok(JsonView(false, ex.Message));
  2514. }
  2515. return Ok(jw);
  2516. }
  2517. #endregion
  2518. #region 团组&签证
  2519. #region 团组&签证 New
  2520. /// <summary>
  2521. /// 团组&签证 New
  2522. /// DeepSeek API:测试API连通性
  2523. /// </summary>
  2524. /// <param name="file">请求dto</param>
  2525. /// <returns></returns>
  2526. [HttpPost]
  2527. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2528. public async Task<IActionResult> TestDeepSeekApiConnectivityAsync()
  2529. {
  2530. return Ok(JsonView(await _deepSeekService.TestApiConnectivityAsync()));
  2531. }
  2532. /// <summary>
  2533. /// 团组&签证 New
  2534. /// DeepSeek API:检查可用端点
  2535. /// </summary>
  2536. /// <param name="file">请求dto</param>
  2537. /// <returns></returns>
  2538. [HttpPost]
  2539. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2540. public async Task<IActionResult> DiscoverAvailableEndpointsAsync()
  2541. {
  2542. return Ok(JsonView(await _deepSeekService.DiscoverAvailableEndpointsAsync()));
  2543. }
  2544. /// <summary>
  2545. /// 团组&签证 New
  2546. /// 上传签证文件(客户填写签证文件),新增或更新 签证信息
  2547. /// </summary>
  2548. /// <param name="visaFile">文件</param>
  2549. /// <param name="fileTypeId">
  2550. /// 1. 澳新签证个人申请表
  2551. /// 2. 出国个人申请表
  2552. /// 3. 美国签证个人申请表格
  2553. /// 4. 沙特个人信息表格
  2554. /// 5. 申根签证个人资料表
  2555. /// 6. 中文个人简历模板
  2556. /// </param>
  2557. /// <returns></returns>
  2558. [HttpPost]
  2559. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2560. public async Task<IActionResult> VisaFileUploadAndUpdate(IFormFile visaFile, int fileTypeId)
  2561. {
  2562. //文件验证
  2563. if (visaFile.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  2564. //var visaFiles = new VisaUploadFileTypeView();
  2565. //var filetypes = VisaUploadFileTypeView.GetVisaUploadFileTypeViewItemInit();
  2566. //if (!filetypes.Any(x => x.FileId == fileTypeId)) return Ok(JsonView(false, "请选择文件类型!"));
  2567. //服务器存储文件
  2568. var fileServerPath = $"D:/FTP/File/OA2023/Office/Word/VisaClientData/Uploads";
  2569. if (!Directory.Exists(fileServerPath)) Directory.CreateDirectory(fileServerPath);
  2570. var filePath = Path.Combine(fileServerPath, visaFile.FileName);
  2571. using (var stream = new FileStream(filePath, FileMode.Create))
  2572. {
  2573. await visaFile.CopyToAsync(stream);
  2574. }
  2575. //日志记录-上传文件
  2576. _logger.LogInformation("【签证上传文件操作信息】签证文件存储成功!路径:{fileServerPath} 文件名称:{fileName}", fileServerPath, visaFile.FileName);
  2577. #region 上传文件到DeepSeekAPI
  2578. //IFormFile localFile = null;
  2579. ////获取项目中的cs文件
  2580. //try
  2581. //{
  2582. // _logger.LogInformation("读取并上传项目文件请求");
  2583. // // 1. 读取项目文件
  2584. // var readResponse = await _deepSeekService.ReadProjectFilesAsync(new List<string>() { @"OASystem.Domain\ViewModels\VisaFormDetails\AusNewVisaApplicationForm.cs" });
  2585. // if (readResponse.SuccessCount == 0)
  2586. // {
  2587. // return Ok(JsonView(false, "读取项目文件失败"));
  2588. // }
  2589. // localFile = readResponse.FileInfos.FirstOrDefault().FormFile;
  2590. //}
  2591. //catch (Exception ex)
  2592. //{
  2593. // _logger.LogError(ex, "读取项目文件失败");
  2594. // return Ok(JsonView(false, "读取项目文件失败"));
  2595. //}
  2596. //if (localFile == null)
  2597. //{
  2598. // return Ok(JsonView(false, "读取项目文件失败"));
  2599. //}
  2600. //var fileReq = new DeepSeekFileUploadRequest()
  2601. //{
  2602. // Files = new List<IFormFile> { localFile, visaFile },
  2603. //};
  2604. //var filesResult = new List<FileUploadResult>();
  2605. //try
  2606. //{
  2607. // _logger.LogInformation("开始上传 {FileCount} 个文件到DeepSeek API", fileReq.Files.Count);
  2608. // filesResult = await _deepSeekService.UploadFilesAsync(fileReq.Files, fileReq.Purpose);
  2609. // // 需要等待处理完成
  2610. // if (fileReq.WaitForProcessing)
  2611. // {
  2612. // foreach (var result in filesResult)
  2613. // {
  2614. // if (result.Success)
  2615. // {
  2616. // try
  2617. // {
  2618. // var processedFile = await _deepSeekService.WaitForFileProcessingAsync(result.FileId);
  2619. // result.Status = processedFile.Status;
  2620. // }
  2621. // catch (Exception ex)
  2622. // {
  2623. // _logger.LogError(ex, "DeepSeek API文件上传失败");
  2624. // return Ok(JsonView(false, $"DeepSeek API文件上传处理失败: {ex.Message}"));
  2625. // }
  2626. // }
  2627. // }
  2628. // }
  2629. //}
  2630. //catch (Exception ex)
  2631. //{
  2632. // _logger.LogError(ex, "DeepSeek API文件上传失败");
  2633. // return Ok(JsonView(false, $"DeepSeek API文件上传处理失败: {ex.Message}"));
  2634. //}
  2635. //#endregion
  2636. //if (filesResult == null || filesResult.Count < 1)
  2637. //{
  2638. // return Ok(JsonView(false, $"DeepSeek API文件上传处理失败"));
  2639. //}
  2640. ////
  2641. //try
  2642. //{
  2643. // var fileIds = filesResult.Where(x => x.Success).Select(x => x.FileId).ToList();
  2644. // _logger.LogInformation("使用 {FileCount} 个文件进行聊天", fileIds.Count);
  2645. // string question = string.Format("将上传的文件内容按照识别为JSON格式,并按照 AusNewVisaApplicationForm 指定的实体类结构进行映射。确保字段和值对应、文档中数据的完整性、复选框选择打勾后的文本。第一项从不识别\"比如美国(2024年7月29日)\"相关文字。");
  2646. // var response = await _deepSeekService.ChatWithFilesAsync(fileIds, question);
  2647. // return Ok(response);
  2648. //}
  2649. //catch (Exception ex)
  2650. //{
  2651. // _logger.LogError(ex, "使用文件聊天失败");
  2652. // return Ok(JsonView(false, $"聊天失败: {ex.Message}"));
  2653. //}
  2654. #endregion
  2655. #region kimi API
  2656. //加载文件OpCarTouristGuideGroundContent
  2657. //kimi AI 识别文档返回json结果
  2658. int kimiAI_API_Index = 0; //KIMI-AI-API 访问计次
  2659. var KiMiApi = new KiMiApiClient();
  2660. var files = new List<IFormFile>() { visaFile };
  2661. var seedConter = await KiMiApi.UploadFilesAsync(files);
  2662. if (seedConter.Count == 0) return Ok(JsonView(false, "Kimi AI 文件上传结果为空!"));
  2663. //var seedMessage = filetypes.Where(x => x.FileId == fileTypeId).FirstOrDefault()?.KimiAITips;
  2664. var seedMessage = string.Format(@"你是领事馆电子材料审核员,只关注 Word 里的表格,正文、页眉页脚、水印、批注全部忽略。
  2665. 任务:把表格里的每个可填字段转换成“标题:值”的键值对,标题用原文,值用原文,不翻译。
  2666. 规则如下:
  2667. 1. 行列对齐:先按视觉补齐所有合并单元格——纵向合并则重复上方单元格内容,横向合并则留空字符串;无线表按对齐虚拟列线。
  2668. 2. 单格内出现多个“□”时,把被勾选(☑、√、×、■)的选项原文输出;若没有任何勾选,该字段输出 null。
  2669. 3. 所有日期统一转 yyyy-mm-dd,原格式“1990年1月1日”→1990-01-01;若缺日/月,用-01补位。
  2670. 4. 电话、传真、手机号:输出连续数字,遇到“(0 )”或“-”一律删除,只保留 7~15 位数字;若缺区号,原样保留。
  2671. 5. 金额:保留原数字,如“3000”。
  2672. 6. 地址:省、市、区、街道、门牌、邮编用空格分隔,不省略。
  2673. 7. 若同一张表出现“现住址”“家庭地址”“单位地址”等多列,依次编号 address_home / address_unit / address_legal。
  2674. 8. 输出顺序:按表格从左到右、从上到下逐行扫描,字段名重复时加序号,如 child_name_1、child_name_2。
  2675. 9. 结果格式:每行一个键值对,字段名与值之间用英文冒号+空格分隔,不要表格 Markdown,不要多余说明。
  2676. 10. 文件命名空间:每份表的最前面加一行 filename 作为起始标记(例:出国个人申请表.doc)。
  2677. 11. 内容为空的字段,显示标题,记空值。
  2678. 12. 只返回json结果,不需要其他内容;json内容去掉换行。");
  2679. var messages = new List<SeedMessages>
  2680. {
  2681. new() { Role = KimiRole.system, Content = "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长识别文件为Json格式的对话。你会为用户提供安全,有帮助,准确的回答。同时,你会拒绝一切涉及恐怖主义,种族歧视,黄色暴力等问题的回答。Moonshot AI 为专有名词,不可翻译成其他语言。" },
  2682. new() { Role = KimiRole.user, Content = seedMessage }
  2683. };
  2684. messages.InsertRange(1, seedConter);
  2685. string jsonString = string.Empty;
  2686. object jsonData = null;
  2687. bool isJson = false; // 是否是json格式 不是json格式继续访问AI
  2688. while (!isJson)
  2689. {
  2690. kimiAI_API_Index++;
  2691. var kimiApiResult = await KiMiApi.SeedMessage(messages);
  2692. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  2693. jsonString += kimiApiResult_JObject["content"].ToString();
  2694. string startStr = "```json", endStr = "```";
  2695. // 判断并清除开头部分
  2696. if (jsonString.StartsWith(startStr))
  2697. {
  2698. jsonString = jsonString.Replace(startStr, "");
  2699. }
  2700. // 判断并清除结尾部分
  2701. if (jsonString.EndsWith(endStr))
  2702. {
  2703. jsonString = jsonString.Replace(endStr, "");
  2704. }
  2705. //验证json格式是否正确
  2706. try
  2707. {
  2708. jsonData = JsonDocument.Parse(jsonString);
  2709. isJson = true; // 如果解析成功,则是json格式
  2710. }
  2711. catch (Exception)
  2712. {
  2713. //messages = new List<SeedMessages>() { new() { Role = KimiRole.user, Content = "接着说" } };
  2714. messages.Add(new() { Role = KimiRole.user, Content = "接着上一个话题继续完成未完成的内容。" });
  2715. }
  2716. }
  2717. if (jsonData == null)
  2718. {
  2719. return Ok(JsonView(false, "kimi识别json转换失败。"));
  2720. }
  2721. var visaDetails = new VisaDetailsView();
  2722. //按照表格类型分别进行参数处理
  2723. // 1. 澳新签证个人申请表
  2724. // 2. 出国个人申请表
  2725. // 3. 美国签证个人申请表格
  2726. // 4. 沙特个人信息表格
  2727. // 5. 申根签证个人资料表
  2728. // 6. 中文个人简历模板
  2729. switch (fileTypeId)
  2730. {
  2731. //澳新签证个人申请表
  2732. case 1:
  2733. _logger.LogInformation("【签证上传文件操作信息】【澳新签证个人申请表】【KIMI-AI-API访问计次】{count} 次", kimiAI_API_Index);
  2734. VisaApplication resInfo = System.Text.Json.JsonSerializer.Deserialize<VisaApplication>(jsonString);
  2735. break;
  2736. //美国签证个人申请表格
  2737. case 3:
  2738. _logger.LogInformation("【签证上传文件操作信息】【美国签证个人申请表格】【KIMI-AI-API访问计次】{count} 次", kimiAI_API_Index);
  2739. string name = (string)jsonData.GetType().GetProperty("姓名")!.GetValue(jsonData)!;
  2740. string passportNo = (string)jsonData.GetType().GetProperty("护照号码")!.GetValue(jsonData)!;
  2741. string passportPlace = (string)jsonData.GetType().GetProperty("护照签发地")!.GetValue(jsonData)!;
  2742. string idNo = (string)jsonData.GetType().GetProperty("身份证号码")!.GetValue(jsonData)!;
  2743. string maritalStatusText = (string)jsonData.GetType().GetProperty("婚姻状况")!.GetValue(jsonData)!;
  2744. int maritalStatus = maritalStatusText switch
  2745. {
  2746. "未设置" => 0,
  2747. "未婚" => 1,
  2748. "已婚" => 2,
  2749. "离异" => 3,
  2750. "丧偶" => 4,
  2751. _ => -1
  2752. };
  2753. string birthDay = (string)jsonData.GetType().GetProperty("出生日期")!.GetValue(jsonData)!;
  2754. DateTime.TryParse(birthDay, out DateTime birthDayDt);
  2755. string birthPlace = (string)jsonData.GetType().GetProperty("出生地点")!.GetValue(jsonData)!;
  2756. var birthDay1 = CommonFun.SplitProvinceCity(birthPlace);
  2757. string birthDay_mate = (string)jsonData.GetType().GetProperty("配偶出生日期")!.GetValue(jsonData)!;
  2758. DateTime.TryParse(birthDay_mate, out DateTime birthDayDt_mate);
  2759. string birthPlace_mate = (string)jsonData.GetType().GetProperty("配偶出生地")!.GetValue(jsonData)!;
  2760. var birthDay1_mate = CommonFun.SplitProvinceCity(birthPlace_mate);
  2761. var addressText = (string)jsonData.GetType().GetProperty("家庭地址")!.GetValue(jsonData)!;
  2762. var address = SplitAddressZip(addressText);
  2763. //美国驾照信息
  2764. string driveText = (string)jsonData.GetType().GetProperty("是否有美国驾照")!.GetValue(jsonData)!;
  2765. var driveInfo = LicenseParser(driveText);
  2766. //美国社会安全号或者纳税ID号
  2767. string ssnText = (string)jsonData.GetType().GetProperty("是否有美国社会安全号或者纳税ID号")!.GetValue(jsonData)!;
  2768. //单位信息
  2769. string clientName = (string)jsonData.GetType().GetProperty("目前就职单位或就读学校")!.GetValue(jsonData)!;
  2770. string clientAddr = (string)jsonData.GetType().GetProperty("目前就职单位或就读学校地址")!.GetValue(jsonData)!;//
  2771. var (hasSsnItin, number) = SsnItinParser(ssnText);
  2772. //婚姻相关
  2773. var WeddingText = (string)jsonData.GetType().GetProperty("若离婚,婚姻起止时间")!.GetValue(jsonData)!;
  2774. var (f, t) = WeddingParser(WeddingText);
  2775. //美国联系人电话和邮箱
  2776. var peText = (string)jsonData.GetType().GetProperty("联系人电话及邮箱")!.GetValue(jsonData)!;
  2777. var usa_phone = Regex.Match(peText ?? "", @"[\d-]+").Value; // 数字和中横线
  2778. var usa_email = Regex.Match(peText ?? "", @"[^@\s]+@[^@\s]+\.[^@\s]+").Value;
  2779. //赴美时间、停留时间处理
  2780. var usa_dateText = (string)jsonData.GetType().GetProperty("联系人电话及邮箱")!.GetValue(jsonData)!;
  2781. var (usa_d, usa_days) = TravelParser(usa_dateText);
  2782. //赴美同行人
  2783. string usaCmpNameText = (string)jsonData.GetType().GetProperty("赴美同行人")!.GetValue(jsonData)!;
  2784. string usaCmpName = string.Empty;
  2785. if (usaCmpNameText.Contains("是"))
  2786. {
  2787. var usaCmpNameTextSplit = usaCmpNameText.Replace(":", "-").Replace("", "-").Split("-");
  2788. if (usaCmpNameTextSplit.Length > 1)
  2789. {
  2790. usaCmpName = usaCmpNameTextSplit[1];
  2791. }
  2792. }
  2793. //是否丢失过护照
  2794. string loseCodeText = (string)jsonData.GetType().GetProperty("是否丢失过护照")!.GetValue(jsonData)!;
  2795. string loseCode = string.Empty;
  2796. if (loseCodeText.Contains("是"))
  2797. {
  2798. var loseCodeTextSplit = loseCodeText.Replace(":", "-").Replace("", "-").Split("-");
  2799. if (loseCodeTextSplit.Length > 1)
  2800. {
  2801. usaCmpName = loseCodeTextSplit[1];
  2802. }
  2803. }
  2804. //是否获得过美国签证
  2805. string usaVisaText = (string)jsonData.GetType().GetProperty("是否丢失过护照")!.GetValue(jsonData)!;
  2806. string usaVisaDateText = (string)jsonData.GetType().GetProperty("获得日期")!.GetValue(jsonData)!;
  2807. //DateTime usaVisaDate;
  2808. if (!string.IsNullOrEmpty(usaVisaDateText))
  2809. {
  2810. if (DateTime.TryParse(usaVisaDateText, out DateTime usaVisaDate))
  2811. {
  2812. visaDetails.ClientInfo.GetUSAVisaDate = usaVisaDate;
  2813. }
  2814. }
  2815. string usaFingerText = (string)jsonData.GetType().GetProperty("是否留过十指指纹")!.GetValue(jsonData)!;
  2816. int usaFinger = 0;
  2817. if (usaFingerText.Contains('是')) usaFinger = 1;
  2818. string usaLoseText = (string)jsonData.GetType().GetProperty("签证是否曾遗失")!.GetValue(jsonData)!;
  2819. int usaLose = 0;
  2820. if (usaLoseText.Contains("是")) usaLose = 1;
  2821. //是否曾抵达过美国
  2822. string usaHadArrival‌Text = (string)jsonData.GetType().GetProperty("是否曾抵达过美国")!.GetValue(jsonData)!;
  2823. var (usaHadArrivalf, usaHadArrivalD, usaHadArrivalDays) = TravelHadFlagParser(usaHadArrival‌Text);
  2824. //是否有被美国拒发签证的经历
  2825. string usaRejecteVisaTest = (string)jsonData.GetType().GetProperty("是否有被美国拒发签证的经历")!.GetValue(jsonData)!;
  2826. var (denied, rejectedDate, rejectedPlace, rejectedType) = VisaDenialParser(usaRejecteVisaTest);
  2827. if (denied)
  2828. {
  2829. visaDetails.ClientInfo.RejectedDate = rejectedDate;
  2830. visaDetails.ClientInfo.RejectedPlace = rejectedPlace;
  2831. visaDetails.ClientInfo.RejectedVisa = rejectedType;
  2832. }
  2833. //是否在申请或曾经申请过美国移民签证
  2834. string usaImmVisaText‌ = (string)jsonData.GetType().GetProperty("是否在申请或曾经申请过美国移民签证")!.GetValue(jsonData)!;
  2835. var (immDenied, immDate, immPlace, immType) = VisaDenialParser(usaImmVisaText‌);
  2836. if (immDenied)
  2837. {
  2838. visaDetails.ClientInfo.USAImmVisa‌Date = immDate;
  2839. visaDetails.ClientInfo.USAImmVisa‌Place = immPlace;
  2840. visaDetails.ClientInfo.USAImmVisa‌ = immType;
  2841. }
  2842. //在美直系
  2843. string usaImmedText‌ = (string)jsonData.GetType().GetProperty("是否有直系亲属在美国")!.GetValue(jsonData)!;
  2844. var (immedDenied, immedName, immedRel, immedStat) = FourFieldParser(usaImmedText‌);
  2845. if (immedDenied)
  2846. {
  2847. visaDetails.ClientInfo.USAImmedFamName = immedName;
  2848. visaDetails.ClientInfo.USAImmedFamRel = immedRel;
  2849. visaDetails.ClientInfo.USAImmedFamStat = immedStat;
  2850. }
  2851. //在美旁系
  2852. string usaUncleText‌ = (string)jsonData.GetType().GetProperty("是否有旁系亲属在美国")!.GetValue(jsonData)!;
  2853. var (uncleDenied, uncleName, uncleRel, uncleStat) = FourFieldParser(usaUncleText‌);
  2854. if (immedDenied)
  2855. {
  2856. visaDetails.ClientInfo.USAUncleFamName = uncleName;
  2857. visaDetails.ClientInfo.USAUncleFamRel = uncleName;
  2858. visaDetails.ClientInfo.USAUncleFamStat = uncleStat;
  2859. }
  2860. //服役时间 MilitaryParser
  2861. string militaryText‌ = (string)jsonData.GetType().GetProperty("是否曾参过军")!.GetValue(jsonData)!;
  2862. var (militaryH, militaryB, militaryR, militaryS, (militaryStart, militaryEnd)) = MilitaryParser(militaryText‌);
  2863. var militarys = new List<MilitaryInfo>();
  2864. if (militaryH)
  2865. {
  2866. militarys.Add(new()
  2867. {
  2868. MilBranch = militaryB,
  2869. MilRank = militaryR,
  2870. MilSkill = militaryS,
  2871. ServeTimeBegin = militaryStart,
  2872. ServeTimeEnd = militaryEnd,
  2873. });
  2874. }
  2875. //申请人父母信息 ParentParser
  2876. string fthMthText‌ = (string)jsonData.GetType().GetProperty("申请人父母信息")!.GetValue(jsonData)!;
  2877. if (!string.IsNullOrEmpty(fthMthText‌))
  2878. {
  2879. var (fName, fDob, mName, mDob) = ParentParser(fthMthText‌);
  2880. visaDetails.ClientInfo.FthName = fName;
  2881. visaDetails.ClientInfo.FthBirth = fDob;
  2882. visaDetails.ClientInfo.MthName = mName;
  2883. visaDetails.ClientInfo.MthBirth = mDob;
  2884. }
  2885. visaDetails.ClientInfo = new()
  2886. {
  2887. LastName = name.GetLastName(),
  2888. FirstName = name.GetFirstName(),
  2889. Sex = (string)jsonData.GetType().GetProperty("性别")!.GetValue(jsonData)! == "男" ? 0 : 1,
  2890. OldName = (string)jsonData.GetType().GetProperty("曾用名")!.GetValue(jsonData)!,
  2891. BirthDay = birthDayDt,
  2892. BirthProvince = birthDay1.province,
  2893. BirthCity = birthDay1.city,
  2894. Address = address.address,
  2895. PostCodes = address.zipCode,
  2896. Marriage = maritalStatus,
  2897. MateName = (string)jsonData.GetType().GetProperty("配偶姓名")!.GetValue(jsonData)!,
  2898. MateBirthDay = birthDayDt_mate,
  2899. MateBirthCountry = birthDay1_mate.province,
  2900. MateBirthCity = birthDay1_mate.city,
  2901. USA_DLNo = driveInfo.number,
  2902. USA_DLPlace = driveInfo.place,
  2903. USA_SSNOrITIN = number,
  2904. Resident = CleanPrefix((string)jsonData.GetType().GetProperty("是否是其他国家的永久居民")!.GetValue(jsonData)!),
  2905. HasSocialAcc‌ = CleanPrefix((string)jsonData.GetType().GetProperty("近五年内是否使用过任何社交账号")!.GetValue(jsonData)!),
  2906. WeddingDate = f,
  2907. DivorceDate = t,
  2908. DivorceRsn = (string)jsonData.GetType().GetProperty("离婚原因")!.GetValue(jsonData)!,
  2909. Job = (string)jsonData.GetType().GetProperty("职务")!.GetValue(jsonData)!,
  2910. Wage = (string)jsonData.GetType().GetProperty("月薪")!.GetValue(jsonData)!,
  2911. WorkState = (string)jsonData.GetType().GetProperty("工作职责")!.GetValue(jsonData)!,
  2912. WorkDate = (string)jsonData.GetType().GetProperty("入职/入学时间(详细到月)")!.GetValue(jsonData)!,
  2913. USAAddress = (string)jsonData.GetType().GetProperty("请提供美国详细住址")!.GetValue(jsonData)!,
  2914. USAPurpose = (string)jsonData.GetType().GetProperty("赴美目的")!.GetValue(jsonData)!,
  2915. CostBearers = (string)jsonData.GetType().GetProperty("费用谁付")!.GetValue(jsonData)!,
  2916. USAContact = (string)jsonData.GetType().GetProperty("美国联系人或组织")!.GetValue(jsonData)!,
  2917. USAContactTel = usa_phone,
  2918. USAContactEmail = usa_email,
  2919. USADate = usa_d,
  2920. USADays = usa_days,
  2921. USAArrivalCity‌ = (string)jsonData.GetType().GetProperty("赴美的到达城市")!.GetValue(jsonData)!,
  2922. USADepartCity‌ = (string)jsonData.GetType().GetProperty("赴美的离开城市")!.GetValue(jsonData)!,
  2923. USAVisitSites‌ = (string)jsonData.GetType().GetProperty("计划在美国访问的景点")!.GetValue(jsonData)!,
  2924. USACmpName = usaCmpName,
  2925. USACmpRelation = (string)jsonData.GetType().GetProperty("同行人关系")!.GetValue(jsonData)!,
  2926. Tel = (string)jsonData.GetType().GetProperty("家庭电话")!.GetValue(jsonData)!,
  2927. ClientPhone = (string)jsonData.GetType().GetProperty("单位电话")!.GetValue(jsonData)!,
  2928. Phone = (string)jsonData.GetType().GetProperty("移动电话")!.GetValue(jsonData)!,
  2929. Cntry5Y‌ = (string)jsonData.GetType().GetProperty("过去5年内到过的国家")!.GetValue(jsonData)!,
  2930. LangSkill‌ = (string)jsonData.GetType().GetProperty("面签时能流利交流的语言")!.GetValue(jsonData)!,
  2931. LoseCode = loseCode,
  2932. DenyNationRsn = (string)jsonData.GetType().GetProperty("曾被哪些国家拒签/拒签原因")!.GetValue(jsonData)!,
  2933. USAVisaCode = (string)jsonData.GetType().GetProperty("签证号码")!.GetValue(jsonData)!,
  2934. USAVisaCate = (string)jsonData.GetType().GetProperty("获签类型")!.GetValue(jsonData)!,
  2935. //GetUSAVisaDate = usaVisaDate,
  2936. USAFinger = usaFinger,
  2937. IsLose = usaLose,
  2938. USAHadArrival = usaHadArrivalD,
  2939. USAHadDays = usaHadArrivalDays,
  2940. ArmyState = JsonConvert.SerializeObject(militarys)
  2941. };
  2942. visaDetails.ClientCerts = new() {
  2943. new(){ SdId = 74,CertNo = passportNo,IDCardAddress = passportPlace },
  2944. new(){ SdId = 73,CertNo = idNo},
  2945. };
  2946. visaDetails.ClientCompany = new() { CompanyFullName = clientName, Address = clientAddr };
  2947. break;
  2948. //中文个人简历模板
  2949. case 6:
  2950. _logger.LogInformation("【签证上传文件操作信息】【中文个人简历模板】【KIMI-AI-API访问计次】{count} 次", kimiAI_API_Index);
  2951. visaDetails.ClientInfo.LastName = (string)jsonData.GetType().GetProperty("姓名(中英文拼音)")!.GetValue(jsonData)!;
  2952. visaDetails.ClientInfo.Sex = (string)jsonData.GetType().GetProperty("性别")!.GetValue(jsonData)! == "男" ? 0 : 1;
  2953. DateTime.TryParse((string)jsonData.GetType().GetProperty("出生日期")!.GetValue(jsonData)!, out DateTime birthDay11);
  2954. visaDetails.ClientInfo.BirthDay = birthDay11;
  2955. visaDetails.ClientInfo.BirthProvince = (string)jsonData.GetType().GetProperty("出生地")!.GetValue(jsonData)!;
  2956. visaDetails.ClientInfo.Address = (string)jsonData.GetType().GetProperty("家庭地址")!.GetValue(jsonData)!;
  2957. visaDetails.ClientInfo.Tel = (string)jsonData.GetType().GetProperty("家庭电话")!.GetValue(jsonData)!;
  2958. visaDetails.ClientInfo.TableOpTel = (string)jsonData.GetType().GetProperty("工作电话")!.GetValue(jsonData)!;
  2959. visaDetails.ClientInfo.Phone = (string)jsonData.GetType().GetProperty("移动电话")!.GetValue(jsonData)!;
  2960. visaDetails.ClientInfo.Email = (string)jsonData.GetType().GetProperty("电子邮件")!.GetValue(jsonData)!;
  2961. //学校信息
  2962. visaDetails.ClientSchools.Add(new()
  2963. {
  2964. School = (string)jsonData.GetType().GetProperty("教育学校名称")!.GetValue(jsonData)!,
  2965. Education = (string)jsonData.GetType().GetProperty("教育学位")!.GetValue(jsonData)!,
  2966. Subject = (string)jsonData.GetType().GetProperty("教育专业")!.GetValue(jsonData)!,
  2967. Remark = (string)jsonData.GetType().GetProperty("教育论文题目/研究重点(硕士、博士)")!.GetValue(jsonData)!,
  2968. });
  2969. //工作信息
  2970. visaDetails.ClientCompany = new()
  2971. {
  2972. CompanyFullName = (string)jsonData.GetType().GetProperty("工作经历雇主")!.GetValue(jsonData)!,
  2973. };
  2974. visaDetails.ClientInfo.Job = (string)jsonData.GetType().GetProperty("工作经历职位或头衔职责")!.GetValue(jsonData)!;
  2975. break;
  2976. default:
  2977. break;
  2978. }
  2979. //数据提交
  2980. #region 数据提交
  2981. _sqlSugar.BeginTran();
  2982. // 客户公司表
  2983. var compId = UpsertReturnId<Crm_CustomerCompany>(visaDetails.ClientCompany, o => o.CompanyFullName);
  2984. if (compId < 1)
  2985. {
  2986. _sqlSugar.RollbackTran();
  2987. return Ok(JsonView(false, "公司信息更新失败!"));
  2988. }
  2989. visaDetails.ClientInfo.CrmCompanyId = compId;
  2990. // 客户资料表
  2991. var clientId = UpsertReturnId<Crm_DeleClient>(visaDetails.ClientInfo, o => new { o.LastName, o.FirstName });
  2992. if (clientId < 1)
  2993. {
  2994. _sqlSugar.RollbackTran();
  2995. return Ok(JsonView(false, "客户信息更新失败!"));
  2996. }
  2997. for (int i = 0; i < visaDetails.ClientFamilys.Count(); i++)
  2998. {
  2999. visaDetails.ClientFamilys[i].DcId = clientId;
  3000. }
  3001. for (int i = 0; i < visaDetails.ClientCerts.Count(); i++)
  3002. {
  3003. visaDetails.ClientCerts[i].DcId = clientId;
  3004. }
  3005. for (int i = 0; i < visaDetails.ClientSchools.Count(); i++)
  3006. {
  3007. visaDetails.ClientSchools[i].DcId = clientId;
  3008. }
  3009. // 客户家庭表
  3010. foreach (var item in visaDetails.ClientFamilys)
  3011. {
  3012. var famId = UpsertReturnId<Crm_VisaCustomerFamily>(item, o => o.Name);
  3013. if (famId < 1)
  3014. {
  3015. _sqlSugar.RollbackTran();
  3016. return Ok(JsonView(false, "客户家庭信息更新失败!"));
  3017. }
  3018. }
  3019. // 客户证件表
  3020. foreach (var item in visaDetails.ClientCerts)
  3021. {
  3022. var certId = UpsertReturnId<Crm_CustomerCert>(item, o => o.CertNo);
  3023. if (certId < 1)
  3024. {
  3025. _sqlSugar.RollbackTran();
  3026. return Ok(JsonView(false, "客户证件信息更新失败!"));
  3027. }
  3028. }
  3029. // 客户学历表
  3030. foreach (var item in visaDetails.ClientSchools)
  3031. {
  3032. var schoolId = UpsertReturnId<Crm_VisaCustomerSchool>(item, o => o.School);
  3033. if (schoolId < 1)
  3034. {
  3035. _sqlSugar.RollbackTran();
  3036. return Ok(JsonView(false, "客户证件信息更新失败!"));
  3037. }
  3038. }
  3039. _sqlSugar.CommitTran();
  3040. #endregion
  3041. #endregion
  3042. return Ok(JsonView(true, jsonString));
  3043. }
  3044. #region 扩展处理
  3045. // 从 Expression<Func<T,object>> 里取出属性名
  3046. static string GetPropName<T>(Expression<Func<T, object>> expr)
  3047. {
  3048. if (expr.Body is UnaryExpression ue) expr = Expression.Lambda<Func<T, object>>(ue.Operand, expr.Parameters);
  3049. return ((MemberExpression)expr.Body).Member.Name;
  3050. }
  3051. /// <summary>
  3052. /// 5.1.4.193 可用:存在更新(非NULL非空串),不存在插入,返回主键ID
  3053. /// </summary>
  3054. public int UpsertReturnId<T>(T entity, Expression<Func<T, object>> whereExpr) where T : class, new()
  3055. {
  3056. // 1. 空字符串→NULL,让后续忽略
  3057. foreach (var pi in typeof(T).GetProperties())
  3058. if (pi.PropertyType == typeof(string) &&
  3059. pi.GetValue(entity) is string s &&
  3060. string.IsNullOrWhiteSpace(s))
  3061. pi.SetValue(entity, null);
  3062. // 2. 从表达式里拿属性名
  3063. string propName = GetPropName(whereExpr);
  3064. var propValue = typeof(T).GetProperty(propName)?.GetValue(entity);
  3065. // 3. 判断存在
  3066. bool exists = _sqlSugar.Queryable<T>().Where(propName, propValue).Any();
  3067. // 4. 执行 Upsert
  3068. if (exists)
  3069. {
  3070. _sqlSugar.Updateable(entity)
  3071. .WhereColumns(propName) // 指定条件列
  3072. .IgnoreColumns(ignoreAllNullColumns: true) // 忽略 NULL
  3073. .ExecuteCommand();
  3074. }
  3075. else
  3076. {
  3077. _sqlSugar.Insertable(entity).ExecuteReturnIdentity();
  3078. }
  3079. // 5. 返回主键值(自增/雪花已回填)
  3080. var idProp = typeof(T).GetProperties()
  3081. .First(p => p.GetCustomAttributes<SugarColumn>()
  3082. .Any(a => a.IsPrimaryKey));
  3083. return (int)idProp.GetValue(entity)!;
  3084. }
  3085. /// <summary>
  3086. /// 地址喊邮编 相关处理
  3087. /// </summary>
  3088. public static (string address, string zipCode) SplitAddressZip(string? s)
  3089. {
  3090. if (string.IsNullOrWhiteSpace(s))
  3091. return ("", "");
  3092. ReadOnlySpan<char> src = s.AsSpan();
  3093. int i = src.IndexOf("邮编".AsSpan());
  3094. if (i < 0) // 没有“邮编”字样
  3095. return (src.Trim().ToString(), "");
  3096. ReadOnlySpan<char> addr = src[..i].TrimEnd();
  3097. ReadOnlySpan<char> zip = src[(i + 3)..].Trim(); // 跳过“邮编:”
  3098. // 可能只有“邮编:”而没有数字
  3099. return (addr.IsEmpty ? "" : addr.ToString(),
  3100. zip.IsEmpty ? "" : zip.ToString());
  3101. }
  3102. /// <summary>
  3103. /// 驾照相 关处理
  3104. /// </summary>
  3105. /// <param name="raw"></param>
  3106. /// <returns></returns>
  3107. public static (bool hasLicense, string number, string place) LicenseParser(string? raw)
  3108. {
  3109. if (string.IsNullOrWhiteSpace(raw))
  3110. return (false, "", "");
  3111. // 1. 是否持有
  3112. bool has = raw.StartsWith("是", System.StringComparison.OrdinalIgnoreCase) ||
  3113. raw.StartsWith("Y", System.StringComparison.OrdinalIgnoreCase);
  3114. // 2. 去掉前缀,按空格切
  3115. ReadOnlySpan<char> s = raw.AsSpan();
  3116. int colon = s.IndexOf(':');
  3117. ReadOnlySpan<char> after = colon < 0 ? s : s[(colon + 1)..];
  3118. after = after.Trim();
  3119. int space = after.IndexOf(' ');
  3120. ReadOnlySpan<char> num = space < 0 ? after : after[..space];
  3121. ReadOnlySpan<char> st = space < 0 ? ReadOnlySpan<char>.Empty : after[(space + 1)..];
  3122. return (has, num.ToString().Trim(), st.ToString().Trim());
  3123. }
  3124. /// <summary>
  3125. /// 美国社会安全号或者纳税ID号 相关处理
  3126. /// </summary>
  3127. /// <param name="raw"></param>
  3128. /// <returns></returns>
  3129. public static (bool hasSsnItin, string number) SsnItinParser(string? raw)
  3130. {
  3131. if (string.IsNullOrWhiteSpace(raw))
  3132. return (false, "");
  3133. ReadOnlySpan<char> s = raw.AsSpan();
  3134. // 1. 是否持有
  3135. bool has = s.StartsWith("是", System.StringComparison.Ordinal) ||
  3136. s.StartsWith("Y", System.StringComparison.OrdinalIgnoreCase);
  3137. // 2. 取号码(去掉前缀和空格)
  3138. int colon = s.IndexOf(':');
  3139. ReadOnlySpan<char> num = colon < 0
  3140. ? ReadOnlySpan<char>.Empty
  3141. : s[(colon + 1)..].Trim();
  3142. return (has, num.ToString());
  3143. }
  3144. /// <summary>
  3145. /// 取消开始的“是:”或者“是”或者“ :”
  3146. /// </summary>
  3147. /// <param name="raw"></param>
  3148. /// <returns></returns>
  3149. public static string CleanPrefix(string? raw)
  3150. {
  3151. if (string.IsNullOrWhiteSpace(raw)) return "";
  3152. // 跳过第一个“是”或“Y”
  3153. ReadOnlySpan<char> s = raw.AsSpan();
  3154. int start = 0;
  3155. if (s.StartsWith("是") || s.StartsWith("Y", StringComparison.OrdinalIgnoreCase))
  3156. start = 1;
  3157. // 跳过连续 : 或空格
  3158. while (start < s.Length && (s[start] == ':' || s[start] == ' '))
  3159. start++;
  3160. return s[start..].Trim().ToString();
  3161. }
  3162. /// <summary>
  3163. /// 婚姻起止时间处理
  3164. /// </summary>
  3165. /// <param name="raw"></param>
  3166. /// <returns></returns>
  3167. public static (DateTime? fromDate, DateTime? toDate) WeddingParser(string? raw)
  3168. {
  3169. if (string.IsNullOrWhiteSpace(raw)) return (null, null);
  3170. Regex _clean = new(@"[\s~至]+", RegexOptions.Compiled);
  3171. // 1. 把所有“空格~至”统一成 '-'
  3172. string normalized = _clean.Replace(raw, "-");
  3173. // 2. 切两段
  3174. string[] parts = normalized.Split('-', StringSplitOptions.RemoveEmptyEntries);
  3175. if (parts.Length != 2) return (null, null);
  3176. // 3. 解析
  3177. bool ff = DateTime.TryParse(parts[0].Trim(), out var from);
  3178. bool tf = DateTime.TryParse(parts[1].Trim(), out var to);
  3179. return (tf ? from : null, tf ? to : null);
  3180. }
  3181. /// <summary>
  3182. /// 出行日期和天数处理
  3183. /// </summary>
  3184. /// <param name="raw"></param>
  3185. /// <returns></returns>
  3186. public static (DateTime? travelDate, int? days) TravelParser(string? raw)
  3187. {
  3188. if (string.IsNullOrWhiteSpace(raw)) return (null, null);
  3189. // 切成两段:第一段日期,第二段天数
  3190. Regex sep = new(@"[^0-9./-]+", RegexOptions.Compiled);
  3191. string[] parts = sep.Split(raw.Trim());
  3192. if (parts.Length < 2) return (null, null);
  3193. bool okDate = DateTime.TryParse(parts[0], out DateTime date);
  3194. bool okDays = int.TryParse(parts[1], out int days) && days > 0;
  3195. return (okDate ? date : null, okDays ? days : null);
  3196. }
  3197. /// <summary>
  3198. /// 是否曾抵达过美国
  3199. /// </summary>
  3200. /// <param name="raw"></param>
  3201. /// <returns></returns>
  3202. public static (bool hasTravel, string date, string days) TravelHadFlagParser(string? raw)
  3203. {
  3204. if (string.IsNullOrWhiteSpace(raw)) return (false, string.Empty, string.Empty);
  3205. Regex sep = new(@"[^0-9./-]+", RegexOptions.Compiled);
  3206. // 1. 是否持有
  3207. bool has = raw.AsSpan().TrimStart().StartsWith("是") ||
  3208. raw.AsSpan().TrimStart().StartsWith("Y", StringComparison.OrdinalIgnoreCase);
  3209. // 2. 用非数字分隔符切成三段:第一段空,第二段日期,第三段天数
  3210. string[] parts = sep.Split(raw.Trim());
  3211. if (parts.Length < 3) return (has, string.Empty, string.Empty);
  3212. return (has, parts[1], parts[2]);
  3213. }
  3214. /// <summary>
  3215. /// 是否有被美国拒发签证的经历
  3216. /// </summary>
  3217. /// <param name="raw"></param>
  3218. /// <returns></returns>
  3219. public static (bool wasDenied, DateTime? date, string place, string visaType) VisaDenialParser(string? raw)
  3220. {
  3221. if (string.IsNullOrWhiteSpace(raw)) return (false, null, "", "");
  3222. bool denied = raw.AsSpan().TrimStart().StartsWith("有") ||
  3223. raw.AsSpan().TrimStart().StartsWith("Y", StringComparison.OrdinalIgnoreCase);
  3224. var parts = Regex.Split(raw.Trim(), @"[^0-9A-Za-z-]+");
  3225. if (parts.Length < 4) return (denied, null, "", "");
  3226. DateTime.TryParse(parts[1], out var dt); // ← 这里改为 DateTime
  3227. return (denied, dt, parts[2], parts[3]);
  3228. }
  3229. /// <summary>
  3230. /// 在美直系、旁系 处理
  3231. /// </summary>
  3232. /// <param name="raw"></param>
  3233. /// <returns></returns>
  3234. public static (bool flag, string name, string rel, string stat) FourFieldParser(string? raw)
  3235. {
  3236. if (string.IsNullOrWhiteSpace(raw)) return (false, "", "", "");
  3237. var parts = raw.Split((char[]?)null, StringSplitOptions.RemoveEmptyEntries);
  3238. if (parts.Length < 4) return (false, "", "", "");
  3239. bool flag = parts[0] is "有" or "是" or "Y" or "Yes";
  3240. string name = parts[1];
  3241. string rel = parts[2];
  3242. string stat = parts[3];
  3243. return (flag, name, rel, stat);
  3244. }
  3245. /// <summary>
  3246. /// 服役时间处理
  3247. /// </summary>
  3248. /// <param name="raw"></param>
  3249. /// <returns></returns>
  3250. public static (bool hasService, string branch, string rank, string specialty, (DateTime? start, DateTime? end) period) MilitaryParser(string? raw)
  3251. {
  3252. const string fmt = "yyyy年MM月dd日";
  3253. if (string.IsNullOrWhiteSpace(raw))
  3254. return (false, "", "", "", (null, null));
  3255. var parts = raw.Split((char[]?)null, StringSplitOptions.RemoveEmptyEntries);
  3256. if (parts.Length < 5) return (false, "", "", "", (null, null));
  3257. bool has = parts[0] is "是" or "Y" or "Yes";
  3258. string branch = parts[1];
  3259. string rank = parts[2];
  3260. string specialty = parts[3];
  3261. // 拼回时间字符串
  3262. string periodRaw = string.Join(" ", parts[4..]);
  3263. var span = periodRaw.AsSpan();
  3264. int zhi = span.IndexOf("至");
  3265. if (zhi < 0) return (has, branch, rank, specialty, (null, null));
  3266. var startStr = span.Slice(0, zhi).Trim();
  3267. var endStr = span.Slice(zhi + 1).Trim();
  3268. bool okStart = DateTime.TryParseExact(startStr.ToString(), fmt, null, DateTimeStyles.None, out var start);
  3269. bool okEnd = DateTime.TryParseExact(endStr.ToString(), fmt, null, DateTimeStyles.None, out var end);
  3270. return (has, branch, rank, specialty, (okStart ? start : null, okEnd ? end : null));
  3271. }
  3272. /// <summary>
  3273. /// 申请人父母信息
  3274. /// </summary>
  3275. /// <param name="raw"></param>
  3276. /// <returns></returns>
  3277. public static (string fatherName, DateTime? fatherDob, string motherName, DateTime? motherDob) ParentParser(string? raw)
  3278. {
  3279. const string fmt = "yyyy年MM月dd日";
  3280. if (string.IsNullOrWhiteSpace(raw)) return ("", null, "", null);
  3281. // 按空格切,去掉空元素
  3282. var parts = raw.Split((char[]?)null, StringSplitOptions.RemoveEmptyEntries);
  3283. if (parts.Length < 4) return ("", null, "", null);
  3284. // 父亲
  3285. string fName = parts[0];
  3286. DateTime.TryParseExact(parts[1], fmt, null, DateTimeStyles.None, out var fDob);
  3287. // 母亲
  3288. string mName = parts[2];
  3289. DateTime.TryParseExact(parts[3], fmt, null, DateTimeStyles.None, out var mDob);
  3290. return (fName, fDob, mName, mDob);
  3291. }
  3292. public class VisaDetailsView
  3293. {
  3294. /// <summary>
  3295. /// 客户资料表
  3296. /// </summary>
  3297. public Crm_DeleClient ClientInfo { get; set; }
  3298. /// <summary>
  3299. /// 客户家庭表
  3300. /// </summary>
  3301. public List<Crm_VisaCustomerFamily> ClientFamilys { get; set; }
  3302. /// <summary>
  3303. /// 客户公司表
  3304. /// </summary>
  3305. public Crm_CustomerCompany ClientCompany { get; set; }
  3306. /// <summary>
  3307. /// 客户证件表
  3308. /// </summary>
  3309. public List<Crm_CustomerCert> ClientCerts { get; set; }
  3310. /// <summary>
  3311. /// 客户学历表
  3312. /// </summary>
  3313. public List<Crm_VisaCustomerSchool> ClientSchools { get; set; }
  3314. }
  3315. private int GetSuccessCount(List<FileUploadResult> results)
  3316. {
  3317. var count = 0;
  3318. foreach (var result in results)
  3319. {
  3320. if (result.Success) count++;
  3321. }
  3322. return count;
  3323. }
  3324. #endregion
  3325. /// <summary>
  3326. /// 根据团组Id获取签证客户信息List
  3327. /// </summary>
  3328. /// <param name="dto">请求dto</param>
  3329. /// <returns></returns>
  3330. [HttpPost]
  3331. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3332. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  3333. {
  3334. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  3335. if (groupData.Code != 0)
  3336. {
  3337. return Ok(JsonView(false, groupData.Msg));
  3338. }
  3339. return Ok(JsonView(groupData.Data));
  3340. }
  3341. /// <summary>
  3342. /// IOS获取团组签证拍照上传进度01(团组列表)
  3343. /// </summary>
  3344. /// <param name="dto">请求dto</param>
  3345. /// <returns></returns>
  3346. [HttpPost]
  3347. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3348. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  3349. {
  3350. if (dto == null)
  3351. {
  3352. return Ok(JsonView(false, "参数为空"));
  3353. }
  3354. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  3355. return Ok(JsonView(visaList));
  3356. }
  3357. /// <summary>
  3358. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  3359. /// </summary>
  3360. /// <returns></returns>
  3361. [HttpPost]
  3362. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3363. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  3364. {
  3365. if (dto == null)
  3366. {
  3367. return Ok(JsonView(false, "请求错误:"));
  3368. }
  3369. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  3370. return Ok(JsonView(list));
  3371. }
  3372. /// <summary>
  3373. /// IOS获取团组签证拍照上传进度03(相册)
  3374. /// </summary>
  3375. /// <returns></returns>
  3376. [HttpPost]
  3377. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3378. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  3379. {
  3380. if (dto == null)
  3381. {
  3382. return Ok(JsonView(false, "请求错误:"));
  3383. }
  3384. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  3385. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  3386. list.ForEach(s => s.url = url);
  3387. return Ok(JsonView(list));
  3388. }
  3389. /// <summary>
  3390. /// IOS获取团组签证拍照上传进度04(图片上传)
  3391. /// </summary>
  3392. /// <param name="dto"></param>
  3393. /// <returns></returns>
  3394. [HttpPost]
  3395. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3396. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  3397. {
  3398. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  3399. //if (!string.IsNullOrEmpty(result))
  3400. //{
  3401. //}
  3402. //else {
  3403. // return Ok(JsonView(false, "上传失败"));
  3404. //}
  3405. var dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  3406. int sucNum = 0;
  3407. try
  3408. {
  3409. foreach (var item in dto.base64DataList)
  3410. {
  3411. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  3412. string result = DecodeBase64ToImage(item, imageName);
  3413. if (!string.IsNullOrEmpty(result))
  3414. {
  3415. var pic = new Grp_VisaProgressCustomerPicture
  3416. {
  3417. CreateUserId = dto.CreateUserId,
  3418. PicName = imageName,
  3419. PicPath = result,
  3420. VisaProgressCustomerId = dto.visaProgressCustomerId
  3421. };
  3422. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  3423. if (insertResult > 0)
  3424. {
  3425. sucNum++;
  3426. }
  3427. }
  3428. }
  3429. }
  3430. catch (Exception ex)
  3431. {
  3432. return Ok(JsonView(false, ex.Message));
  3433. }
  3434. string msg = string.Format(@"成功上传{0}张", sucNum);
  3435. return Ok(JsonView(true, msg));
  3436. }
  3437. private string DecodeBase64ToImage(string base64DataURL, string imgName)
  3438. {
  3439. string filename = "";//声明一个string类型的相对路径
  3440. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  3441. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  3442. try//会有异常抛出,try,catch一下
  3443. {
  3444. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  3445. var ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  3446. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  3447. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  3448. //文件名称
  3449. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  3450. //上传的文件的路径
  3451. string filePath = "";
  3452. if (!Directory.Exists(fileDir))
  3453. {
  3454. Directory.CreateDirectory(fileDir);
  3455. }
  3456. //上传的文件的路径
  3457. filePath = fileDir + filename;
  3458. //string url = HttpRuntime.AppDomainAppPath.ToString();
  3459. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  3460. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  3461. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  3462. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  3463. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  3464. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  3465. ms.Close();//关闭当前流,并释放所有与之关联的资源
  3466. bitmap.Dispose();
  3467. }
  3468. catch (Exception e)
  3469. {
  3470. string massage = e.Message;
  3471. Logs("IOS图片上传Error:" + massage);
  3472. //filename = e.Message;
  3473. }
  3474. return filename;//返回相对路径
  3475. }
  3476. /// <summary>
  3477. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  3478. /// </summary>
  3479. /// <param name="dto"></param>
  3480. /// <returns></returns>
  3481. [HttpPost]
  3482. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3483. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  3484. {
  3485. if (dto == null)
  3486. {
  3487. return Ok(JsonView(false, "请求错误:"));
  3488. }
  3489. string msg = "参数错误";
  3490. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  3491. {
  3492. try
  3493. {
  3494. //_delegationVisaRep.BeginTran();
  3495. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  3496. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  3497. .Where(s => s.Id == dto.visaProgressCustomerId)
  3498. .ExecuteCommandAsync();
  3499. if (updCount > 0 && dto.publishCode == 1)
  3500. {
  3501. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  3502. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  3503. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  3504. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  3505. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  3506. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  3507. if (groupData == null)
  3508. {
  3509. _delegationVisaRep.RollbackTran();
  3510. }
  3511. string title = string.Format(@"[签证进度更新]");
  3512. string content = string.Format(@"测试文本");
  3513. bool rst = await _message.AddMsg(new MessageDto()
  3514. {
  3515. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  3516. IssuerId = dto.publisher,
  3517. Title = title,
  3518. Content = content,
  3519. ReleaseTime = DateTime.Now,
  3520. UIdList = new List<int> {
  3521. 234
  3522. }
  3523. });
  3524. if (rst)
  3525. {
  3526. return Ok(JsonView(true, "发送通知成功"));
  3527. }
  3528. }
  3529. //_delegationVisaRep.CommitTran();
  3530. }
  3531. catch (Exception)
  3532. {
  3533. //_delegationVisaRep.RollbackTran();
  3534. }
  3535. }
  3536. return Ok(JsonView(true, msg));
  3537. }
  3538. #endregion
  3539. #endregion
  3540. #region 团组任务分配
  3541. /// <summary>
  3542. /// 团组任务分配初始化
  3543. /// </summary>
  3544. /// <returns></returns>
  3545. [HttpPost]
  3546. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3547. public async Task<IActionResult> GetTaskAssignmen()
  3548. {
  3549. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  3550. if (groupData.Code != 0)
  3551. {
  3552. return Ok(JsonView(false, groupData.Msg));
  3553. }
  3554. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3555. }
  3556. /// <summary>
  3557. /// 团组任务分配查询
  3558. /// </summary>
  3559. /// <param name="dto"></param>
  3560. /// <returns></returns>
  3561. [HttpPost]
  3562. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3563. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  3564. {
  3565. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  3566. if (groupData.Code != 0)
  3567. {
  3568. return Ok(JsonView(false, groupData.Msg));
  3569. }
  3570. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3571. }
  3572. /// <summary>
  3573. /// 团组任务分配操作
  3574. /// </summary>
  3575. /// <param name="dto"></param>
  3576. /// <returns></returns>
  3577. [HttpPost]
  3578. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3579. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  3580. {
  3581. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  3582. if (groupData.Code != 0)
  3583. {
  3584. return Ok(JsonView(false, groupData.Msg));
  3585. }
  3586. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3587. }
  3588. /// <summary>
  3589. /// 团组任务分配
  3590. /// 批量分配
  3591. /// 查询团组
  3592. /// </summary>
  3593. /// <param name="dto"></param>
  3594. /// <returns></returns>
  3595. [HttpPost]
  3596. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3597. public async Task<IActionResult> TaskAllocationGroupSelect(TaskAllocationGroupSelectDto dto)
  3598. {
  3599. //参数验证
  3600. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  3601. if (!DateTime.TryParse(dto.VisitBeginDt, out _) || !DateTime.TryParse(dto.VisitEndDt, out _))
  3602. return Ok(JsonView(false, "团组出访开始/结束日期格式不正确!"));
  3603. return Ok(await _taskAssignmentRep.TaskAllocationGroupSelect(dto));
  3604. }
  3605. /// <summary>
  3606. /// 团组任务分配
  3607. /// 批量分配
  3608. /// </summary>
  3609. /// <param name="dto"></param>
  3610. /// <returns></returns>
  3611. [HttpPost]
  3612. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3613. public async Task<IActionResult> TaskAllocationBulkAdd(TaskAllocationBulkAddDto dto)
  3614. {
  3615. //参数验证
  3616. if (dto.UserIds.Length < 1) return Ok(JsonView(false, $"请选择分配人员!"));
  3617. if (dto.PermissionTypeIds.Length < 1) return Ok(JsonView(false, $"请选择分配类型!"));
  3618. if (dto.GroupIds.Length < 1) return Ok(JsonView(false, "请选择分配团组Id"));
  3619. if (dto.CurrUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId数组参数"));
  3620. return Ok(await _taskAssignmentRep.TaskAllocationBulkAdd(dto));
  3621. }
  3622. #endregion
  3623. #region 团组费用审核
  3624. /// <summary>
  3625. /// 费用审核
  3626. /// 团组列表 Page
  3627. /// </summary>
  3628. /// <param name="_dto">团组列表请求dto</param>
  3629. /// <returns></returns>
  3630. [HttpPost]
  3631. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3632. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  3633. {
  3634. #region 参数验证
  3635. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  3636. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  3637. #region 页面操作权限验证
  3638. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  3639. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  3640. #endregion
  3641. #endregion
  3642. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  3643. {
  3644. string sqlWhere = string.Empty;
  3645. if (_dto.IsSure == 0) //未完成
  3646. {
  3647. sqlWhere += string.Format(@" And IsSure = 0");
  3648. }
  3649. else if (_dto.IsSure == 1) //已完成
  3650. {
  3651. sqlWhere += string.Format(@" And IsSure = 1");
  3652. }
  3653. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  3654. {
  3655. string tj = _dto.SearchCriteria;
  3656. 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}%')",
  3657. tj, tj, tj, tj, tj);
  3658. }
  3659. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  3660. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  3661. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  3662. From (
  3663. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  3664. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  3665. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  3666. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  3667. From Grp_DelegationInfo gdi
  3668. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  3669. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  3670. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  3671. Where gdi.IsDel = 0 {0}
  3672. ) temp ", sqlWhere);
  3673. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  3674. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  3675. var _view = new
  3676. {
  3677. PageFuncAuth = pageFunAuthView,
  3678. Data = _DelegationList
  3679. };
  3680. return Ok(JsonView(true, "查询成功!", _view, total));
  3681. }
  3682. else
  3683. {
  3684. return Ok(JsonView(false, "查询失败"));
  3685. }
  3686. }
  3687. /// <summary>
  3688. /// 获取团组费用审核
  3689. /// </summary>
  3690. /// <param name="_dto"></param>
  3691. /// <returns></returns>
  3692. [HttpPost]
  3693. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3694. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  3695. {
  3696. try
  3697. {
  3698. #region 参数验证
  3699. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  3700. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  3701. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  3702. #region 页面操作权限验证
  3703. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  3704. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  3705. #endregion
  3706. #endregion
  3707. var _view = new Grp_CreditCardPaymentView();
  3708. var clientNameList = GetSimplClientList(_dto.DiId);
  3709. #region 费用清单
  3710. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  3711. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  3712. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  3713. var entityList = _groupRepository.Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0).Where(exp.ToExpression()).ToList();
  3714. var detailList = new List<Grp_CreditCardPaymentDetailView>();
  3715. var ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  3716. /*
  3717. * 76://酒店预订
  3718. */
  3719. var _HotelReservations = await _groupRepository.Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3720. var _HotelReservationsContents = await _groupRepository.Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3721. /*
  3722. * 79://车/导游地接
  3723. */
  3724. var _CarTouristGuideGroundReservations = await _groupRepository.Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3725. var _CarTouristGuideGroundReservationsContent = await _groupRepository.Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3726. /*
  3727. * 80: //签证
  3728. */
  3729. var _VisaInfos = await _groupRepository.Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3730. /*
  3731. *81: //邀请/公务活动
  3732. */
  3733. var _InvitationOfficialActivities = await _groupRepository.Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3734. /*
  3735. * 82: //团组客户保险
  3736. */
  3737. var _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3738. /*
  3739. * Lable = 85 机票预订
  3740. */
  3741. var p_AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3742. /*
  3743. * 85 机票预定
  3744. */
  3745. var _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3746. /*
  3747. * 98 其他款项
  3748. */
  3749. var _DecreasePayments = await _groupRepository.Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3750. /*
  3751. * 285:收款退还
  3752. */
  3753. var _PaymentRefundAndOtherMoneys = await _groupRepository.Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3754. /*
  3755. * 1015: //超支费用
  3756. */
  3757. var _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3758. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  3759. /*
  3760. * 币种信息
  3761. */
  3762. var currencyItems = initDatas.Where(s => s.STid == 66).ToList();
  3763. /*
  3764. * 车/导游地接 费用类型
  3765. */
  3766. var carFeeTypeItems = initDatas.Where(s => s.STid == 17).ToList();
  3767. /*
  3768. * 车/导游地接 费用类型
  3769. */
  3770. var carFeeItems = initDatas.Where(s => s.STid == 83).ToList();
  3771. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  3772. /*
  3773. * 用户信息
  3774. */
  3775. var userItems = await _groupRepository._sqlSugar.Queryable<Sys_Users>().ToListAsync();
  3776. /*
  3777. * 费用模块
  3778. */
  3779. var sdPriceName = initDatas.Where(s => s.Id == _dto.Label).First();
  3780. string priceModule = string.Empty;
  3781. if (sdPriceName != null)
  3782. {
  3783. priceModule = sdPriceName.Name;
  3784. }
  3785. /*
  3786. * 成本信息
  3787. */
  3788. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  3789. decimal _groupRate = 0.0000M;
  3790. string _groupCurrencyCode = "-";
  3791. if (groupCost != null)
  3792. {
  3793. _groupRate = groupCost.Rate;
  3794. if (int.TryParse(groupCost.Currency, out int _currency))
  3795. {
  3796. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  3797. }
  3798. else _groupCurrencyCode = groupCost.Currency;
  3799. }
  3800. string costContentSql = $"Select * From Grp_GroupCost";
  3801. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  3802. //处理日期为空的天数
  3803. for (int i = 0; i < groupCostDetails.Count; i++)
  3804. if (i != 0)
  3805. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  3806. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  3807. /*
  3808. * 处理详情数据
  3809. */
  3810. foreach (var entity in entityList)
  3811. {
  3812. var _detail = new Grp_CreditCardPaymentDetailView
  3813. {
  3814. Id = entity.Id,
  3815. PriceName = priceModule,
  3816. PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-"
  3817. };
  3818. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  3819. else _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  3820. //处理金额
  3821. if (entity.CTable == 1015)
  3822. {
  3823. var czInfo = _GroupExtraCosts.Find(x => entity.CId == x.Id);
  3824. if (czInfo != null)
  3825. {
  3826. entity.PayMoney = czInfo.Price * czInfo.PriceCount;
  3827. entity.RMBPrice = czInfo.Price * czInfo.PriceCount * entity.DayRate;
  3828. }
  3829. }
  3830. /*
  3831. * 应付款金额
  3832. */
  3833. var sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  3834. string PaymentCurrency_WaitPay = "Unknown";
  3835. string hotelCurrncyCode = "Unknown";
  3836. string hotelCurrncyName = "Unknown";
  3837. if (sdPaymentCurrency_WaitPay != null)
  3838. {
  3839. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  3840. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  3841. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  3842. if (hotelCurrncyCode.Equals("CNY"))
  3843. {
  3844. entity.DayRate = 1.0000M;
  3845. }
  3846. }
  3847. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  3848. /*
  3849. * 此次付款金额
  3850. */
  3851. decimal CurrPayStr = 0.00M,
  3852. OriginalCurrPay = 0.00M;
  3853. if (entity.PayPercentage == 0)
  3854. {
  3855. if (entity.PayThenMoney != 0)
  3856. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  3857. }
  3858. else
  3859. {
  3860. if (entity.PayMoney != 0)
  3861. {
  3862. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  3863. }
  3864. }
  3865. //if (_dto.Label == 79)
  3866. //{
  3867. // string original = string.Empty;
  3868. // if (hotelCurrncyCode.Equals("CNY"))
  3869. // {
  3870. // OriginalCurrPay = CurrPayStr;
  3871. // _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  3872. // }
  3873. // else
  3874. // {
  3875. // OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  3876. // //760 EUR(7600.00 CNY)
  3877. // _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  3878. // }
  3879. //}
  3880. //else _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  3881. string original = string.Empty;
  3882. if (hotelCurrncyCode.Equals("CNY"))
  3883. {
  3884. OriginalCurrPay = CurrPayStr;
  3885. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  3886. }
  3887. else
  3888. {
  3889. OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  3890. //760 EUR(7600.00 CNY)
  3891. _detail.CurrPay = $"{OriginalCurrPay:#0.00} {hotelCurrncyCode}({CurrPayStr:#0.00} CNY)";
  3892. }
  3893. /*
  3894. * 剩余尾款
  3895. */
  3896. decimal BalanceStr = 0;
  3897. if (CurrPayStr != 0)
  3898. {
  3899. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  3900. BalanceStr = 0;
  3901. else
  3902. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  3903. }
  3904. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  3905. /*
  3906. * Bus名称
  3907. */
  3908. _detail.BusName = "待增加";
  3909. /*
  3910. *费用所属
  3911. */
  3912. switch (entity.CTable)
  3913. {
  3914. case 76://酒店预订
  3915. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  3916. if (hotelReservations != null)
  3917. {
  3918. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  3919. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  3920. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  3921. string roomFeeStr = "", roomFeestr1 = "";
  3922. //是否比较房型价格
  3923. //bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  3924. //roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  3925. roomFeeStr += $"<br/>";
  3926. var roomTotal = 0.00M;
  3927. if (hotelReservations.SingleRoomPrice > 0)
  3928. {
  3929. var fee = hotelReservations.SingleRoomPrice * hotelReservations.SingleRoomCount * hotel_days;
  3930. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice:#0.00} * {hotelReservations.SingleRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  3931. //__isSingle = true;
  3932. roomTotal += fee;
  3933. }
  3934. if (hotelReservations.DoubleRoomPrice > 0)
  3935. {
  3936. var fee = hotelReservations.DoubleRoomPrice * hotelReservations.DoubleRoomCount * hotel_days;
  3937. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice:#0.00} * {hotelReservations.DoubleRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  3938. // __isDouble = true;
  3939. roomTotal += fee;
  3940. }
  3941. if (hotelReservations.SuiteRoomPrice > 0)
  3942. {
  3943. var fee = hotelReservations.SuiteRoomPrice * hotelReservations.SuiteRoomCount * hotel_days;
  3944. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice:#0.00} * {hotelReservations.SuiteRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  3945. //__isSuite = true;
  3946. roomTotal += fee;
  3947. }
  3948. if (hotelReservations.OtherRoomPrice > 0)
  3949. {
  3950. var fee = hotelReservations.OtherRoomPrice * hotelReservations.OtherRoomCount * hotel_days;
  3951. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice:#0.00} * {hotelReservations.OtherRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  3952. //__isOther = true;
  3953. roomTotal += fee;
  3954. }
  3955. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1 + $"<span style='width:70px;display: inline-block;'></span>房费总金额:{roomTotal:#0.00}";
  3956. else roomFeeStr += " 0.00 * 0";
  3957. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  3958. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  3959. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  3960. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  3961. /*
  3962. * 费用类型
  3963. * 1:房费
  3964. * 2:早餐
  3965. * 3:地税
  3966. * 4:城市税
  3967. * </summary>
  3968. */
  3969. //地税
  3970. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  3971. if (governmentRentData != null)
  3972. {
  3973. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  3974. governmentRentFee = governmentRentData.Price;
  3975. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  3976. if (governmentRentCurrData != null)
  3977. {
  3978. governmentRentCode = governmentRentCurrData.Name;
  3979. governmentRentName = $"({governmentRentCurrData.Remark})";
  3980. }
  3981. }
  3982. //城市税
  3983. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  3984. if (cityTaxData != null)
  3985. {
  3986. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  3987. cityTaxFee = cityTaxData.Price;
  3988. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  3989. if (cityTaxCurrData != null)
  3990. {
  3991. cityTaxCode = cityTaxCurrData.Name;
  3992. cityTaxName = $"({cityTaxCurrData.Remark})";
  3993. }
  3994. }
  3995. //酒店早餐
  3996. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  3997. if (breakfastData != null)
  3998. {
  3999. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  4000. breakfastFee = breakfastData.Price;
  4001. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  4002. if (breakfastCurrData != null)
  4003. {
  4004. breakfastCode = breakfastCurrData.Name;
  4005. breakfastName = $"({breakfastCurrData.Remark})";
  4006. }
  4007. }
  4008. //房间费用
  4009. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  4010. if (roomData != null)
  4011. {
  4012. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  4013. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  4014. else _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  4015. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  4016. roomFee = roomData.Price;
  4017. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  4018. if (roomCurrData != null)
  4019. {
  4020. roomCode = roomCurrData.Name;
  4021. roomName = $"({roomCurrData.Remark})";
  4022. }
  4023. }
  4024. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  4025. string hotelCostStr = "";
  4026. decimal hotelCsotTotal = 0.00M;
  4027. if (groupCost != null)
  4028. {
  4029. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  4030. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate:#0.0000})<br/>";
  4031. }
  4032. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  4033. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  4034. string hotelCost_day = "";
  4035. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  4036. foreach (var item in hotelCostDetails1)
  4037. {
  4038. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  4039. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  4040. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee):#0.00}";
  4041. //else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  4042. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee):#0.00}";
  4043. //else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  4044. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee):#0.00}";
  4045. //else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  4046. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee):#0.00}";
  4047. //else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  4048. hotelCost_day += @$"<br/>";
  4049. }
  4050. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  4051. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee:#0.00} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate:#0.0000} <br/>是否由地接或其他人代付:{breakfastBool}<br/><br/>";
  4052. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee:#0.00} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate:#0.0000} <br/>是否由地接或其他人代付:{governmentRentBool}<br/><br/>";
  4053. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee:#0.00} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate:#0.0000)} <br/>是否由地接或其他人代付:{cityTaxBool}<br/>";
  4054. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  4055. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  4056. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  4057. $"酒店费用总额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  4058. $"房间说明: {hotelReservations.Remark} <br/>" +
  4059. $"房间费用: {roomCode} {roomName} 当时汇率:{roomData?.Rate.ToString("#0.0000")}{roomFeeStr} <br/>是否由地接或其他人代付:{roomBool}<br/><br/>" +
  4060. $"{hotelBreakfastStr}" +
  4061. $"{hotelGovernmentRentStr}" +
  4062. $"{hotelCityTaxStr}";
  4063. _detail.PriceNameContent = hotelReservations.HotelName;
  4064. }
  4065. break;
  4066. case 79://车/导游地接
  4067. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  4068. if (touristGuideGroundReservations != null)
  4069. {
  4070. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  4071. {
  4072. _detail.BusName = touristGuideGroundReservations.BusName;
  4073. }
  4074. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  4075. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  4076. //if (isInt)
  4077. //{
  4078. // var cityInfo = cityData.Find(it => it.Id == cityId);
  4079. // if (cityInfo != null)
  4080. // {
  4081. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  4082. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  4083. // if (carFeeItem != null)
  4084. // {
  4085. // nameContent += $@"({carFeeItem.Name})";
  4086. // }
  4087. // _detail.PriceNameContent = nameContent;
  4088. // }
  4089. //}
  4090. //else
  4091. //{
  4092. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  4093. //}
  4094. var touristGuideGroundReservationsContents =
  4095. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  4096. var opContent_sb = new StringBuilder();
  4097. string contetTitle = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  4098. opContent_sb.AppendLine(contetTitle);
  4099. foreach (var item in touristGuideGroundReservationsContents)
  4100. {
  4101. string typeName = "Unknown";
  4102. string carCurrencyCode = "Unknown";
  4103. string carCurrencyName = "Unknown";
  4104. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  4105. if (carTypeData != null) typeName = carTypeData.Name;
  4106. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  4107. if (currencyData != null)
  4108. {
  4109. carCurrencyCode = currencyData.Name;
  4110. carCurrencyName = currencyData.Remark;
  4111. }
  4112. //op、成本 币种是否一致 (币种一致只比较金额:2025-04-18)
  4113. bool IsCurrencyAgreement = false;
  4114. if (carCurrencyCode.Equals(_groupCurrencyCode)) IsCurrencyAgreement = true;
  4115. string opCostStr = string.Empty;
  4116. decimal opCostTypePrice = 0.00M;
  4117. #region 处理成本各项费用
  4118. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  4119. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  4120. decimal aduitOPFeeCNY = 0.00M, //费用审核 op费用
  4121. costOPFeeCNY = 0.00M, //团组成本 op费用
  4122. opPayPercentage = entity.PayPercentage == 0.00M ? 1.00M : entity.PayPercentage / 100M; //费用审核 op付款百分比
  4123. if (opCost.Count > 0)
  4124. {
  4125. switch (item.SId)
  4126. {
  4127. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  4128. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  4129. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  4130. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  4131. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  4132. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  4133. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  4134. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  4135. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  4136. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  4137. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  4138. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  4139. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  4140. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  4141. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  4142. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  4143. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  4144. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  4145. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  4146. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  4147. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  4148. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  4149. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  4150. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  4151. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  4152. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  4153. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  4154. }
  4155. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice:#0.00} {_groupCurrencyCode}(汇率:{_groupRate:#0.0000})";
  4156. costOPFeeCNY = opCostTypePrice * _groupRate;
  4157. if (!IsCurrencyAgreement) opCostStr += $" ≈ {costOPFeeCNY:#0.00} CNY";
  4158. }
  4159. #endregion
  4160. string opTypeStr = $"{typeName}:{item.Price:#0.00} {carCurrencyCode}(汇率:{entity.DayRate:#0.0000})";
  4161. aduitOPFeeCNY = item.Price * entity.DayRate;
  4162. if (!IsCurrencyAgreement) opTypeStr += $" ≈ {aduitOPFeeCNY:#0.0000} CNY";
  4163. var opContent = $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  4164. $"{opTypeStr} {opCostStr}<br/>" +
  4165. $"明细:{item.PriceContent ?? "-"}<br/>" +
  4166. $"备注:{item.Remark ?? "-"}<br/><br/>";
  4167. if (entity.IsAuditGM != 3) //状态 != 自动审核
  4168. {
  4169. if (IsCurrencyAgreement)
  4170. {
  4171. if (item.Price > opCostTypePrice)
  4172. {
  4173. opContent_sb.Append("<span style='color:red;'>");
  4174. opContent_sb.Append(opContent);
  4175. opContent_sb.Append("</span>");
  4176. opContent_sb.AppendLine();
  4177. }
  4178. else
  4179. {
  4180. opContent_sb.Append(opContent);
  4181. opContent_sb.AppendLine();
  4182. }
  4183. }
  4184. else
  4185. {
  4186. //验证是否超成本 按付款比例计算
  4187. if (aduitOPFeeCNY * opPayPercentage > costOPFeeCNY * opPayPercentage)
  4188. {
  4189. opContent_sb.Append("<span style='color:red;'>");
  4190. opContent_sb.Append(opContent);
  4191. opContent_sb.Append("</span>");
  4192. opContent_sb.AppendLine();
  4193. }
  4194. else
  4195. {
  4196. opContent_sb.Append(opContent);
  4197. opContent_sb.AppendLine();
  4198. }
  4199. }
  4200. }
  4201. else
  4202. {
  4203. opContent_sb.Append(opContent);
  4204. opContent_sb.AppendLine();
  4205. }
  4206. }
  4207. _detail.PriceMsgContent = opContent_sb.ToString();
  4208. }
  4209. break;
  4210. case 80: //签证
  4211. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  4212. if (visaInfo != null)
  4213. {
  4214. string visaName = GetClientNameStr1(clientNameList, visaInfo.VisaClient);
  4215. _detail.PriceNameContent = visaInfo.VisaDescription;
  4216. _detail.PriceMsgContent = $"签证描述:{visaName}<br/> 备注:{visaInfo.Remark}";
  4217. }
  4218. break;
  4219. case 81: //邀请/公务活动
  4220. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  4221. if (_ioa != null)
  4222. {
  4223. string inviteCurrName = "Unknown", //邀请费用币种 Name
  4224. inviteCurrCode = "Unknown", //邀请费用币种 Code
  4225. sendCurrName = "Unknown", //快递费用币种 Name
  4226. sendCurrCode = "Unknown", //快递费用币种 Code
  4227. eventsCurrName = "Unknown", //公务活动费币种 Name
  4228. eventsCurrCode = "Unknown", //公务活动费币种 Code
  4229. translateCurrName = "Unknown", //公务翻译费 Name
  4230. translateCurrCode = "Unknown"; //公务翻译费 Code
  4231. #region 处理费用币种
  4232. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  4233. if (inviteCurrData != null)
  4234. {
  4235. inviteCurrName = inviteCurrData.Remark;
  4236. inviteCurrCode = inviteCurrData.Name;
  4237. }
  4238. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  4239. if (sendCurrData != null)
  4240. {
  4241. sendCurrName = sendCurrData.Remark;
  4242. sendCurrCode = sendCurrData.Name;
  4243. }
  4244. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  4245. if (eventsCurrData != null)
  4246. {
  4247. eventsCurrName = eventsCurrData.Remark;
  4248. eventsCurrCode = eventsCurrData.Name;
  4249. }
  4250. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  4251. if (translateCurrData != null)
  4252. {
  4253. translateCurrName = translateCurrData.Remark;
  4254. translateCurrCode = translateCurrData.Name;
  4255. }
  4256. #endregion
  4257. _detail.PriceNameContent = _ioa.InviterArea;
  4258. //2025-09-08 商邀费用名称更改:单项费用不等于0,则在名称后面最加费用类型名称。
  4259. List<string> priceExpNames = new List<string>();
  4260. if (_ioa.InviteCost != 0.00M) priceExpNames.Add("邀请费");
  4261. if (_ioa.SendCost != 0.00M) priceExpNames.Add("快递费");
  4262. if (_ioa.EventsCost != 0.00M) priceExpNames.Add("公务活动费");
  4263. if (_ioa.TranslateCost != 0.00M) priceExpNames.Add("公务翻译费");
  4264. if (priceExpNames != null && priceExpNames.Count > 0)
  4265. {
  4266. _detail.PriceNameContent += $"({string.Join("+", priceExpNames)})";
  4267. }
  4268. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost:#0.00} {inviteCurrCode}({inviteCurrName})<br/>" +
  4269. $@"快递费用:{_ioa.SendCost:#0.00} {sendCurrCode}({sendCurrName})<br/>" +
  4270. $@"公务活动费:{_ioa.EventsCost:#0.00} {eventsCurrCode}({eventsCurrName})<br/>" +
  4271. $@"公务翻译费:{_ioa.TranslateCost:#0.00} {translateCurrCode}({translateCurrName})<br/>" +
  4272. $@"备注:" + _ioa.Remark + "<br/>";
  4273. }
  4274. break;
  4275. case 82: //团组客户保险
  4276. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  4277. if (customers != null)
  4278. {
  4279. _detail.PriceNameContent = GetClientNameStr(clientNameList, customers.ClientName);
  4280. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  4281. }
  4282. break;
  4283. case 85: //机票预订
  4284. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  4285. if (jpRes != null)
  4286. {
  4287. string FlightsDescription = jpRes.FlightsDescription;
  4288. string PriceDescription = jpRes.PriceDescription;
  4289. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  4290. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  4291. }
  4292. break;
  4293. case 98://其他款项
  4294. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  4295. if (gdpRes != null)
  4296. {
  4297. //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/";
  4298. //if (!string.IsNullOrEmpty(gdpRes.FilePath))
  4299. //{
  4300. // _detail.FileUrl = $"{urlBase}{gdpRes.FilePath}";
  4301. //}
  4302. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  4303. _detail.PriceNameContent = gdpRes.PriceName;
  4304. }
  4305. break;
  4306. case 285://收款退还
  4307. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  4308. if (refundAndOtherMoney != null)
  4309. {
  4310. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  4311. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  4312. }
  4313. break;
  4314. case 751://酒店早餐
  4315. break;
  4316. case 1015://超支费用
  4317. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  4318. if (groupExtraCost != null)
  4319. {
  4320. _detail.PriceNameContent = groupExtraCost.PriceName;
  4321. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  4322. }
  4323. break;
  4324. default:
  4325. break;
  4326. }
  4327. /*
  4328. * 申请人
  4329. */
  4330. string operatorName = " - ";
  4331. var _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  4332. if (_opUser != null)
  4333. {
  4334. operatorName = _opUser.CnName;
  4335. }
  4336. _detail.OperatorName = operatorName;
  4337. /*
  4338. * 审核人
  4339. */
  4340. string auditOperatorName = " - ";
  4341. if (entity.IsAuditGM != 0)
  4342. {
  4343. if (entity.AuditGMOperate == 0) auditOperatorName = " - ";
  4344. else if (entity.AuditGMOperate == 4) auditOperatorName = "自动审核";
  4345. else
  4346. {
  4347. var _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  4348. if (_adUser != null)
  4349. {
  4350. auditOperatorName = _adUser.CnName;
  4351. }
  4352. }
  4353. }
  4354. _detail.AuditOperatorName = auditOperatorName;
  4355. /*
  4356. * 超预算比例
  4357. */
  4358. string overBudgetStr = "";
  4359. if (entity.ExceedBudget == -1) overBudgetStr = sdPriceName.Name + "尚无预算";
  4360. else if (entity.ExceedBudget == 0)
  4361. {
  4362. if (entity.CTable == 76 || entity.CTable == 79)
  4363. {
  4364. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  4365. else overBudgetStr = _feeAuditRep.IsOverBudget(entity.CTable, entity.DIId, entity.CId);
  4366. }
  4367. else
  4368. {
  4369. overBudgetStr = "未超预算";
  4370. }
  4371. }
  4372. else overBudgetStr = entity.ExceedBudget.ToString("P");
  4373. _detail.OverBudget = overBudgetStr;
  4374. decimal auditFee = 0.00M; //已审核金额 人名币
  4375. decimal auditedFeeOriginal = 0.00M; ////已审核金额 原始
  4376. decimal unAuditFeeCNY = 0.00M; //未审核款项 原始
  4377. decimal unAuditFeeOriginal = 0.00M; //未审核款项 人名币
  4378. if (entity.IsAuditGM == 1 || entity.IsAuditGM == 3)
  4379. {
  4380. auditedFeeOriginal = entity.PayMoney;
  4381. auditFee = CurrPayStr;
  4382. }
  4383. else if (entity.IsAuditGM == 0)
  4384. {
  4385. unAuditFeeCNY = CurrPayStr;
  4386. unAuditFeeOriginal = OriginalCurrPay;
  4387. OriginalCurrPay = 0.00M;
  4388. }
  4389. /*
  4390. * 费用总计
  4391. */
  4392. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  4393. {
  4394. CurrencyId = entity.PaymentCurrency,
  4395. CurrencyName = PaymentCurrency_WaitPay,
  4396. AmountPayable = entity.PayMoney,
  4397. ThisPayment = OriginalCurrPay,
  4398. BalancePayment = BalanceStr,
  4399. AuditedFunds = auditFee,
  4400. AuditedFundsOriginal = auditedFeeOriginal,
  4401. UnAuditFundsCNY = unAuditFeeCNY,
  4402. UnAuditFundsOriginal = unAuditFeeOriginal
  4403. });
  4404. _detail.IsAuditGM = entity.IsAuditGM;
  4405. detailList.Add(_detail);
  4406. }
  4407. #endregion
  4408. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  4409. /*
  4410. * 下方描述处理
  4411. */
  4412. var nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  4413. var ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  4414. if (ccpCurrencyPrice != null)
  4415. {
  4416. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  4417. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  4418. }
  4419. else
  4420. {
  4421. nonDuplicat = nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  4422. }
  4423. string amountPayableStr = string.Format(@"应付款总金额: ");
  4424. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  4425. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  4426. string auditedFundsStr = string.Format(@"已审费用总额: ");
  4427. string unAuditedFundsStr = string.Format(@"未审费用总额: ");
  4428. foreach (var item in nonDuplicat)
  4429. {
  4430. var currencyName = item.CurrencyName;
  4431. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  4432. if (strs.Count > 0)
  4433. {
  4434. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  4435. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  4436. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  4437. amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), currencyName);
  4438. //单独处理此次付款金额
  4439. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  4440. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), currencyName);
  4441. //单独处理已审核费用
  4442. //if (item.CurrencyId == 836) //人民币
  4443. //{
  4444. // decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  4445. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), currencyName);
  4446. //}
  4447. //else
  4448. //{
  4449. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.AmountPayable), currencyName);
  4450. //}
  4451. if (currencyName.Equals("CNY"))
  4452. {
  4453. //已审核费用
  4454. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  4455. //未审核费用
  4456. unAuditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.UnAuditFundsOriginal).ToString("#0.00"), currencyName);
  4457. }
  4458. else
  4459. {
  4460. //已审核费用
  4461. 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"));
  4462. //未审核费用
  4463. 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"));
  4464. }
  4465. }
  4466. }
  4467. _view.TotalStr1 = amountPayableStr[..^1];
  4468. _view.TotalStr2 = thisPaymentStr[..^1];
  4469. _view.TotalStr3 = balancePaymentStr[..^1];
  4470. _view.TotalStr4 = $"{auditedFundsStr[..^1]}<br/>{unAuditedFundsStr[..^1]}";
  4471. //_view.TotalStr5 = unAuditedFundsStr.Substring(0, unAuditedFundsStr.Length - 1);
  4472. var _view1 = new
  4473. {
  4474. PageFuncAuth = pageFunAuthView,
  4475. Data = _view
  4476. };
  4477. return Ok(JsonView(_view1));
  4478. }
  4479. catch (Exception ex)
  4480. {
  4481. return Ok(JsonView(false, ex.Message));
  4482. }
  4483. }
  4484. /// <summary>
  4485. /// 费用审核
  4486. /// 修改团组费用审核状态
  4487. /// </summary>
  4488. /// <param name="_dto">参数Json字符串</param>
  4489. /// <returns></returns>
  4490. [HttpPost]
  4491. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4492. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  4493. {
  4494. #region 参数验证
  4495. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  4496. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  4497. #endregion
  4498. #region 页面操作权限验证
  4499. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  4500. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  4501. #endregion
  4502. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  4503. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  4504. DateTime dtNow = DateTime.Now;
  4505. _groupRepository.BeginTran();
  4506. int rst = 0;
  4507. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  4508. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  4509. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  4510. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  4511. var msgDatas = new List<dynamic>();
  4512. var dic_ccp_user = new Dictionary<int, int>() { };
  4513. foreach (var item in idList)
  4514. {
  4515. int CreditId = int.Parse(item);
  4516. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  4517. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  4518. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  4519. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  4520. .Where(s => s.Id == CreditId)
  4521. .ExecuteCommandAsync();
  4522. if (result < 1)
  4523. {
  4524. rst = -1;
  4525. _groupRepository.RollbackTran();
  4526. return Ok(JsonView(false, "操作失败并回滚!"));
  4527. }
  4528. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  4529. if (creditData != null)
  4530. {
  4531. #region 应用通知配置
  4532. try
  4533. {
  4534. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  4535. }
  4536. catch (Exception ex)
  4537. {
  4538. }
  4539. #endregion
  4540. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  4541. string groupNameStr = string.Empty;
  4542. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  4543. if (groupData != null) groupNameStr = groupData.TeamName;
  4544. string creditTypeStr = string.Empty;
  4545. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  4546. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  4547. string creditCurrency = string.Empty;
  4548. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  4549. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  4550. if (creditCurrency.Equals("CNY"))
  4551. {
  4552. creditData.DayRate = 1.0000M;
  4553. }
  4554. if (creditData.PayPercentage == 0.00M)
  4555. {
  4556. creditData.PayPercentage = 100M;
  4557. }
  4558. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  4559. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  4560. string msgContent = "";
  4561. if (creditCurrency.Equals("CNY"))
  4562. {
  4563. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice:0.00} CNY) {auditStr}!";
  4564. }
  4565. else
  4566. {
  4567. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice:0.00} CNY({creditData.PayMoney:0.00} {creditCurrency})) {auditStr}!";
  4568. }
  4569. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  4570. }
  4571. }
  4572. if (rst == 0)
  4573. {
  4574. _groupRepository.CommitTran();
  4575. foreach (var item in msgDatas)
  4576. {
  4577. //发送消息
  4578. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  4579. }
  4580. #region 应用推送
  4581. try
  4582. {
  4583. foreach (var ccpId in dic_ccp_user.Keys)
  4584. {
  4585. var templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  4586. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  4587. }
  4588. }
  4589. catch (Exception)
  4590. {
  4591. }
  4592. #endregion
  4593. return Ok(JsonView(true, "操作成功!"));
  4594. }
  4595. return Ok(JsonView(false, "操作失败!"));
  4596. }
  4597. /// <summary>
  4598. /// 费用审核
  4599. /// 其他款项 文件下载
  4600. /// </summary>
  4601. /// <param name="id">其他款项 主键编号</param>
  4602. /// <returns></returns>
  4603. [HttpGet("{id}")]
  4604. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4605. public async Task<IActionResult> FeeAuditOtherFileDownlaod([Range(1, int.MaxValue, ErrorMessage = "请传入有效的ID")] int id)
  4606. {
  4607. //网站域名
  4608. 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/";
  4609. var otherInfo = await _decreasePaymentsRep._sqlSugar
  4610. .Queryable<Grp_DecreasePayments>()
  4611. .InnerJoin<Grp_CreditCardPayment>((x, y) => x.Id == y.CId && y.Id == id)
  4612. .Where(((x, y) => x.IsDel == 0 && y.IsDel == 0))
  4613. .Select((x, y) => new
  4614. {
  4615. x.Id,
  4616. x.FilePath
  4617. })
  4618. .FirstAsync();
  4619. if (otherInfo != null && !string.IsNullOrEmpty(otherInfo.FilePath.Trim()))
  4620. {
  4621. var url = $"{baseUrl}{otherInfo.FilePath}";
  4622. return Ok(JsonView(true, "操作成功!", url));
  4623. }
  4624. return Ok(JsonView(false, "暂无附件"));
  4625. }
  4626. #endregion
  4627. #region 机票费用录入
  4628. /// <summary>
  4629. /// 机票录入当前登录人可操作团组
  4630. /// </summary>
  4631. /// <param name="dto"></param>
  4632. /// <returns></returns>
  4633. [HttpPost]
  4634. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4635. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  4636. {
  4637. try
  4638. {
  4639. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  4640. if (groupData.Code != 0)
  4641. {
  4642. return Ok(JsonView(false, groupData.Msg));
  4643. }
  4644. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4645. }
  4646. catch (Exception ex)
  4647. {
  4648. return Ok(JsonView(false, ex.Message));
  4649. }
  4650. }
  4651. /// <summary>
  4652. /// 机票费用录入列表
  4653. /// </summary>
  4654. /// <param name="dto"></param>
  4655. /// <returns></returns>
  4656. [HttpPost]
  4657. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4658. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  4659. {
  4660. try
  4661. {
  4662. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  4663. if (groupData.Code != 0)
  4664. {
  4665. return Ok(JsonView(false, groupData.Msg));
  4666. }
  4667. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4668. }
  4669. catch (Exception ex)
  4670. {
  4671. return Ok(JsonView(false, ex.Message));
  4672. throw;
  4673. }
  4674. }
  4675. /// <summary>
  4676. /// 根据id查询费用录入信息
  4677. /// </summary>
  4678. /// <param name="dto"></param>
  4679. /// <returns></returns>
  4680. [HttpPost]
  4681. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4682. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  4683. {
  4684. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  4685. if (groupData.Code != 0)
  4686. {
  4687. return Ok(JsonView(false, groupData.Msg));
  4688. }
  4689. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4690. }
  4691. /// <summary>
  4692. /// 机票费用录入操作(Status:1.新增,2.修改)
  4693. /// </summary>
  4694. /// <param name="dto"></param>
  4695. /// <returns></returns>
  4696. [HttpPost]
  4697. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4698. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  4699. {
  4700. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  4701. if (groupData.Code != 0)
  4702. {
  4703. return Ok(JsonView(false, groupData.Msg));
  4704. }
  4705. #region 应用推送
  4706. try
  4707. {
  4708. var diId = dto.AirTicketResOpData.DiId;
  4709. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  4710. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  4711. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  4712. //自动审核
  4713. //var autoAdit1 = await _feeAuditRep.FeeAutomaticAudit(5, diId, dataId); //机票费用合计方式
  4714. (bool status, string auditMsg) = await AirTicketResAutoAudit(diId, dataId); //KIMI-AI识别INIT方式
  4715. _logger.LogInformation("【机票费用自动审核(KIMI-AI识别INIT)】请求参数:{RequstData} 返回结果:是否执行:{IsExecute}; 结果消息:{ResponseMsg};",
  4716. $"GroupId:{diId};airId:{dataId};",
  4717. status,
  4718. auditMsg);
  4719. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  4720. //2024-10-21 新增LZ UID
  4721. var userIds = new List<int>() { 21 };
  4722. string title = $"系统通知";
  4723. string content = "";
  4724. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  4725. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  4726. if (dto.Status == 1) content = $"[新增-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4727. else if (dto.Status == 2) content = $"[更新-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4728. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  4729. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "85" };
  4730. await APNsTools.iOS_PushNotifications1("051", $"机票费用审核", "", content, true, "ExpenseAuditWebView", h5);
  4731. }
  4732. catch (Exception ex)
  4733. {
  4734. }
  4735. #endregion
  4736. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4737. }
  4738. /// <summary>
  4739. /// 机票费用自动审核 AI识别方式
  4740. /// </summary>
  4741. /// <returns></returns>
  4742. private async Task<(bool, string)> AirTicketResAutoAudit(int diId, int dataId)
  4743. {
  4744. var ecoTypeIds = new List<int>() {
  4745. 459, //超经舱
  4746. 460, //经济舱
  4747. 1430, //公务舱(实际经济舱)
  4748. 1432, //头等舱(实际经济舱)
  4749. };
  4750. var bizTypeIds = new List<int>() {
  4751. 457, //头等舱
  4752. 458, //公务舱
  4753. 1431, //头等舱(实际公务舱)
  4754. };
  4755. var auditFeeTypeIds = new List<int>() { };
  4756. auditFeeTypeIds.AddRange(ecoTypeIds);
  4757. auditFeeTypeIds.AddRange(bizTypeIds);
  4758. int currModule = 85;
  4759. var airInfo = await _sqlSugar.Queryable<Grp_AirTicketReservations>()
  4760. .InnerJoin<Grp_CreditCardPayment>((x, y) => x.Id == y.CId && y.CTable == currModule && y.IsDel == 0)
  4761. .Where((x, y) => x.Id == dataId && x.IsDel == 0 && auditFeeTypeIds.Contains(x.CType))
  4762. .Select((x, y) => new
  4763. {
  4764. x.Id,
  4765. CcpId = y.Id,
  4766. x.FlightsDate,
  4767. x.PrePrice,
  4768. x.CType,
  4769. x.ClientNum,
  4770. x.DIId
  4771. })
  4772. .FirstAsync();
  4773. if (airInfo == null) return (false, "机票信息为空或费用类型不在自动审核范围内,不可自动审核!");
  4774. var groupDetails = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.IsDel == 0 && x.Id == diId);
  4775. if (groupDetails == null) return (false, "团组信息为空,不可自动审核!");
  4776. var groupCostInfo = await _sqlSugar.Queryable<Grp_GroupCostParameter>().FirstAsync(x => x.IsDel == 0 && x.DiId == diId);
  4777. if (groupCostInfo == null) return (false, "团组成本信息未填写!");
  4778. var groupCostContents = await _sqlSugar
  4779. .SqlQueryable<GroupCostAuditView>($"Select * From Grp_GroupCost")
  4780. .Where(x => x.IsDel == 0 && x.Diid == diId)
  4781. .ToListAsync();
  4782. if (groupCostContents.Count < 1) return (false, "团组成本信息未填写!");
  4783. //处理 成本详细信息日期为空 填装费用信息
  4784. var airFeeLabel = new StringBuilder();
  4785. airFeeLabel.AppendLine("费用成本:");
  4786. for (int i = 0; i < groupCostContents.Count; i++)
  4787. {
  4788. if (string.IsNullOrEmpty(groupCostContents[i].Date))
  4789. {
  4790. int index = i - 1;
  4791. if (index >= 0)
  4792. {
  4793. groupCostContents[i].Date = groupCostContents[index].Date;
  4794. var dtBool = DateTime.TryParse(groupCostContents[i].Date, out DateTime _dateTime);
  4795. if (dtBool) groupCostContents[i].CurrTime = _dateTime;
  4796. }
  4797. }
  4798. else
  4799. {
  4800. var dtBool = DateTime.TryParse(groupCostContents[i].Date, out DateTime _dateTime);
  4801. if (dtBool) groupCostContents[i].CurrTime = _dateTime;
  4802. }
  4803. var item = groupCostContents[i];
  4804. airFeeLabel.AppendLine($"{item.Date}");
  4805. airFeeLabel.AppendLine($"{item.ITIN.Replace("\n", " ")}");
  4806. }
  4807. airFeeLabel.AppendLine($"注:费用:位置:航班号或者航班时间后面; 组成:经济舱/公务舱;");
  4808. airFeeLabel.AppendLine($"取出“{airInfo.FlightsDate}”费用金额,按照经济舱/公务舱格式返回,如果不存在的话则返回0.00/0.00,只返回金额格式文本;不需要其他文字描述;");
  4809. //访问Kimi AI 返回价格结果
  4810. var msgs = new List<SeedMessages>()
  4811. {
  4812. new ()
  4813. {
  4814. Role = KimiRole.user,
  4815. Content = airFeeLabel.ToString()
  4816. }
  4817. };
  4818. var client = new KiMiApiClient();
  4819. var kimiApiResult = await client.SeedMessage(msgs);
  4820. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  4821. string clients = kimiApiResult_JObject["content"].ToString();
  4822. decimal ecoPri_kimiAI = 0.00M,
  4823. bizPri_kimiAI = 0.00M;
  4824. //单个价格: 经济舱价格
  4825. if (decimal.TryParse(clients, out ecoPri_kimiAI)) { }
  4826. //价格文本包含/:/前经济舱价格 /后公务舱价格
  4827. if (clients.Contains('/'))
  4828. {
  4829. var priArray = clients.Split('/');
  4830. decimal.TryParse(priArray[0], out ecoPri_kimiAI); //
  4831. decimal.TryParse(priArray[1], out bizPri_kimiAI); //经济舱价格
  4832. }
  4833. else return (false, "价格文本不存在价格或KIMI-AI未识别出价格,不可自动审核!");
  4834. var isAutoAudit = false;
  4835. //价格验证处理
  4836. //经济舱
  4837. if (ecoTypeIds.Contains(airInfo.CType))
  4838. {
  4839. if (airInfo.PrePrice <= ecoPri_kimiAI) isAutoAudit = true;
  4840. }
  4841. //公务舱
  4842. else if (bizTypeIds.Contains(airInfo.CType))
  4843. {
  4844. if (airInfo.PrePrice <= bizPri_kimiAI) isAutoAudit = true;
  4845. }
  4846. else return (false, "该舱位类型不在自动审核范围内,不可自动审核!");
  4847. //是否执行自动审核
  4848. if (isAutoAudit)
  4849. {
  4850. var auditStatus = await _sqlSugar.Updateable<Grp_CreditCardPayment>()
  4851. .SetColumns(x => x.IsAuditGM == 3)
  4852. .SetColumns(x => x.AuditGMOperate == 4)
  4853. .SetColumns(x => x.AuditGMDate == DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
  4854. .Where(x => x.Id == airInfo.CcpId)
  4855. .ExecuteCommandAsync();
  4856. if (auditStatus > 0) return (true, "机票自动审核(KIMI-AI识别方式)执行成功!");
  4857. }
  4858. return (false, "当前费用超过成本费用,不可自动审核!");
  4859. }
  4860. /// <summary>
  4861. /// 机票费用录入
  4862. /// 自动审核测试 - AI 识别
  4863. /// </summary>
  4864. /// <param name="groupId"></param>
  4865. /// <param name="Id"></param>
  4866. /// <returns></returns>
  4867. [HttpPost]
  4868. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4869. public async Task<IActionResult> AirTicketResAutoAuditTest(int groupId, int Id)
  4870. {
  4871. (bool status, string msg) = await AirTicketResAutoAudit(groupId, Id);
  4872. return Ok(JsonView(status, msg));
  4873. }
  4874. /// <summary>
  4875. /// 根据舱位类型查询接团客户名单信息
  4876. /// </summary>
  4877. /// <param name="dto"></param>
  4878. /// <returns></returns>
  4879. [HttpPost]
  4880. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4881. public async Task<IActionResult> TankType(AirTicketResByIdDto dto)
  4882. {
  4883. try
  4884. {
  4885. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  4886. if (crm_Groups.Count != 0)
  4887. {
  4888. var Customer = new List<dynamic>();
  4889. foreach (var item in crm_Groups)
  4890. {
  4891. var data = new
  4892. {
  4893. item.Id,
  4894. item.Pinyin,
  4895. Name = item.LastName + item.FirstName
  4896. };
  4897. Customer.Add(data);
  4898. }
  4899. return Ok(JsonView(true, "查询成功!", Customer));
  4900. }
  4901. return Ok(JsonView(true, "暂无数据", crm_Groups));
  4902. }
  4903. catch (Exception ex)
  4904. {
  4905. return Ok(JsonView(false, "程序错误!"));
  4906. throw;
  4907. }
  4908. }
  4909. /// <summary>
  4910. /// 根据团号获取客户信息
  4911. /// </summary>
  4912. /// <param name="dto"></param>
  4913. /// <returns></returns>
  4914. [HttpPost]
  4915. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4916. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  4917. {
  4918. var jw = JsonView(false);
  4919. if (dto.DIID < 1)
  4920. {
  4921. jw.Msg += "请输入正确的diid";
  4922. return Ok(jw);
  4923. }
  4924. var arr = GetSimplClientList(dto.DIID);
  4925. jw = JsonView(true, "获取成功!", arr);
  4926. return Ok(jw);
  4927. }
  4928. private List<SimplClientInfo> GetSimplClientList(int diId)
  4929. {
  4930. 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);
  4931. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  4932. foreach (var item in arr)
  4933. {
  4934. EncryptionProcessor.DecryptProperties(item);
  4935. }
  4936. return arr;
  4937. }
  4938. private static string GetClientNameStr(List<SimplClientInfo> list, string origin)
  4939. {
  4940. string result = origin;
  4941. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  4942. {
  4943. string[] temparr = origin.Split(',');
  4944. string fistrStr = temparr[0];
  4945. int count = temparr.Length;
  4946. bool success = int.TryParse(fistrStr, out int tempId);
  4947. if (success)
  4948. {
  4949. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  4950. if (tempInfo != null)
  4951. {
  4952. if (count > 1)
  4953. {
  4954. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  4955. }
  4956. else
  4957. {
  4958. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  4959. }
  4960. }
  4961. }
  4962. }
  4963. return result;
  4964. }
  4965. private static string GetClientNameStr1(List<SimplClientInfo> list, string origin)
  4966. {
  4967. string result = origin;
  4968. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  4969. {
  4970. string[] temparr = origin.Split(',');
  4971. result = "";
  4972. foreach (var item in temparr)
  4973. {
  4974. bool success = int.TryParse(item, out int tempId);
  4975. if (success)
  4976. {
  4977. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  4978. if (tempInfo != null)
  4979. {
  4980. result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
  4981. }
  4982. }
  4983. }
  4984. }
  4985. if (result.Length > 0) result = result.Substring(0, result.Length - 1);
  4986. return result;
  4987. }
  4988. /// <summary>
  4989. /// 机票费用录入,删除
  4990. /// </summary>
  4991. /// <param name="dto"></param>
  4992. /// <returns></returns>
  4993. [HttpPost]
  4994. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4995. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  4996. {
  4997. try
  4998. {
  4999. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  5000. if (res)
  5001. {
  5002. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  5003. {
  5004. IsDel = 1,
  5005. DeleteUserId = dto.DeleteUserId,
  5006. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5007. }).ExecuteCommandAsync();
  5008. return Ok(JsonView(true, "删除成功!"));
  5009. }
  5010. return Ok(JsonView(false, "删除失败!"));
  5011. }
  5012. catch (Exception ex)
  5013. {
  5014. return Ok(JsonView(false, "程序错误!"));
  5015. throw;
  5016. }
  5017. }
  5018. /// <summary>
  5019. /// 导出机票录入报表
  5020. /// </summary>
  5021. /// <param name="dto"></param>
  5022. /// <returns></returns>
  5023. [HttpPost]
  5024. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5025. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  5026. {
  5027. try
  5028. {
  5029. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  5030. if (groupData.Code != 0)
  5031. {
  5032. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  5033. }
  5034. else
  5035. {
  5036. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  5037. if (AirTicketReservations.Count != 0)
  5038. {
  5039. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  5040. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  5041. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  5042. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  5043. var designer = new WorkbookDesigner
  5044. {
  5045. Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx")
  5046. };
  5047. decimal countCost = 0;
  5048. foreach (var item in AirTicketReservations)
  5049. {
  5050. #region 处理客人姓名
  5051. string clientNames = _tourClientListRep.ResolveCustomerName(item.ClientName);
  5052. item.ClientName = clientNames;
  5053. #endregion
  5054. if (item.BankType == "其他")
  5055. {
  5056. item.BankNo = "--";
  5057. }
  5058. else
  5059. {
  5060. if (!string.IsNullOrEmpty(item.BankType))
  5061. {
  5062. item.BankNo = $"{item.BankType}:{item.BankNo?[..3]}";
  5063. }
  5064. }
  5065. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  5066. item.Price = System.Decimal.Round(item.Price, 2);
  5067. countCost += Convert.ToDecimal(item.Price);
  5068. }
  5069. designer.SetDataSource("Export", AirTicketReservations);
  5070. designer.SetDataSource("ExportDiCode", diCode);
  5071. designer.SetDataSource("ExportDiName", diName);
  5072. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  5073. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  5074. designer.Process();
  5075. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  5076. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  5077. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  5078. return Ok(JsonView(true, "成功", url = rst));
  5079. }
  5080. else
  5081. {
  5082. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  5083. }
  5084. }
  5085. }
  5086. catch (Exception ex)
  5087. {
  5088. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  5089. throw;
  5090. }
  5091. }
  5092. private Dictionary<string, string> transDic = new Dictionary<string, string>();
  5093. /// <summary>
  5094. /// 行程单导出
  5095. /// </summary>
  5096. /// <param name="dto"></param>
  5097. /// <returns></returns>
  5098. [HttpPost]
  5099. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5100. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  5101. {
  5102. try
  5103. {
  5104. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  5105. if (groupData.Code != 0)
  5106. {
  5107. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  5108. }
  5109. else
  5110. {
  5111. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  5112. if (dto.Language == "CN")
  5113. {
  5114. var doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  5115. var builder = new DocumentBuilder(doc);
  5116. int tableIndex = 0;//表格索引
  5117. //得到文档中的第一个表格
  5118. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  5119. foreach (var item in _AirTicketReservations)
  5120. {
  5121. #region 处理固定数据
  5122. string[] FlightsCode = item.FlightsCode.Split('/');
  5123. if (FlightsCode.Length != 0)
  5124. {
  5125. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  5126. if (_AirCompany != null)
  5127. {
  5128. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  5129. }
  5130. else
  5131. {
  5132. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  5133. }
  5134. }
  5135. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  5136. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  5137. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  5138. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  5139. string name = "";
  5140. foreach (string clientName in nameArray)
  5141. {
  5142. if (!name.Contains(clientName))
  5143. {
  5144. name += clientName + ",";
  5145. }
  5146. }
  5147. if (!string.IsNullOrWhiteSpace(name))
  5148. {
  5149. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  5150. }
  5151. else
  5152. {
  5153. table.Range.Bookmarks["ClientName"].Text = "--";
  5154. }
  5155. table.Range.Bookmarks["TicketNumber"].Text = "--";
  5156. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  5157. table.Range.Bookmarks["JointTicket"].Text = "--";
  5158. table.Range.Bookmarks["TimeIssue"].Text = "--";
  5159. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  5160. table.Range.Bookmarks["NavigationCode"].Text = "--";
  5161. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  5162. table.Range.Bookmarks["AgentPhone"].Text = "--";
  5163. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  5164. #endregion
  5165. #region 循环数据处理
  5166. var airs = new List<AirInfo>();
  5167. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  5168. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  5169. for (int i = 0; i < FlightsCode.Length; i++)
  5170. {
  5171. var air = new AirInfo();
  5172. string[] tempstr = DayArray[i]
  5173. .Replace("\r\n", string.Empty)
  5174. .Replace("\\r\\n", string.Empty)
  5175. .TrimStart().TrimEnd()
  5176. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  5177. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  5178. string starCity = "";
  5179. if (star_Three != null)
  5180. {
  5181. starCity = star_Three.AirPort;
  5182. }
  5183. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  5184. string EndCity = "";
  5185. if (End_Three != null)
  5186. {
  5187. EndCity = End_Three.AirPort;
  5188. }
  5189. air.Destination = starCity + "/" + EndCity;
  5190. air.Flight = FlightsCode[i];
  5191. air.SeatingClass = item.CTypeName;
  5192. string dateTime = tempstr[2];
  5193. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  5194. air.FlightDate = DateTemp;
  5195. air.DepartureTime = tempstr[5];
  5196. air.LandingTime = tempstr[6];
  5197. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  5198. air.TicketStatus = "--";
  5199. air.Luggage = "--";
  5200. air.DepartureTerminal = "--";
  5201. air.LandingTerminal = "--";
  5202. airs.Add(air);
  5203. }
  5204. int row = 13;
  5205. for (int i = 0; i < airs.Count; i++)
  5206. {
  5207. if (airs.Count > 2)
  5208. {
  5209. for (int j = 0; j < airs.Count - 2; j++)
  5210. {
  5211. var CopyRow = table.Rows[12].Clone(true);
  5212. table.Rows.Add(CopyRow);
  5213. }
  5214. }
  5215. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  5216. int index = 0;
  5217. foreach (PropertyInfo property in properties)
  5218. {
  5219. string value = property.GetValue(airs[i]).ToString();
  5220. Cell ishcel0 = table.Rows[row].Cells[index];
  5221. var p = new Paragraph(doc);
  5222. string s = value;
  5223. p.AppendChild(new Run(doc, s));
  5224. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  5225. ishcel0.AppendChild(p);
  5226. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  5227. index++;
  5228. }
  5229. row++;
  5230. }
  5231. #endregion
  5232. var lastParagraph = new Paragraph(doc);
  5233. //第一个表格末尾加段落
  5234. table.ParentNode.InsertAfter(lastParagraph, table);
  5235. //复制第一个表格
  5236. Table cloneTable = (Table)table.Clone(true);
  5237. //在文档末尾段落后面加入复制的表格
  5238. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  5239. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  5240. {
  5241. int rownewsIndex = 13;
  5242. for (int i = 0; i < 2; i++)
  5243. {
  5244. var CopyRow = table.Rows[12].Clone(true);
  5245. table.Rows.RemoveAt(13);
  5246. table.Rows.Add(CopyRow);
  5247. rownewsIndex++;
  5248. }
  5249. }
  5250. else
  5251. {
  5252. table.Rows.RemoveAt(12);
  5253. }
  5254. cloneTable.Rows.RemoveAt(12);
  5255. }
  5256. if (_AirTicketReservations.Count != 0)
  5257. {
  5258. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  5259. if (FlightsCode.Length != 0)
  5260. {
  5261. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  5262. if (_AirCompany != null)
  5263. {
  5264. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  5265. }
  5266. else
  5267. {
  5268. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  5269. }
  5270. }
  5271. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  5272. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  5273. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  5274. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  5275. string name = "";
  5276. foreach (string clientName in nameArray)
  5277. {
  5278. if (!name.Contains(clientName))
  5279. {
  5280. name += clientName + ",";
  5281. }
  5282. }
  5283. if (!string.IsNullOrWhiteSpace(name))
  5284. {
  5285. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  5286. }
  5287. else
  5288. {
  5289. table.Range.Bookmarks["ClientName"].Text = "--";
  5290. }
  5291. table.Range.Bookmarks["TicketNumber"].Text = "--";
  5292. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  5293. table.Range.Bookmarks["JointTicket"].Text = "--";
  5294. table.Range.Bookmarks["TimeIssue"].Text = "--";
  5295. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  5296. table.Range.Bookmarks["NavigationCode"].Text = "--";
  5297. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  5298. table.Range.Bookmarks["AgentPhone"].Text = "--";
  5299. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  5300. }
  5301. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  5302. //保存合并后的文档
  5303. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  5304. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  5305. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  5306. return Ok(JsonView(true, "成功!", rst));
  5307. }
  5308. else
  5309. {
  5310. var doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  5311. var builder = new DocumentBuilder(doc);
  5312. int tableIndex = 0;//表格索引
  5313. //得到文档中的第一个表格
  5314. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  5315. var texts = new List<string>();
  5316. foreach (var item in _AirTicketReservations)
  5317. {
  5318. string[] FlightsCode = item.FlightsCode.Split('/');
  5319. if (FlightsCode.Length != 0)
  5320. {
  5321. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  5322. if (_AirCompany != null)
  5323. {
  5324. if (!transDic.ContainsKey(_AirCompany.CnName))
  5325. {
  5326. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  5327. }
  5328. }
  5329. else
  5330. {
  5331. if (!transDic.ContainsKey("--"))
  5332. {
  5333. transDic.Add("--", "--");
  5334. }
  5335. }
  5336. }
  5337. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  5338. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  5339. string name = "";
  5340. foreach (string clientName in nameArray)
  5341. {
  5342. name += clientName + ",";
  5343. }
  5344. if (!texts.Contains(name))
  5345. {
  5346. texts.Add(name);
  5347. }
  5348. var airs = new List<AirInfo>();
  5349. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  5350. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  5351. for (int i = 0; i < FlightsCode.Length; i++)
  5352. {
  5353. var air = new AirInfo();
  5354. string[] tempstr = DayArray[i]
  5355. .Replace("\r\n", string.Empty)
  5356. .Replace("\\r\\n", string.Empty)
  5357. .TrimStart().TrimEnd()
  5358. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  5359. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  5360. if (star_Three != null)
  5361. {
  5362. if (!transDic.ContainsKey(star_Three.AirPort))
  5363. {
  5364. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  5365. }
  5366. }
  5367. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  5368. if (End_Three != null)
  5369. {
  5370. if (!transDic.ContainsKey(End_Three.AirPort))
  5371. {
  5372. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  5373. }
  5374. }
  5375. if (!texts.Contains(item.CTypeName))
  5376. {
  5377. texts.Add(item.CTypeName);
  5378. }
  5379. }
  5380. }
  5381. List<TranslateResult> transData = await _airTicketResRep.ReTransBatch(texts, "en");
  5382. if (transData.Count > 0)
  5383. {
  5384. foreach (TranslateResult item in transData)
  5385. {
  5386. if (!transDic.ContainsKey(item.Query))
  5387. {
  5388. transDic.Add(item.Query, item.Translation);
  5389. }
  5390. }
  5391. }
  5392. foreach (var item in _AirTicketReservations)
  5393. {
  5394. #region 处理固定数据
  5395. string[] FlightsCode = item.FlightsCode.Split('/');
  5396. if (FlightsCode.Length != 0)
  5397. {
  5398. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  5399. if (_AirCompany != null)
  5400. {
  5401. string str = "--";
  5402. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  5403. if (!string.IsNullOrEmpty(translateResult))
  5404. {
  5405. str = translateResult;
  5406. str = _airTicketResRep.Processing(str);
  5407. }
  5408. table.Range.Bookmarks["AirlineCompany"].Text = str;
  5409. }
  5410. else
  5411. {
  5412. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  5413. }
  5414. }
  5415. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  5416. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  5417. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  5418. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  5419. string names = "";
  5420. foreach (string clientName in nameArray)
  5421. {
  5422. names += clientName + ",";
  5423. }
  5424. if (!string.IsNullOrWhiteSpace(names))
  5425. {
  5426. string str = "--";
  5427. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  5428. if (!string.IsNullOrEmpty(translateResult))
  5429. {
  5430. str = translateResult;
  5431. str = _airTicketResRep.Processing(str);
  5432. }
  5433. table.Range.Bookmarks["ClientName"].Text = str;
  5434. }
  5435. else
  5436. {
  5437. table.Range.Bookmarks["ClientName"].Text = "--";
  5438. }
  5439. table.Range.Bookmarks["TicketNumber"].Text = "--";
  5440. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  5441. table.Range.Bookmarks["JointTicket"].Text = "--";
  5442. table.Range.Bookmarks["TimeIssue"].Text = "--";
  5443. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  5444. table.Range.Bookmarks["NavigationCode"].Text = "--";
  5445. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  5446. table.Range.Bookmarks["AgentPhone"].Text = "--";
  5447. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  5448. #endregion
  5449. #region 循环数据处理
  5450. var airs = new List<AirInfo>();
  5451. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  5452. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  5453. for (int i = 0; i < FlightsCode.Length; i++)
  5454. {
  5455. var air = new AirInfo();
  5456. string[] tempstr = DayArray[i]
  5457. .Replace("\r\n", string.Empty)
  5458. .Replace("\\r\\n", string.Empty)
  5459. .TrimStart().TrimEnd()
  5460. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  5461. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  5462. string starCity = "";
  5463. if (star_Three != null)
  5464. {
  5465. string str2 = "--";
  5466. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  5467. if (!string.IsNullOrEmpty(translateResult2))
  5468. {
  5469. str2 = translateResult2;
  5470. str2 = _airTicketResRep.Processing(str2);
  5471. }
  5472. starCity = str2;
  5473. }
  5474. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  5475. string EndCity = "";
  5476. if (End_Three != null)
  5477. {
  5478. string str1 = "--";
  5479. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  5480. if (!string.IsNullOrEmpty(translateResult1))
  5481. {
  5482. str1 = translateResult1;
  5483. str1 = _airTicketResRep.Processing(str1);
  5484. }
  5485. EndCity = str1;
  5486. }
  5487. air.Destination = starCity + "/" + EndCity;
  5488. air.Flight = FlightsCode[i];
  5489. string str = "--";
  5490. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  5491. if (!string.IsNullOrEmpty(translateResult))
  5492. {
  5493. str = translateResult;
  5494. str = _airTicketResRep.Processing(str);
  5495. }
  5496. air.SeatingClass = str;
  5497. string dateTime = tempstr[2];
  5498. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  5499. air.FlightDate = DateTemp;
  5500. air.DepartureTime = tempstr[5];
  5501. air.LandingTime = tempstr[6];
  5502. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  5503. air.TicketStatus = "--";
  5504. air.Luggage = "--";
  5505. air.DepartureTerminal = "--";
  5506. air.LandingTerminal = "--";
  5507. airs.Add(air);
  5508. }
  5509. int row = 13;
  5510. for (int i = 0; i < airs.Count; i++)
  5511. {
  5512. if (airs.Count > 2)
  5513. {
  5514. for (int j = 0; j < airs.Count - 2; j++)
  5515. {
  5516. var CopyRow = table.Rows[12].Clone(true);
  5517. table.Rows.Add(CopyRow);
  5518. }
  5519. }
  5520. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  5521. int index = 0;
  5522. foreach (PropertyInfo property in properties)
  5523. {
  5524. string value = property.GetValue(airs[i]).ToString();
  5525. Cell ishcel0 = table.Rows[row].Cells[index];
  5526. var p = new Paragraph(doc);
  5527. string s = value;
  5528. p.AppendChild(new Run(doc, s));
  5529. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  5530. ishcel0.AppendChild(p);
  5531. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  5532. //ishcel0.CellFormat.VerticalAlignment=
  5533. index++;
  5534. }
  5535. row++;
  5536. }
  5537. #endregion
  5538. var lastParagraph = new Paragraph(doc);
  5539. //第一个表格末尾加段落
  5540. table.ParentNode.InsertAfter(lastParagraph, table);
  5541. //复制第一个表格
  5542. Table cloneTable = (Table)table.Clone(true);
  5543. //在文档末尾段落后面加入复制的表格
  5544. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  5545. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  5546. {
  5547. int rownewsIndex = 13;
  5548. for (int i = 0; i < 2; i++)
  5549. {
  5550. var CopyRow = table.Rows[12].Clone(true);
  5551. table.Rows.RemoveAt(13);
  5552. table.Rows.Add(CopyRow);
  5553. rownewsIndex++;
  5554. }
  5555. }
  5556. else
  5557. {
  5558. table.Rows.RemoveAt(12);
  5559. }
  5560. cloneTable.Rows.RemoveAt(12);
  5561. }
  5562. if (_AirTicketReservations.Count != 0)
  5563. {
  5564. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  5565. if (FlightsCode.Length != 0)
  5566. {
  5567. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  5568. if (_AirCompany != null)
  5569. {
  5570. string str = "--";
  5571. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  5572. if (!string.IsNullOrEmpty(translateResult))
  5573. {
  5574. str = translateResult;
  5575. str = _airTicketResRep.Processing(str);
  5576. }
  5577. table.Range.Bookmarks["AirlineCompany"].Text = str;
  5578. }
  5579. else
  5580. {
  5581. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  5582. }
  5583. }
  5584. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  5585. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  5586. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  5587. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  5588. string names = "";
  5589. foreach (string clientName in nameArray)
  5590. {
  5591. names += clientName + ",";
  5592. }
  5593. if (!string.IsNullOrWhiteSpace(names))
  5594. {
  5595. string str = "--";
  5596. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  5597. if (!string.IsNullOrEmpty(translateResult))
  5598. {
  5599. str = translateResult;
  5600. str = _airTicketResRep.Processing(str);
  5601. }
  5602. table.Range.Bookmarks["ClientName"].Text = str;
  5603. }
  5604. else
  5605. {
  5606. table.Range.Bookmarks["ClientName"].Text = "--";
  5607. }
  5608. table.Range.Bookmarks["TicketNumber"].Text = "--";
  5609. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  5610. table.Range.Bookmarks["JointTicket"].Text = "--";
  5611. table.Range.Bookmarks["TimeIssue"].Text = "--";
  5612. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  5613. table.Range.Bookmarks["NavigationCode"].Text = "--";
  5614. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  5615. table.Range.Bookmarks["AgentPhone"].Text = "--";
  5616. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  5617. }
  5618. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  5619. //保存合并后的文档
  5620. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  5621. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  5622. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  5623. return Ok(JsonView(true, "成功!", rst));
  5624. }
  5625. }
  5626. }
  5627. catch (Exception ex)
  5628. {
  5629. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  5630. throw;
  5631. }
  5632. }
  5633. #endregion
  5634. #region 团组增减款项 --> 其他款项
  5635. /// <summary>
  5636. /// 团组增减款项下拉框绑定
  5637. /// </summary>
  5638. /// <param name="dto"></param>
  5639. /// <returns></returns>
  5640. [HttpPost]
  5641. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5642. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  5643. {
  5644. #region 参数验证
  5645. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  5646. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  5647. #endregion
  5648. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  5649. }
  5650. /// <summary>
  5651. /// 根据团组Id查询团组增减款项
  5652. /// </summary>
  5653. /// <param name="dto"></param>
  5654. /// <returns></returns>
  5655. [HttpPost]
  5656. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5657. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  5658. {
  5659. #region 参数验证
  5660. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  5661. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  5662. #endregion
  5663. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  5664. }
  5665. /// <summary>
  5666. /// 团组增减款项操作(Status:1.新增,2.修改)
  5667. /// </summary>
  5668. /// <param name="dto"></param>
  5669. /// <returns></returns>
  5670. [HttpPost]
  5671. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5672. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  5673. {
  5674. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  5675. if (groupData.Code != 200)
  5676. {
  5677. return Ok(JsonView(false, groupData.Msg));
  5678. }
  5679. #region 应用推送
  5680. //int otherId = (int)groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  5681. //int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  5682. //int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  5683. int otherId = Convert.ToInt32(groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null) ?? 0);
  5684. int ccpId = Convert.ToInt32(groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null) ?? 0);
  5685. int sign = Convert.ToInt32(groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null) ?? 0);
  5686. bool recheck = Convert.ToBoolean(groupData.Data.GetType().GetProperty("recheck").GetValue(groupData.Data, null) ?? "True");
  5687. if (recheck)
  5688. {
  5689. //自动审核
  5690. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(3, dto.DiId, otherId);
  5691. }
  5692. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  5693. //2024-10-21 新增LZ UID
  5694. var userIds = new List<int>() { 21 };
  5695. string title = $"系统通知";
  5696. string content = "";
  5697. var diId = dto.DiId;
  5698. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  5699. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  5700. if (dto.Status == 1) content = $"[新增-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  5701. else if (dto.Status == 2) content = $"[更新-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  5702. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  5703. //await APNsTools.iOS_PushNotifications1("051", $"其他款项费用审核", "", content);
  5704. #endregion
  5705. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5706. }
  5707. /// <summary>
  5708. /// 团组增减款项操作 删除
  5709. /// </summary>
  5710. /// <param name="dto"></param>
  5711. /// <returns></returns>
  5712. [HttpPost]
  5713. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5714. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  5715. {
  5716. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  5717. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  5718. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  5719. if (res.Code == 0) return Ok(JsonView(true, "删除成功!"));
  5720. return Ok(JsonView(false, res?.Msg ?? "删除失败!"));
  5721. }
  5722. /// <summary>
  5723. /// 根据团组增减款项Id查询
  5724. /// </summary>
  5725. /// <param name="dto"></param>
  5726. /// <returns></returns>
  5727. [HttpPost]
  5728. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5729. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  5730. {
  5731. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  5732. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  5733. }
  5734. /// <summary>
  5735. /// 查询供应商名称
  5736. /// </summary>
  5737. /// <param name="dto"></param>
  5738. /// <returns></returns>
  5739. [HttpPost]
  5740. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  5741. {
  5742. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  5743. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  5744. ?? new List<Grp_DecreasePayments>();
  5745. dbResult = dbResult.Distinct(new
  5746. ProductComparer()).ToList();
  5747. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  5748. {
  5749. x.Id,
  5750. x.SupplierAddress,
  5751. x.SupplierArea,
  5752. x.SupplierContact,
  5753. x.SupplierContactNumber,
  5754. x.SupplierEmail,
  5755. x.SupplierName,
  5756. x.SupplierSocialAccount,
  5757. x.SupplierTypeId,
  5758. }).ToList());
  5759. return Ok(jw);
  5760. }
  5761. /// <summary>
  5762. /// 团组增减款项 OTA匹配
  5763. /// </summary>
  5764. /// <param name="file"></param>
  5765. /// <returns></returns>
  5766. [HttpPost]
  5767. public async Task<IActionResult> DecreasePaymentsOTAMate(IFormFile file)
  5768. {
  5769. if (file.Length < 1) return Ok(JsonView(false, "请上传文件!"));
  5770. string fileName = file.FileName;
  5771. if (!fileName.EndsWith(".xlsx") && !fileName.EndsWith(".xls"))
  5772. {
  5773. return Ok(JsonView(false, "请上传Excel文件!"));
  5774. }
  5775. //D:\FTP\File\OA2023\Office\GrpFile\团组增减款项相关文件\团组其他款项(OTA)
  5776. var path = @$"{AppSettingsHelper.Get("GrpFileBasePath")}团组增减款项相关文件/团组其他款项(OTA)";
  5777. if (!Directory.Exists(path))
  5778. {
  5779. Directory.CreateDirectory(path);
  5780. }
  5781. var filePath = @$"{path}/{fileName}";
  5782. //保存文件
  5783. using (FileStream fs = System.IO.File.Create(filePath))
  5784. {
  5785. file.CopyTo(fs);
  5786. fs.Flush();
  5787. }
  5788. if (!System.IO.File.Exists(filePath)) return Ok(JsonView(false, "文件不存在!"));
  5789. //读取ExcelFile
  5790. DataTable dt = ConvertExcelToDataTable(filePath);
  5791. if (dt == null) return Ok(JsonView(false, $"您上传的Excel工作表没有内容,请检查!!!"));
  5792. dt.TableName = "TB";
  5793. //修改table列名
  5794. dt.Columns[0].ColumnName = "OrderNo"; // 订单号
  5795. dt.Columns[1].ColumnName = "OTAOrderNo"; // OTA订单号
  5796. dt.Columns[2].ColumnName = "PackageName"; // 套餐名
  5797. dt.Columns[3].ColumnName = "IsPay"; // 是否支付
  5798. dt.Columns[4].ColumnName = "IsShipments"; // 是否发货
  5799. dt.Columns[5].ColumnName = "IsSendBack"; // 是否寄回
  5800. dt.Columns[6].ColumnName = "OpUser"; // 使用人信息
  5801. dt.Columns[7].ColumnName = "OrderTime"; // 下单时间
  5802. dt.Columns[8].ColumnName = "UseTime"; // 使用时间
  5803. dt.Columns[9].ColumnName = "Quantity"; // 台数
  5804. dt.Columns[10].ColumnName = "Days"; // 租赁天数
  5805. dt.Columns[11].ColumnName = "QuantityShipped";// 发货数量
  5806. dt.Columns[12].ColumnName = "TotalPrice"; // 总金额
  5807. dt.Columns[13].ColumnName = "GroupName"; // 团组名称
  5808. dt.Columns[14].ColumnName = "OATotalPrice"; // OA金额
  5809. var otaOrderNos = new List<string>();
  5810. foreach (DataRow item in dt.Rows)
  5811. {
  5812. otaOrderNos.Add(item["OTAOrderNo"].ToString());
  5813. }
  5814. var oaDatas = await _sqlSugar.Queryable<Grp_DecreasePayments>()
  5815. .LeftJoin<Grp_DelegationInfo>((dp, di) => dp.DiId == di.Id)
  5816. .Where((dp, di) => dp.IsDel == 0 && dp.PriceName.Contains("wifi") || otaOrderNos.Contains(dp.OTAOrderNo))
  5817. .Select((dp, di) => new
  5818. {
  5819. dp.PriceName,
  5820. dp.OTAOrderNo,
  5821. dp.FeeTotal,
  5822. di.TeamName,
  5823. })
  5824. .ToListAsync();
  5825. foreach (DataRow item in dt.Rows)
  5826. {
  5827. var otaOrderNo = item["OTAOrderNo"].ToString();
  5828. var oaData = oaDatas.Find(x => !string.IsNullOrEmpty(x.OTAOrderNo) && x.OTAOrderNo.Contains(otaOrderNo));
  5829. if (oaData == null) continue;
  5830. item["GroupName"] = oaData.TeamName;
  5831. item["OATotalPrice"] = oaData.FeeTotal.ToString("#0.00");
  5832. }
  5833. string fileName1 = $"OTA_WIFI费用{DateTime.Now:yyyyMMddHHmmss}.xls";
  5834. var pairs = new Dictionary<string, object>();
  5835. var datas = new List<DataTable>
  5836. {
  5837. dt
  5838. };
  5839. url = AsposeHelper.ExpertExcelToModel("WIFI费用清单-模板.xlsx", $"GrpFile/团组增减款项相关文件/团组其他款项(OTA)", fileName1, pairs, datas);
  5840. return Ok(JsonView(true, "操作成功", new { url }));
  5841. }
  5842. #region
  5843. private static DataTable ConvertExcelToDataTable(string excelFilePath)
  5844. {
  5845. // 创建Workbook对象
  5846. var workbook = new Workbook(excelFilePath);
  5847. // 获取第一个工作表
  5848. var worksheet = workbook.Worksheets[0];
  5849. // 将工作表转换为DataTable
  5850. DataTable dataTable = worksheet.Cells.ExportDataTable(1, 0, worksheet.Cells.MaxDataRow + 1, worksheet.Cells.MaxDataColumn + 1);
  5851. return dataTable;
  5852. }
  5853. #endregion
  5854. /// <summary>
  5855. /// 世运会数据
  5856. /// </summary>
  5857. /// <returns></returns>
  5858. [HttpGet]
  5859. public IActionResult WorldGamesData()
  5860. {
  5861. var setData = _sqlSugar.Queryable<Grp_GamesBudgetMaster>().Where(x => x.IsDel == 0).ToList();
  5862. var groupMenu = setData.GroupBy(x => x.T0);
  5863. var resultArr = new List<DecreasePaymentsWorldGamesDataView>();
  5864. foreach (var item in groupMenu)
  5865. {
  5866. resultArr.Add(new DecreasePaymentsWorldGamesDataView
  5867. {
  5868. Data = new SetDataView
  5869. {
  5870. Name = item.Key
  5871. },
  5872. Child = item.Select(x => x.CalculationContent).ToList() ?? new List<string>()
  5873. });
  5874. }
  5875. return Ok(JsonView(true, "success", resultArr));
  5876. }
  5877. #endregion
  5878. #region 文件上传、删除
  5879. /// <summary>
  5880. /// region 文件上传 可以带参数
  5881. /// </summary>
  5882. /// <param name="file"></param>
  5883. /// <returns></returns>
  5884. [HttpPost]
  5885. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5886. public async Task<IActionResult> UploadProject(IFormFile file)
  5887. {
  5888. //var TypeName = Request.Headers["TypeName"].ToString();
  5889. //if (file == null) return Ok(JsonView(false, "文件不存在!"));
  5890. //var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  5891. ////文件名称
  5892. //string projectFileName = file.FileName;
  5893. ////上传的文件的路径
  5894. //string filePath = $"{fileDir}/{projectFileName}";
  5895. //if (TypeName == "A")//A代表团组增减款项
  5896. //{
  5897. // filePath = fileDir + $@"\团组增减款项相关文件";
  5898. // if (!Directory.Exists(filePath))
  5899. // {
  5900. // Directory.CreateDirectory(filePath);
  5901. // }
  5902. // //上传的文件的路径
  5903. // filePath += $@"\{projectFileName}";
  5904. //}
  5905. //else if (TypeName == "B")//B代表商邀相关文件
  5906. //{
  5907. // //上传的文件的路径
  5908. // filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  5909. // if (!Directory.Exists(filePath))
  5910. // {
  5911. // Directory.CreateDirectory(filePath);
  5912. // }
  5913. // //上传的文件的路径
  5914. // filePath = $@"\{projectFileName}";
  5915. //}
  5916. //try
  5917. //{
  5918. // using (FileStream fs = System.IO.File.Create(filePath))
  5919. // {
  5920. // file.CopyTo(fs);
  5921. // fs.Flush();
  5922. // }
  5923. //}
  5924. //catch (Exception ex)
  5925. //{
  5926. // return Ok(JsonView(false, $"文件上传失败! Error:{ex.Message}"));
  5927. //}
  5928. //return Ok(JsonView(true, "上传成功!", projectFileName));
  5929. try
  5930. {
  5931. var TypeName = Request.Headers["TypeName"].ToString();
  5932. if (file != null)
  5933. {
  5934. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  5935. //文件名称
  5936. string projectFileName = file.FileName;
  5937. //上传的文件的路径
  5938. string filePath = $"{fileDir}/{projectFileName}";
  5939. if (TypeName == "A")//A代表团组增减款项
  5940. {
  5941. if (!Directory.Exists(fileDir))
  5942. {
  5943. Directory.CreateDirectory(fileDir);
  5944. }
  5945. //上传的文件的路径
  5946. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  5947. }
  5948. else if (TypeName == "B")//B代表商邀相关文件
  5949. {
  5950. if (!Directory.Exists(fileDir))
  5951. {
  5952. Directory.CreateDirectory(fileDir);
  5953. }
  5954. //上传的文件的路径
  5955. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  5956. }
  5957. using (FileStream fs = System.IO.File.Create(filePath))
  5958. {
  5959. file.CopyTo(fs);
  5960. fs.Flush();
  5961. }
  5962. return Ok(JsonView(true, "上传成功!", projectFileName));
  5963. }
  5964. else
  5965. {
  5966. return Ok(JsonView(false, "上传失败!"));
  5967. }
  5968. }
  5969. catch (Exception ex)
  5970. {
  5971. return Ok(JsonView(false, ex.Message));
  5972. }
  5973. }
  5974. /// <summary>
  5975. /// 删除指定文件
  5976. /// </summary>
  5977. /// <param name="dto"></param>
  5978. /// <returns></returns>
  5979. [HttpPost]
  5980. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5981. public async Task<IActionResult> DelFile(DelFileDto dto)
  5982. {
  5983. try
  5984. {
  5985. var TypeName = Request.Headers["TypeName"].ToString();
  5986. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  5987. string filePath = "";
  5988. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  5989. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  5990. int id = 0;
  5991. if (TypeName == "A")
  5992. {
  5993. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  5994. // 删除该文件
  5995. System.IO.File.Delete(filePath);
  5996. id = await _sqlSugar.Updateable<Grp_DecreasePayments>()
  5997. .Where(a => a.Id == dto.Id)
  5998. .SetColumns(a => new Grp_DecreasePayments { FilePath = "" })
  5999. .ExecuteCommandAsync();
  6000. }
  6001. else if (TypeName == "B")
  6002. {
  6003. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  6004. // 删除该文件
  6005. System.IO.File.Delete(filePath);
  6006. var info = await _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.Id == dto.Id && x.IsDel == 0).FirstAsync();
  6007. if (info != null)
  6008. {
  6009. string[] files = Array.Empty<string>();
  6010. if (!string.IsNullOrEmpty(info.Attachment))
  6011. {
  6012. try
  6013. {
  6014. files = JsonConvert.DeserializeObject<string[]>(info.Attachment);
  6015. }
  6016. catch (Exception)
  6017. {
  6018. files = new List<string>() { info.Attachment }.ToArray();
  6019. }
  6020. }
  6021. if (files.Length > 0)
  6022. {
  6023. var files1 = files.Where(x => !x.Equals(dto.fileName)).ToArray();
  6024. string filePath2 = string.Empty;
  6025. if (files1.Length > 0)
  6026. {
  6027. filePath2 = JsonConvert.SerializeObject(files1);
  6028. }
  6029. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  6030. .Where(a => a.Id == dto.Id)
  6031. .SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = filePath2 })
  6032. .ExecuteCommandAsync();
  6033. }
  6034. }
  6035. }
  6036. if (id != 0)
  6037. {
  6038. return Ok(JsonView(true, "成功!"));
  6039. }
  6040. else
  6041. {
  6042. return Ok(JsonView(false, "失败!"));
  6043. }
  6044. }
  6045. catch (Exception ex)
  6046. {
  6047. return Ok(JsonView(false, "程序错误!"));
  6048. throw;
  6049. }
  6050. }
  6051. /// <summary>
  6052. /// 文件上传多个文件 可以带参数
  6053. /// </summary>
  6054. /// <param name="files"></param>
  6055. /// <returns></returns>
  6056. [HttpPost]
  6057. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6058. public async Task<IActionResult> UploadProjects(IFormFile[] files)
  6059. {
  6060. try
  6061. {
  6062. var TypeName = Request.Headers["TypeName"].ToString();
  6063. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  6064. if (files.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  6065. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  6066. var filePahts = new List<string>();
  6067. foreach (var file in files)
  6068. {
  6069. //文件名称
  6070. string projectFileName = file.FileName;
  6071. //上传的文件的路径
  6072. string filePath = $"{fileDir}/{projectFileName}";
  6073. if (TypeName == "A")//A代表团组增减款项
  6074. {
  6075. if (!Directory.Exists(fileDir))
  6076. {
  6077. Directory.CreateDirectory(fileDir);
  6078. }
  6079. //上传的文件的路径
  6080. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  6081. }
  6082. else if (TypeName == "B")//B代表商邀相关文件
  6083. {
  6084. if (!Directory.Exists(fileDir))
  6085. {
  6086. Directory.CreateDirectory(fileDir);
  6087. }
  6088. //上传的文件的路径
  6089. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  6090. }
  6091. using (FileStream fs = System.IO.File.Create(filePath))
  6092. {
  6093. file.CopyTo(fs);
  6094. fs.Flush();
  6095. }
  6096. filePahts.Add(projectFileName);
  6097. }
  6098. return Ok(JsonView(true, "上传成功!", filePahts));
  6099. }
  6100. catch (Exception ex)
  6101. {
  6102. return Ok(JsonView(false, ex.Message));
  6103. }
  6104. }
  6105. #endregion
  6106. #region 商邀费用录入
  6107. /// <summary>
  6108. /// 根据团组Id查询商邀费用列表
  6109. /// </summary>
  6110. /// <param name="dto"></param>
  6111. /// <returns></returns>
  6112. [HttpPost]
  6113. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6114. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  6115. {
  6116. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  6117. if (groupData.Code != 0)
  6118. {
  6119. return Ok(JsonView(false, groupData.Msg));
  6120. }
  6121. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6122. }
  6123. /// <summary>
  6124. /// 商邀费用列表
  6125. /// 下载文件
  6126. /// </summary>
  6127. /// <param name="id"></param>
  6128. /// <returns></returns>
  6129. [HttpGet("{id}")]
  6130. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6131. public async Task<IActionResult> InvitationOfficialActivitiesListDownFile(int id)
  6132. {
  6133. if (id < 1) return Ok(JsonView(false, "请传入有效的Id!"));
  6134. var info = await _InvitationOfficialActivitiesRep.Query(x => x.Id == id).FirstAsync();
  6135. if (info == null) return Ok(JsonView(false, "数据不存在!"));
  6136. if (string.IsNullOrEmpty(info.Attachment)) return Ok(JsonView(false, "文件不存在!"));
  6137. var filePaths = new List<string>();
  6138. var filePathBase = @$"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/";
  6139. try
  6140. {
  6141. filePaths = JsonConvert.DeserializeObject<List<string>>(info.Attachment);
  6142. }
  6143. catch (Exception ex)
  6144. {
  6145. filePaths.Add(info.Attachment);
  6146. }
  6147. if (filePaths != null && filePaths.Count < 1) return Ok(JsonView(false, "文件不存在!"));
  6148. for (int i = 0; i < filePaths.Count; i++)
  6149. {
  6150. filePaths[i] = $"{filePathBase}{filePaths[i]}";
  6151. }
  6152. var zipFilePathGuid = $"{Guid.NewGuid()}.zip";
  6153. var zipFilePath = $"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{zipFilePathGuid}";
  6154. using (var zipFileStream = new FileStream(zipFilePath, FileMode.Create))
  6155. {
  6156. using (var zipArchive = new ZipArchive(zipFileStream, ZipArchiveMode.Create))
  6157. {
  6158. foreach (string filePath in filePaths)
  6159. {
  6160. if (System.IO.File.Exists(filePath))
  6161. {
  6162. // 获取文件名
  6163. string fileName = Path.GetFileName(filePath);
  6164. // 将文件添加到ZIP归档中
  6165. zipArchive.CreateEntryFromFile(filePath, fileName);
  6166. }
  6167. }
  6168. }
  6169. }
  6170. return Ok(JsonView(new { url = @$"{AppSettingsHelper.Get("OfficeBaseUrl")}{AppSettingsHelper.Get("GrpFileFtpPath")}/商邀相关文件/{zipFilePathGuid}" }));
  6171. }
  6172. /// <summary>
  6173. /// 商邀费用 Info Page 基础数据源
  6174. /// </summary>
  6175. /// <returns></returns>
  6176. [HttpPost]
  6177. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6178. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  6179. {
  6180. try
  6181. {
  6182. Result groupData = await _InvitationOfficialActivitiesRep.InitBasicData();
  6183. if (groupData.Code != 0)
  6184. {
  6185. return Ok(JsonView(false, groupData.Msg));
  6186. }
  6187. return Ok(JsonView(true, "操作成功", groupData.Data));
  6188. }
  6189. catch (Exception ex)
  6190. {
  6191. return Ok(JsonView(false, ex.Message));
  6192. throw;
  6193. }
  6194. }
  6195. /// <summary>
  6196. /// 根据商邀费用ID查询C表和商邀费用数据
  6197. /// </summary>
  6198. /// <param name="dto"></param>
  6199. /// <returns></returns>
  6200. [HttpPost]
  6201. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6202. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  6203. {
  6204. try
  6205. {
  6206. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  6207. if (groupData.Code != 0)
  6208. {
  6209. return Ok(JsonView(false, groupData.Msg));
  6210. }
  6211. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6212. }
  6213. catch (Exception ex)
  6214. {
  6215. return Ok(JsonView(false, ex.Message));
  6216. throw;
  6217. }
  6218. }
  6219. /// <summary>
  6220. /// 商邀费用录入操作(Status:1.新增,2.修改)
  6221. /// </summary>
  6222. /// <param name="dto"></param>
  6223. /// <returns></returns>
  6224. [HttpPost]
  6225. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6226. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  6227. {
  6228. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  6229. if (groupData.Code != 0)
  6230. {
  6231. return Ok(JsonView(false, groupData.Msg));
  6232. }
  6233. #region 应用推送
  6234. try
  6235. {
  6236. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  6237. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  6238. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  6239. //2024-10-21 新增LZ UID
  6240. var userIds = new List<int>() { 21 };
  6241. string title = $"系统通知";
  6242. string content = "";
  6243. var diId = dto.DiId;
  6244. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  6245. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  6246. if (dto.Status == 1) content = $"[新增-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  6247. else if (dto.Status == 2) content = $"[更新-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  6248. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  6249. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "81" };
  6250. await APNsTools.iOS_PushNotifications1("051", $"商邀费用审核", "", content, true, "ExpenseAuditWebView", h5);
  6251. }
  6252. catch (Exception ex)
  6253. {
  6254. }
  6255. #endregion
  6256. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6257. }
  6258. /// <summary>
  6259. /// 商邀删除
  6260. /// </summary>
  6261. /// <param name="dto"></param>
  6262. /// <returns></returns>
  6263. [HttpPost]
  6264. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6265. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  6266. {
  6267. try
  6268. {
  6269. _sqlSugar.BeginTran();
  6270. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  6271. .SetColumns(it => new Grp_InvitationOfficialActivities()
  6272. {
  6273. IsDel = 1,
  6274. DeleteUserId = dto.DeleteUserId,
  6275. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6276. })
  6277. .Where(it => it.Id == dto.Id)
  6278. .ExecuteCommand();
  6279. if (res1 > 0)
  6280. {
  6281. int _diId = 0;
  6282. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  6283. if (_ioaInfo != null)
  6284. {
  6285. _diId = _ioaInfo.DiId;
  6286. }
  6287. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  6288. .SetColumns(a => new Grp_CreditCardPayment()
  6289. {
  6290. IsDel = 1,
  6291. DeleteUserId = dto.DeleteUserId,
  6292. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6293. })
  6294. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  6295. .ExecuteCommand();
  6296. if (res2 > 0)
  6297. {
  6298. _sqlSugar.CommitTran();
  6299. return Ok(JsonView(true, "删除成功!"));
  6300. }
  6301. }
  6302. _sqlSugar.RollbackTran();
  6303. return Ok(JsonView(false, "删除失败"));
  6304. }
  6305. catch (Exception ex)
  6306. {
  6307. _sqlSugar.RollbackTran();
  6308. return Ok(JsonView(false, ex.Message));
  6309. }
  6310. }
  6311. #endregion
  6312. #region 票据上传
  6313. /// <summary>
  6314. /// 团组模块文件上传
  6315. /// </summary>
  6316. /// <param name="dto"></param>
  6317. /// <returns></returns>
  6318. [HttpPost]
  6319. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  6320. {
  6321. var jw = JsonView(false);
  6322. long M = 1024 * 1024;
  6323. if (dto.Files == null || dto.Files.Count == 0)
  6324. {
  6325. jw.Msg = "无文件信息!";
  6326. return Ok(jw);
  6327. }
  6328. if (dto.Files.Sum(x => x.Length) > 20 * M)
  6329. {
  6330. jw.Msg = "文件大小超过20M!";
  6331. return Ok(jw);
  6332. }
  6333. //var nameSp = dto.File.FileName.Split(".");
  6334. //if (nameSp.Length < 2)
  6335. //{
  6336. // jw.Msg = "拓展名称有误!";
  6337. // return Ok(jw);
  6338. //}
  6339. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  6340. //if (!existsName.Contains(nameSp[1].ToUpper()))
  6341. //{
  6342. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  6343. // return Ok(jw);
  6344. //}
  6345. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  6346. if (Ctable == null)
  6347. {
  6348. jw.Msg = "Ctable指向有误!";
  6349. return Ok(jw);
  6350. }
  6351. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  6352. if (groupInfo == null)
  6353. {
  6354. jw.Msg = "团组信息不存在!";
  6355. return Ok(jw);
  6356. }
  6357. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  6358. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  6359. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  6360. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  6361. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  6362. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  6363. try
  6364. {
  6365. if (!Directory.Exists(fileBase))
  6366. {
  6367. Directory.CreateDirectory(fileBase);
  6368. }
  6369. var saveArr = new List<Grp_GroupModelFile>();
  6370. foreach (var fileStream in dto.Files)
  6371. {
  6372. var saveFilePath = fileBase + "\\" + fileStream.FileName;
  6373. var file = new Grp_GroupModelFile()
  6374. {
  6375. Cid = dto.Cid,
  6376. CreateTime = DateTime.Now,
  6377. CreateUserId = dto.Userid,
  6378. Ctable = dto.Ctable,
  6379. Diid = dto.Diid,
  6380. IsDel = 0,
  6381. FilePath = saveFilePath,
  6382. FileName = fileStream.FileName
  6383. };
  6384. using (FileStream fs = System.IO.File.Create(saveFilePath))
  6385. {
  6386. fileStream.CopyTo(fs);
  6387. fs.Flush();
  6388. }
  6389. saveArr.Add(file);
  6390. }
  6391. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  6392. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  6393. jw = JsonView(true, "保存成功!", new
  6394. {
  6395. count = addResult,
  6396. filesName = saveArr.Select(x => x.FileName)
  6397. });
  6398. }
  6399. catch (Exception ex)
  6400. {
  6401. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  6402. {
  6403. count = 0,
  6404. filesName = Array.Empty<string>(),
  6405. });
  6406. }
  6407. return Ok(jw);
  6408. }
  6409. /// <summary>
  6410. /// 查询各模块已保存文件
  6411. /// </summary>
  6412. /// <param name="dto"></param>
  6413. /// <returns></returns>
  6414. [HttpPost]
  6415. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  6416. {
  6417. var expression = Expressionable.Create<Grp_GroupModelFile>()
  6418. .AndIF(dto.UserId != -1, x => x.CreateUserId == dto.UserId);
  6419. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x => x.Id).ToList();
  6420. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  6421. {
  6422. expression = Expressionable.Create<Grp_GroupModelFile>()
  6423. .And(x => visaIds.Contains(x.CreateUserId));
  6424. }
  6425. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  6426. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  6427. .Where(expression.ToExpression())
  6428. .ToList();
  6429. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  6430. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  6431. {
  6432. x.FileName,
  6433. x.Id,
  6434. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  6435. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  6436. })));
  6437. }
  6438. /// <summary>
  6439. /// 下载该团组下的所有文件
  6440. /// </summary>
  6441. /// <param name="dto"></param>
  6442. /// <returns></returns>
  6443. [HttpPost]
  6444. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  6445. {
  6446. var jw = JsonView(false);
  6447. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  6448. if (groupInfo == null)
  6449. {
  6450. jw.Msg = "团组信息不存在!";
  6451. return Ok(jw);
  6452. }
  6453. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  6454. var isModule = Convert.ToBoolean(dto.isModule);
  6455. var Zips = new Dictionary<string, Stream>();
  6456. var io = new IOOperatorHelper();
  6457. if (isModule)
  6458. {
  6459. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  6460. foreach (var moduleArr in moduleGroup)
  6461. {
  6462. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  6463. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  6464. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  6465. var chiZips = new Dictionary<string, Stream>();
  6466. foreach (var item in moduleArr)
  6467. {
  6468. if (System.IO.File.Exists(item.FilePath))
  6469. {
  6470. using (var fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  6471. {
  6472. byte[] bytes = new byte[fileStream.Length];
  6473. fileStream.Read(bytes, 0, bytes.Length);
  6474. fileStream.Close();
  6475. Stream stream = new MemoryStream(bytes);
  6476. chiZips.Add(item.FileName, stream);
  6477. }
  6478. }
  6479. }
  6480. if (chiZips.Count > 0)
  6481. {
  6482. var byts = io.ConvertZipStream(chiZips);
  6483. Stream stream = new MemoryStream(byts);
  6484. Zips.Add(key.Name + "_.zip", stream);
  6485. }
  6486. }
  6487. }
  6488. else
  6489. {
  6490. foreach (var item in dbQuery)
  6491. {
  6492. using (var fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  6493. {
  6494. byte[] bytes = new byte[fileStream.Length];
  6495. fileStream.Read(bytes, 0, bytes.Length);
  6496. fileStream.Close();
  6497. var stream = new MemoryStream(bytes);
  6498. while (Zips.ContainsKey(item.FileName))
  6499. {
  6500. item.FileName = new Random().Next(100) + "_" + item.FileName;
  6501. }
  6502. Zips.Add(item.FileName, stream);
  6503. }
  6504. }
  6505. }
  6506. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  6507. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  6508. if (Zips.Count > 0)
  6509. {
  6510. var byts = io.ConvertZipStream(Zips);
  6511. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  6512. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  6513. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  6514. }
  6515. else
  6516. {
  6517. jw.Msg = "暂无生成文件!";
  6518. }
  6519. return Ok(jw);
  6520. }
  6521. /// <summary>
  6522. /// 下载该团组下此模块的所有文件
  6523. /// </summary>
  6524. /// <param name="dto"></param>
  6525. /// <returns></returns>
  6526. [HttpPost]
  6527. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  6528. {
  6529. var jw = JsonView(false);
  6530. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  6531. if (groupInfo == null)
  6532. {
  6533. jw.Msg = "团组信息不存在!";
  6534. return Ok(jw);
  6535. }
  6536. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  6537. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  6538. && x.IsDel == 0);
  6539. if (key == null)
  6540. {
  6541. jw.Msg = "Ctable指向错误!";
  6542. return Ok(jw);
  6543. }
  6544. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  6545. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  6546. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  6547. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  6548. var io = new IOOperatorHelper();
  6549. var Zips = new Dictionary<string, Stream>();
  6550. foreach (var item in dbQuery)
  6551. {
  6552. if (System.IO.File.Exists(item.FilePath))
  6553. {
  6554. using (var fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  6555. {
  6556. byte[] bytes = new byte[fileStream.Length];
  6557. fileStream.Read(bytes, 0, bytes.Length);
  6558. fileStream.Close();
  6559. var stream = new MemoryStream(bytes);
  6560. while (Zips.ContainsKey(item.FileName))
  6561. {
  6562. item.FileName = new Random().Next(100) + "_" + item.FileName;
  6563. }
  6564. Zips.Add(item.FileName, stream);
  6565. }
  6566. }
  6567. }
  6568. if (Zips.Count > 0)
  6569. {
  6570. var byts = io.ConvertZipStream(Zips);
  6571. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  6572. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  6573. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  6574. }
  6575. else
  6576. {
  6577. jw.Msg = "暂无生成文件!";
  6578. }
  6579. return Ok(jw);
  6580. }
  6581. /// <summary>
  6582. /// 删除该团组下的指定文件
  6583. /// </summary>
  6584. /// <param name="dto"></param>
  6585. /// <returns></returns>
  6586. [HttpPost]
  6587. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  6588. {
  6589. var jw = JsonView(false);
  6590. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  6591. if (sing == null)
  6592. {
  6593. jw.Msg = "暂无";
  6594. return Ok(jw);
  6595. }
  6596. if (System.IO.File.Exists(sing.FilePath))
  6597. {
  6598. try
  6599. {
  6600. System.IO.File.Delete(sing.FilePath);
  6601. }
  6602. catch (Exception ex)
  6603. {
  6604. jw.Msg = "删除失败!" + ex.Message;
  6605. return Ok(jw);
  6606. }
  6607. }
  6608. sing.IsDel = 1;
  6609. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  6610. sing.DeleteUserId = dto.UserId;
  6611. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  6612. jw = JsonView(true, "删除成功!");
  6613. return Ok(jw);
  6614. }
  6615. #endregion
  6616. #region 共享文件上传
  6617. /// <summary>
  6618. /// 共享文件数据初始化
  6619. /// </summary>
  6620. /// <returns></returns>
  6621. [HttpGet]
  6622. public async Task<IActionResult> SharedFileInit(int userid, int portType)
  6623. {
  6624. var marketingDepartmentIds = new List<int> { 6, 26, 27, 28 };
  6625. var isMarketingDepartment = _sqlSugar.Queryable<Sys_Users>()
  6626. .Where(x => x.IsDel == 0 && marketingDepartmentIds.Contains(x.DepId))
  6627. .Select(x => x.Id)
  6628. .ToList()
  6629. .Contains(userid);
  6630. var dropDownType = _sqlSugar.Queryable<Sys_SetData>()
  6631. .Where(x => x.STid == 111 && x.IsDel == 0)
  6632. .Select(x => new
  6633. {
  6634. x.Name,
  6635. x.Id,
  6636. }).ToList();
  6637. if (isMarketingDepartment)
  6638. {
  6639. dropDownType = dropDownType.Where(x => x.Id == 1412).ToList();
  6640. }
  6641. if (portType == 1)
  6642. {
  6643. var provCityDatas = await _groupRepository.ProvinceCityBasicSource();
  6644. var dropDownGroupList = _sqlSugar.Queryable<Grp_DelegationInfo>()
  6645. .Where(x => x.IsDel == 0)
  6646. .OrderByDescending(x => x.VisitDate)
  6647. .Select(x => new
  6648. {
  6649. x.TeamName,
  6650. x.Id,
  6651. x.CityId,
  6652. })
  6653. .ToList()
  6654. .Select(x =>
  6655. {
  6656. var provinceId = x.CityId;
  6657. var isDefualtVal = true;
  6658. if (provinceId > 0)
  6659. {
  6660. var parentId = _groupRepository.FindParentIdByChildId(provCityDatas, provinceId);
  6661. if (parentId != null)
  6662. {
  6663. isDefualtVal = false;
  6664. provinceId = (int)parentId;
  6665. }
  6666. }
  6667. if (isDefualtVal)
  6668. {
  6669. provinceId = 122; //默认四川
  6670. }
  6671. return new
  6672. {
  6673. x.TeamName,
  6674. x.Id,
  6675. provinceId,
  6676. };
  6677. })
  6678. .ToList();
  6679. return Ok(JsonView(true, "SUCCESS!", new
  6680. {
  6681. dropDownType,
  6682. dropDownGroupList,
  6683. isMarketingDepartment
  6684. }));
  6685. }
  6686. else if (portType == 2 || portType == 3)
  6687. {
  6688. return Ok(JsonView(true, "SUCCESS!", new
  6689. {
  6690. dropDownType,
  6691. isMarketingDepartment
  6692. }));
  6693. }
  6694. else
  6695. {
  6696. return Ok(JsonView(false, "portType有误!"));
  6697. }
  6698. }
  6699. /// <summary>
  6700. /// 共享文件上传
  6701. /// </summary>
  6702. /// <param name="dto"></param>
  6703. /// <returns></returns>
  6704. [HttpPost]
  6705. public IActionResult SharedFileUpload([FromForm] SharedFileUploadDto dto)
  6706. {
  6707. var isGroup = new List<int> { 1412 };
  6708. if (isGroup.Contains(dto.FileType) && dto.Diid < 1)
  6709. {
  6710. return Ok(JsonView(false, "该文件需要关联团组!"));
  6711. }
  6712. if (dto.Files == null || dto.Files.Count == 0)
  6713. {
  6714. return Ok(JsonView(false, "无文件信息!"));
  6715. }
  6716. if (dto.Files.Sum(x => x.Length) > 20 * 1024 * 1024)
  6717. {
  6718. return Ok(JsonView(false, "文件大小超过20M!"));
  6719. }
  6720. if (dto.Userid < 1)
  6721. {
  6722. return Ok(JsonView(false, "请传入有效的Userid!"));
  6723. }
  6724. var jobInfo = _sqlSugar.Queryable<Sys_Users, Sys_JobPost>((u, j) => u.JobPostId == j.Id && j.IsDel == 0)
  6725. .Where(u => u.IsDel == 0 && u.Id == dto.Userid)
  6726. .Select((u, j) => new
  6727. {
  6728. u.CnName,
  6729. UserId = u.Id,
  6730. j.JobName,
  6731. })
  6732. .First();
  6733. if (jobInfo == null)
  6734. {
  6735. return Ok(JsonView(false, "请传入有效的Userid!"));
  6736. }
  6737. var commonFileExtensions = new List<string>
  6738. {
  6739. // 文本文件
  6740. ".txt", ".doc", ".docx", ".odt", ".pdf", ".rtf", ".md", ".log",
  6741. // 图片文件
  6742. ".jpg", ".jpeg", ".png", ".gif", ".bmp", ".tiff", ".svg",
  6743. // 视频文件
  6744. ".mp4", ".avi", ".mov", ".mkv", ".wmv", ".flv", ".mpg", ".mpeg",
  6745. // 音频文件
  6746. ".mp3", ".wav", ".ogg", ".aac", ".flac",
  6747. // 压缩文件
  6748. ".zip", ".rar", ".7z", ".tar", ".gz", ".bz2",
  6749. // 数据文件
  6750. ".csv", ".xls", ".xlsx", ".json", ".xml", ".yaml", ".ini",
  6751. };
  6752. try
  6753. {
  6754. var setting = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1416);
  6755. var settingExtend = JsonConvert.DeserializeObject<List<string>>(setting.Remark);
  6756. commonFileExtensions.AddRange(settingExtend);
  6757. }
  6758. catch (Exception)
  6759. { }
  6760. var setdata = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.FileType);
  6761. if (setdata == null)
  6762. {
  6763. return Ok(JsonView(false, "请传入有效的FileType!"));
  6764. }
  6765. var insertList = new List<Grp_GroupShareFile>();
  6766. string winPath = AppSettingsHelper.Get("ShareFileBasePath") + $"{setdata.Name}/";
  6767. if (!Directory.Exists(winPath))
  6768. {
  6769. Directory.CreateDirectory(winPath);
  6770. }
  6771. foreach (var item in dto.Files)
  6772. {
  6773. var houzui = Path.GetExtension(item.FileName);
  6774. if (!commonFileExtensions.Contains(houzui))
  6775. {
  6776. return Ok(JsonView(false, "未知后缀名称!"));
  6777. }
  6778. var fileName = $"{jobInfo.JobName}-{jobInfo.CnName}-{item.FileName}";
  6779. var saveFilePath = winPath + fileName;
  6780. using (FileStream fs = System.IO.File.Create(saveFilePath))
  6781. {
  6782. item.CopyTo(fs);
  6783. fs.Flush();
  6784. }
  6785. var fileDetail = new Grp_GroupShareFile()
  6786. {
  6787. CreateUserId = dto.Userid,
  6788. CreateTime = DateTime.Now,
  6789. UploadJob = jobInfo.JobName,
  6790. FileName = fileName,
  6791. FileType = dto.FileType,
  6792. Diid = dto.Diid,
  6793. FilePath = winPath + fileName,
  6794. };
  6795. insertList.Add(fileDetail);
  6796. }
  6797. _sqlSugar.Insertable<Grp_GroupShareFile>(insertList).ExecuteCommand();
  6798. return Ok(JsonView(true, "保存成功!"));
  6799. }
  6800. /// <summary>
  6801. /// 查询共享文件列表
  6802. /// </summary>
  6803. /// <param name="dto"></param>
  6804. /// <returns></returns>
  6805. [HttpPost]
  6806. public IActionResult QuerySharedFile(QuerySharedFileDto dto)
  6807. {
  6808. var isGroup = new List<int> { 1412 };
  6809. if (!isGroup.Contains(dto.FileType)) dto.Diid = 0;
  6810. var queryExpression = Expressionable.Create<Grp_GroupShareFile>()
  6811. .And(x => x.Diid == dto.Diid)
  6812. .And(x => x.FileType == dto.FileType)
  6813. .And(x => x.IsDel == 0)
  6814. .AndIF(!dto.FileName.IsNullOrWhiteSpace(), x => x.FileName.Contains(dto.FileName))
  6815. .AndIF(DateTime.TryParse(dto.StartTime, out DateTime Start), x => x.CreateTime >= Start)
  6816. .AndIF(DateTime.TryParse(dto.EndTime, out DateTime End), x => x.CreateTime <= End);
  6817. int totalCount = 0;
  6818. var dbQuery = _sqlSugar.Queryable<Grp_GroupShareFile>()
  6819. .Where(queryExpression.ToExpression())
  6820. .OrderBy(x => x.UploadJob)
  6821. .Select(x => new
  6822. {
  6823. x.Id,
  6824. FilePath = AppSettingsHelper.Get("ShareFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("ShareFileBasePath"), AppSettingsHelper.Get("ShareFileFtpPath")),
  6825. x.FileName,
  6826. x.FileType,
  6827. x.CreateTime,
  6828. })
  6829. .ToPageList(dto.PageIndex, dto.PageSize, ref totalCount);
  6830. return Ok(JsonView(true, "SUCCESS!", new
  6831. {
  6832. FileList = dbQuery,
  6833. dto.PageSize,
  6834. dto.PageIndex,
  6835. totalCount
  6836. }));
  6837. }
  6838. /// <summary>
  6839. /// 删除共享文件模块下的指定文件
  6840. /// </summary>
  6841. /// <param name="dto"></param>
  6842. /// <returns></returns>
  6843. [HttpPost]
  6844. public IActionResult DeleteSharedFile(DeleteGroupFileDto dto)
  6845. {
  6846. var jw = JsonView(false);
  6847. var sing = _sqlSugar.Queryable<Grp_GroupShareFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  6848. if (sing == null)
  6849. {
  6850. jw.Msg = "暂无文件信息!";
  6851. return Ok(jw);
  6852. }
  6853. if (sing.CreateUserId != dto.UserId)
  6854. {
  6855. jw.Msg = "只能删除自己上传的文件!";
  6856. return Ok(jw);
  6857. }
  6858. if (System.IO.File.Exists(sing.FilePath))
  6859. {
  6860. try
  6861. {
  6862. System.IO.File.Delete(sing.FilePath);
  6863. }
  6864. catch (Exception ex)
  6865. {
  6866. jw.Msg = "删除失败!" + ex.Message;
  6867. return Ok(jw);
  6868. }
  6869. }
  6870. sing.IsDel = 1;
  6871. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  6872. sing.DeleteUserId = dto.UserId;
  6873. _sqlSugar.Updateable<Grp_GroupShareFile>(sing).ExecuteCommand();
  6874. jw = JsonView(true, "删除成功!");
  6875. return Ok(jw);
  6876. }
  6877. #endregion
  6878. #region 团组英文资料
  6879. /// <summary>
  6880. /// 查询团组英文所有资料
  6881. /// </summary>
  6882. /// <param name="dto"></param>
  6883. /// <returns></returns>
  6884. [HttpPost]
  6885. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6886. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  6887. {
  6888. try
  6889. {
  6890. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  6891. if (groupData.Code != 0)
  6892. {
  6893. return Ok(JsonView(false, groupData.Msg));
  6894. }
  6895. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6896. }
  6897. catch (Exception ex)
  6898. {
  6899. return Ok(JsonView(false, ex.Message));
  6900. throw;
  6901. }
  6902. }
  6903. /// <summary>
  6904. /// 团组英文资料操作(Status:1.新增,2.修改)
  6905. /// </summary>
  6906. /// <param name="dto"></param>
  6907. /// <returns></returns>
  6908. [HttpPost]
  6909. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6910. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  6911. {
  6912. try
  6913. {
  6914. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  6915. if (groupData.Code != 0)
  6916. {
  6917. return Ok(JsonView(false, groupData.Msg));
  6918. }
  6919. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6920. }
  6921. catch (Exception ex)
  6922. {
  6923. return Ok(JsonView(false, ex.Message));
  6924. throw;
  6925. }
  6926. }
  6927. /// <summary>
  6928. /// 团组英文资料Id查询数据
  6929. /// </summary>
  6930. /// <param name="dto"></param>
  6931. /// <returns></returns>
  6932. [HttpPost]
  6933. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6934. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  6935. {
  6936. try
  6937. {
  6938. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  6939. if (_DelegationEnData != null)
  6940. {
  6941. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  6942. }
  6943. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  6944. }
  6945. catch (Exception ex)
  6946. {
  6947. return Ok(JsonView(false, "程序错误!"));
  6948. throw;
  6949. }
  6950. }
  6951. /// <summary>
  6952. /// 团组英文资料删除
  6953. /// </summary>
  6954. /// <param name="dto"></param>
  6955. /// <returns></returns>
  6956. [HttpPost]
  6957. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6958. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  6959. {
  6960. try
  6961. {
  6962. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  6963. if (!res)
  6964. {
  6965. return Ok(JsonView(false, "删除失败"));
  6966. }
  6967. return Ok(JsonView(true, "删除成功!"));
  6968. }
  6969. catch (Exception ex)
  6970. {
  6971. return Ok(JsonView(false, ex.Message));
  6972. throw;
  6973. }
  6974. }
  6975. #endregion
  6976. #region 导出邀请函
  6977. /// <summary>
  6978. /// 导出邀请函页面初始化
  6979. /// </summary>
  6980. /// <param name="dto"></param>
  6981. /// <returns></returns>
  6982. [HttpPost]
  6983. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6984. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  6985. {
  6986. try
  6987. {
  6988. var grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.VisitStartDate, OrderByType.Desc).ToList();
  6989. var crm_Deles = new List<Crm_DeleClient>();
  6990. if (dto.DiId == 0)
  6991. {
  6992. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  6993. }
  6994. else
  6995. {
  6996. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  6997. }
  6998. return Ok(JsonView(true, "查询成功!", new
  6999. {
  7000. deleClient = crm_Deles,
  7001. delegations = grp_Delegations
  7002. }));
  7003. }
  7004. catch (Exception ex)
  7005. {
  7006. return Ok(JsonView(false, "程序错误!"));
  7007. throw;
  7008. }
  7009. }
  7010. /// <summary>
  7011. /// 导出邀请函
  7012. /// </summary>
  7013. /// <param name="dto"></param>
  7014. /// <returns></returns>
  7015. [HttpPost]
  7016. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7017. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  7018. {
  7019. #region 参数验证
  7020. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  7021. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  7022. #endregion
  7023. try
  7024. {
  7025. var transDic = new Dictionary<string, string>();
  7026. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  7027. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  7028. From Grp_TourClientList tcl
  7029. Left Join
  7030. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  7031. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  7032. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  7033. From Crm_DeleClient dc
  7034. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  7035. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  7036. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  7037. Where dc.IsDel = 0) temp
  7038. On temp.DcId =tcl.ClientId
  7039. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  7040. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  7041. var texts = new List<string>();
  7042. if (datas.Count != 0)
  7043. {
  7044. foreach (TourClientListDetailsView item in datas)
  7045. {
  7046. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  7047. {
  7048. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  7049. }
  7050. else
  7051. {
  7052. string name = item.LastName + item.FirstName;
  7053. texts.Add(name);
  7054. }
  7055. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  7056. {
  7057. if (!transDic.ContainsKey(item.Job))
  7058. {
  7059. texts.Add(item.Job);
  7060. }
  7061. }
  7062. if (!string.IsNullOrEmpty(item.CompanyFullName))
  7063. {
  7064. texts.Add(item.CompanyFullName);
  7065. }
  7066. }
  7067. var transData = await _airTicketResRep.ReTransBatch(texts, "en");
  7068. if (transData.Count > 0)
  7069. {
  7070. foreach (TranslateResult item in transData)
  7071. {
  7072. if (!transDic.ContainsKey(item.Query))
  7073. {
  7074. transDic.Add(item.Query, item.Translation);
  7075. }
  7076. }
  7077. }
  7078. var list = new List<GuestList>();
  7079. foreach (var dele in datas)
  7080. {
  7081. var guestList = new GuestList();
  7082. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  7083. {
  7084. guestList.Name = dele.Pinyin;
  7085. }
  7086. else
  7087. {
  7088. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  7089. guestList.Name = Name;
  7090. }
  7091. if (dele.Sex == 0)
  7092. {
  7093. guestList.Sex = "Male";
  7094. }
  7095. else if (dele.Sex == 1)
  7096. {
  7097. guestList.Sex = "Female";
  7098. }
  7099. guestList.DOB = dele.BirthDay.Replace('-', '.');
  7100. if (!string.IsNullOrEmpty(dele.Job))
  7101. {
  7102. guestList.Job = dele.Job;
  7103. }
  7104. list.Add(guestList);
  7105. }
  7106. //载入模板
  7107. var doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  7108. var builder = new DocumentBuilder(doc);
  7109. //获取word里所有表格
  7110. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7111. //获取所填表格的序数
  7112. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  7113. var rowStart = tableOne.Rows[0]; //获取第1行
  7114. //循环赋值
  7115. for (int i = 0; i < list.Count; i++)
  7116. {
  7117. builder.MoveToCell(0, i + 1, 0, 0);
  7118. builder.Write(list[i].Name.ToString());
  7119. builder.MoveToCell(0, i + 1, 1, 0);
  7120. builder.Write(list[i].Sex.ToString());
  7121. builder.MoveToCell(0, i + 1, 2, 0);
  7122. builder.Write(list[i].DOB.ToString());
  7123. builder.MoveToCell(0, i + 1, 3, 0);
  7124. builder.Write(list[i].Job.ToString());
  7125. }
  7126. //删除多余行
  7127. while (tableOne.Rows.Count > list.Count + 1)
  7128. {
  7129. tableOne.Rows.RemoveAt(list.Count + 1);
  7130. }
  7131. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  7132. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  7133. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  7134. doc.Save(filePath);
  7135. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  7136. return Ok(JsonView(true, "操作成功!", Url));
  7137. }
  7138. else
  7139. {
  7140. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  7141. }
  7142. }
  7143. catch (Exception ex)
  7144. {
  7145. return Ok(JsonView(false, ex.Message));
  7146. throw;
  7147. }
  7148. }
  7149. #endregion
  7150. #region 团组经理模块 出入境费用
  7151. /// <summary>
  7152. /// 团组模块 - 出入境费用 - 省份基础数据源
  7153. /// </summary>
  7154. /// <returns></returns>
  7155. [HttpGet]
  7156. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7157. public async Task<IActionResult> GetEnterExitProvBelongCostDataSource()
  7158. {
  7159. return Ok(JsonView(await _groupRepository.ProvinceBasicSource()));
  7160. }
  7161. /// <summary>
  7162. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  7163. /// </summary>
  7164. /// <param name="dto"></param>
  7165. /// <returns></returns>
  7166. [HttpPost]
  7167. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7168. public async Task<IActionResult> GetEnterExitCostDataSource(EnterExitCostDataSourceDto dto)
  7169. {
  7170. var groupNameData = await _groupRepository.EnterExitCostGroupNameAsync();
  7171. var groupNamFirst = groupNameData.FirstOrDefault();
  7172. //SetDataInfoView
  7173. var dataSource = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  7174. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  7175. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  7176. //验证城市归属并给默认值
  7177. int provinceId = 122;
  7178. if (groupNamFirst != null) provinceId = groupNamFirst.ProvinceId;
  7179. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostRep.FileOwner(provinceId);
  7180. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  7181. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  7182. return Ok(JsonView(true, "查询成功!", new
  7183. {
  7184. GroupNameData = groupNameData,
  7185. CurrencyData = _CurrencyData,
  7186. WordTypeData = wordTypeData,
  7187. ExcelTypeData = excelTypeData,
  7188. CurrencyInit = _currencyInfos,
  7189. ViewPermissionData = viewPermissionData
  7190. }));
  7191. }
  7192. /// <summary>
  7193. /// 团组模块 - 出入境费用 - 文件类型list 跟据省份Id获取
  7194. /// </summary>
  7195. /// <returns></returns>
  7196. [HttpGet("{provinceId}")]
  7197. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7198. public async Task<IActionResult> EnterExitCostFileOwner([FromRoute] int provinceId = 122)
  7199. {
  7200. //验证城市归属并给默认值
  7201. if (provinceId < 1) provinceId = 122;
  7202. /*
  7203. * 122 四川
  7204. * 108 贵州
  7205. * 103 重庆
  7206. * 132 云南
  7207. */
  7208. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostDraftRep.FileOwner(provinceId);
  7209. return Ok(JsonView(true, "查询成功!", new
  7210. {
  7211. WordTypeData = wordTypeData,
  7212. ExcelTypeData = excelTypeData,
  7213. }));
  7214. }
  7215. /// <summary>
  7216. /// 团组模块 - 出入境费用
  7217. /// 实时汇率 tips
  7218. /// 签证费用 tips
  7219. /// 机票费用 tips
  7220. /// </summary>
  7221. /// <returns></returns>
  7222. [HttpPost]
  7223. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7224. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  7225. {
  7226. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  7227. //默认币种显示
  7228. var reteInfos = await GeneralMethod.EnterExitCostLiveRate();
  7229. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.DiId);
  7230. var airData = await GeneralMethod.EntryAndExitTips(dto.DiId);
  7231. return Ok(JsonView(true, "查询成功!", new
  7232. {
  7233. //GroupNameData = groupNameData.Data,
  7234. visaData = visaData.Data,
  7235. airData,
  7236. reteInfos
  7237. }));
  7238. }
  7239. /// <summary>
  7240. /// 团组模块 - 出入境费用 - Info
  7241. /// </summary>
  7242. /// <param name="dto"></param>
  7243. /// <returns></returns>
  7244. [HttpPost]
  7245. //[ApiLog("Grp_EnterExitCost", OperationEnum.Details)]
  7246. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7247. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  7248. {
  7249. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7250. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7251. return Ok(await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto));
  7252. }
  7253. /// <summary>
  7254. /// 团组模块 - 出入境费用 - 设置view权限
  7255. /// </summary>
  7256. /// <returns></returns>
  7257. [HttpPost]
  7258. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7259. public async Task<IActionResult> EnterExitCostSetViewPermissiion(EnterExitCostSetViewPermissiionDto dto)
  7260. {
  7261. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7262. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7263. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  7264. var permissions = new List<Grp_EnterExitCostPermission>();
  7265. foreach (var userId in dto.UserIds)
  7266. {
  7267. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.GroupId, UserId = userId, CreateUserId = dto.CurrUserId });
  7268. }
  7269. if (permissions.Any())
  7270. {
  7271. _sqlSugar.BeginTran();
  7272. try
  7273. {
  7274. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.GroupId).ExecuteCommandAsync();
  7275. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  7276. if (result < 1)
  7277. {
  7278. _sqlSugar.RollbackTran();
  7279. return Ok(JsonView(false));
  7280. }
  7281. }
  7282. catch (Exception ex)
  7283. {
  7284. _sqlSugar.RollbackTran();
  7285. return Ok(JsonView(false, ex.Message));
  7286. }
  7287. _sqlSugar.CommitTran();
  7288. return Ok(JsonView(true));
  7289. }
  7290. return Ok(JsonView(false));
  7291. }
  7292. /// <summary>
  7293. /// 团组模块 - 出入境费用 - Add And Update
  7294. /// </summary>
  7295. /// <returns></returns>
  7296. [HttpPost]
  7297. [ApiLog("Grp_EnterExitCost", OperationEnum.Add)]
  7298. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7299. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  7300. {
  7301. try
  7302. {
  7303. var rateRecords = new List<RateRecordInfo>();
  7304. #region 汇率保存前存储
  7305. var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(x => x.IsDel == 0 && x.DiId == dto.DiId);
  7306. if (info != null)
  7307. {
  7308. var cacheRateInfos = CommonFun.GetCurrencyChinaToList(info.CurrencyRemark);
  7309. if (cacheRateInfos != null && cacheRateInfos.Count > 0)
  7310. {
  7311. rateRecords = cacheRateInfos.Select(x => new RateRecordInfo()
  7312. {
  7313. CurrencyCode = x.CurrencyCode,
  7314. CurrencyName = x.CurrencyName,
  7315. UpdatePreRate = x.Rate,
  7316. UpdateBreRate = dto.Currencys.Where(x1 => x1.CurrencyName.Equals(x.CurrencyName)).FirstOrDefault()?.Rate ?? 0.00M
  7317. }).ToList();
  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. }
  7330. else
  7331. {
  7332. rateRecords = dto.Currencys.Select(x => new RateRecordInfo()
  7333. {
  7334. CurrencyCode = x.CurrencyCode,
  7335. CurrencyName = x.CurrencyName,
  7336. UpdatePreRate = 0.00M,
  7337. UpdateBreRate = x.Rate
  7338. }).ToList();
  7339. }
  7340. #endregion
  7341. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  7342. if (dto.DayOtherPriceData.Any())
  7343. {
  7344. var inserList = dto.DayOtherPriceData
  7345. .Where(x => x.Id == 0)
  7346. .Select(x => new Grp_DayOtherPrice
  7347. {
  7348. Cost = x.Cost,
  7349. Id = x.Id,
  7350. CreateTime = DateTime.Now,
  7351. CreateUserId = dto.UserId,
  7352. Currency = x.Currency,
  7353. Diid = x.DiId,
  7354. Index = x.Index,
  7355. IsDel = 0,
  7356. SetDataId = x.SetDataId,
  7357. SubTotal = x.SubTotal,
  7358. Remark = x.Remark
  7359. })
  7360. .ToList();
  7361. var updateList = dto.DayOtherPriceData
  7362. .Where(x => x.Id != 0)
  7363. .Select(x => new Grp_DayOtherPrice
  7364. {
  7365. Cost = x.Cost,
  7366. Id = x.Id,
  7367. CreateTime = DateTime.Now,
  7368. CreateUserId = dto.UserId,
  7369. Currency = x.Currency,
  7370. Diid = x.DiId,
  7371. Index = x.Index,
  7372. IsDel = 0,
  7373. SetDataId = x.SetDataId,
  7374. SubTotal = x.SubTotal,
  7375. Remark = x.Remark
  7376. })
  7377. .ToList();
  7378. //添加
  7379. _sqlSugar.BeginTran();
  7380. if (inserList.Any())
  7381. {
  7382. var rowCount = _sqlSugar.Insertable<Grp_DayOtherPrice>(inserList).ExecuteCommand();
  7383. }
  7384. if (updateList.Any())
  7385. {
  7386. var rowCount = _sqlSugar.Updateable<Grp_DayOtherPrice>(updateList).ExecuteCommand();
  7387. }
  7388. _sqlSugar.CommitTran();
  7389. }
  7390. if (data.Code != 0)
  7391. {
  7392. return Ok(JsonView(false, data.Msg));
  7393. }
  7394. //生成默认文件pdf并且通知人员
  7395. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  7396. {
  7397. DiId = dto.DiId,
  7398. ExportType = 1,
  7399. SubTypeId = 1005
  7400. }, "pdf");
  7401. //发送通知
  7402. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  7403. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  7404. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  7405. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign, fileUrl);
  7406. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  7407. //汇率信息记录
  7408. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  7409. var checkCurrencys = await _enterExitCostRep.GetCheckCurrencies(dto.DiId);
  7410. //汇率验证、反推
  7411. (bool isSendMsg, string msgContent, List<CurrencyInfo> liveRates) = await GeneralMethod.EnterExitCostCheckRate(dto.DiId, checkCurrencys);
  7412. if (isSendMsg)
  7413. {
  7414. //消息推送
  7415. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFin(dto.DiId, dto.UserId, msgContent);
  7416. }
  7417. #region //日志汇率记录
  7418. //按照已使用币种记录
  7419. if (checkCurrencys != null && checkCurrencys.Count > 0)
  7420. {
  7421. rateRecords = rateRecords.Where(x => checkCurrencys.Select(x1 => x1.CurrencyName).ToList().Contains(x.CurrencyName)).ToList();
  7422. //汇率记录中加入实时汇率
  7423. if (liveRates != null && liveRates.Count > 0)
  7424. {
  7425. foreach (var item in rateRecords)
  7426. {
  7427. item.CurrLiveRate = liveRates.Where(x => x.CurrencyName.Equals(item.CurrencyName)).FirstOrDefault()?.Rate ?? 0.00M;
  7428. }
  7429. }
  7430. var teamName = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.Id == dto.DiId && x.IsDel == 0).Select(x => x.TeamName).FirstAsync();
  7431. var operationName = await _sqlSugar.Queryable<Sys_Users>().Where(x => x.Id == dto.UserId && x.IsDel == 0).Select(x => x.CnName).FirstAsync();
  7432. var logContent = new StringBuilder();
  7433. foreach (var item in rateRecords)
  7434. {
  7435. var blRate = (item.CurrLiveRate * 1.0350M).TruncDecimals(4);
  7436. string msg = $">- {item.CurrencyName}汇率:(页面保存前){item.UpdatePreRate:#0.0000}/(页面保存){item.UpdateBreRate:#0.0000}/实时汇率(已上浮1.0350):{blRate:#0.0000}【注:原接口输出汇率为:{item.CurrLiveRate:#0.0000}】";
  7437. logContent.AppendLine(msg);
  7438. }
  7439. _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());
  7440. }
  7441. #endregion
  7442. return Ok(JsonView(true, data.Msg, data.Data));
  7443. }
  7444. catch (Exception ex)
  7445. {
  7446. return Ok(JsonView(false, ex.Message));
  7447. }
  7448. }
  7449. /// <summary>
  7450. /// 团组模块 - 出入境费用 - Confirm 费用
  7451. /// </summary>
  7452. /// <returns></returns>
  7453. [HttpPost]
  7454. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7455. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  7456. {
  7457. //TODO:测试完毕需把对应的用户ID更改
  7458. //1、数据表添加字段
  7459. //2、更改字段接口()
  7460. var _view = await _enterExitCostRep.ConfirmCost(dto);
  7461. //3、确认成功 给财务发送消息
  7462. if (_view.Code == 200)
  7463. {
  7464. if (dto.Type == 1)
  7465. {
  7466. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  7467. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  7468. }
  7469. }
  7470. return Ok(_view);
  7471. }
  7472. /// <summary>
  7473. /// 团组模块 - 出入境费用 - File download
  7474. /// </summary>
  7475. /// <param name="dto"></param>
  7476. /// <returns></returns>
  7477. [HttpPost]
  7478. //[ApiLog("Grp_EnterExitCost", OperationEnum.Download)]
  7479. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7480. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  7481. {
  7482. try
  7483. {
  7484. if (dto.DiId < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  7485. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  7486. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  7487. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  7488. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  7489. 3 团组成员名单 1 团组成员名单", ""));
  7490. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).OrderByDescending(x => x.CreateTime).First();
  7491. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  7492. if (_EnterExitCosts == null) return Ok(JsonView(400, "该团组未填写出入境费用;", ""));
  7493. var currencyInit = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToList();
  7494. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  7495. //数据源
  7496. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  7497. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  7498. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  7499. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  7500. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  7501. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  7502. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  7503. .Where((x, a, b) => x.IsDel == 0 && x.Diid == dto.DiId)
  7504. .Select((x, a, b) => new
  7505. {
  7506. x.Index,
  7507. itemName = a.Name,
  7508. CurrencyStr = b.Name,
  7509. x.Cost,
  7510. x.SubTotal,
  7511. x.Remark
  7512. })
  7513. .OrderBy((x) => x.Index)
  7514. .ToList(); //其他款项费用
  7515. var peiceItemCurrencys = new List<string>();
  7516. if (_DayAndCosts.Any())
  7517. {
  7518. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  7519. if (currencyIds.Any()) peiceItemCurrencys.AddRange(currencyInit.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  7520. }
  7521. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  7522. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  7523. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  7524. {
  7525. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  7526. }
  7527. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  7528. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  7529. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  7530. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  7531. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  7532. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  7533. .Select((tcl, dc, cc) => new ClientInfo
  7534. {
  7535. LastName = dc.LastName,
  7536. FirstName = dc.FirstName,
  7537. Sex = dc.Sex,
  7538. Birthday = dc.BirthDay,
  7539. Company = cc.CompanyFullName,
  7540. Job = dc.Job
  7541. })
  7542. .ToList();
  7543. foreach (var item in DeleClientList)
  7544. {
  7545. EncryptionProcessor.DecryptProperties(item);
  7546. }
  7547. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  7548. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  7549. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  7550. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  7551. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  7552. if (dto.ExportType == 1) //明细表
  7553. {
  7554. if (dto.SubTypeId == 1005) //1005(默认明细表)
  7555. {
  7556. //获取模板
  7557. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  7558. //载入模板
  7559. var doc = new Document(tempPath);
  7560. var builder = new DocumentBuilder(doc);
  7561. var dic = new Dictionary<string, string>();
  7562. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  7563. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  7564. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  7565. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  7566. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  7567. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  7568. //境内费用(其他费用)
  7569. if (_EnterExitCosts.ChoiceOne == 1)
  7570. {
  7571. string row1_1 = "";
  7572. if (_EnterExitCosts.Visa > 0)
  7573. {
  7574. //insidePayTotal += _EnterExitCosts.Visa;
  7575. row1_1 = $"签证费:{_EnterExitCosts.Visa:#0.00} 元/人";
  7576. //if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  7577. //{
  7578. // row1_1 += $"\t签证费用描述: {_EnterExitCosts.VisaRemark} 人民币/人";
  7579. //}
  7580. }
  7581. string row1_2 = "";
  7582. if (_EnterExitCosts.YiMiao > 0)
  7583. {
  7584. //insidePayTotal += _EnterExitCosts.YiMiao;
  7585. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00} 元/人";
  7586. }
  7587. if (_EnterExitCosts.HeSuan > 0)
  7588. {
  7589. //insidePayTotal += _EnterExitCosts.HeSuan;
  7590. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan:#0.00} 元/人";
  7591. }
  7592. if (_EnterExitCosts.Service > 0)
  7593. {
  7594. //insidePayTotal += _EnterExitCosts.Service;
  7595. row1_2 += $"服务费:{_EnterExitCosts.Service:#0.00} 元/人";
  7596. }
  7597. string row1_3 = "";
  7598. if (_EnterExitCosts.Safe > 0)
  7599. {
  7600. //insidePayTotal += _EnterExitCosts.Safe;
  7601. row1_3 += $"保险费:{_EnterExitCosts.Safe:#0.00} 元/人";
  7602. }
  7603. if (_EnterExitCosts.Ticket > 0)
  7604. {
  7605. //insidePayTotal += _EnterExitCosts.Ticket;
  7606. row1_3 += $"参展门票:{_EnterExitCosts.Ticket:#0.00} 元/人";
  7607. }
  7608. string row1 = "";
  7609. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  7610. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  7611. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  7612. row1 += $"备注:{_EnterExitCosts.Remark}";
  7613. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  7614. dic.Add("Row1Str", row1);
  7615. }
  7616. string airTotalStr = string.Empty,
  7617. airPriceStr = string.Empty;
  7618. //经济舱
  7619. if (_EnterExitCosts.SumJJC == 1)
  7620. {
  7621. airTotalStr += $"{_EnterExitCosts.OutsideJJPay:#0.00}元/人(经济舱)";
  7622. airPriceStr += $"{_EnterExitCosts.AirJJ:#0.00}元/人(经济舱)";
  7623. }
  7624. //公务舱
  7625. if (_EnterExitCosts.SumGWC == 1)
  7626. {
  7627. airTotalStr += $" {_EnterExitCosts.OutsideGWPay:#0.00} 元/人(公务舱)";
  7628. airPriceStr += $" {_EnterExitCosts.AirGW:#0.00} 元/人(公务舱)";
  7629. }
  7630. //头等舱
  7631. if (_EnterExitCosts.SumTDC == 1)
  7632. {
  7633. airTotalStr += $" {_EnterExitCosts.OutsideTDPay:#0.00} 元/人(头等舱)";
  7634. airPriceStr += $" {_EnterExitCosts.AirTD:#0.00} 元/人(头等舱)";
  7635. }
  7636. //汇率描述
  7637. string rateStr = "";
  7638. if (peiceItemCurrencyInfos.Any())
  7639. {
  7640. rateStr = "\r\n汇率描述:";
  7641. foreach (var item in peiceItemCurrencyInfos)
  7642. {
  7643. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate:#0.0000} ";
  7644. }
  7645. }
  7646. string twoItemRemark = "备注:";
  7647. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  7648. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  7649. dic.Add("AirTotalStr", airTotalStr);
  7650. dic.Add("AirPriceStr", airPriceStr);
  7651. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  7652. dic.Add("TwoItemRemark", twoItemRemark);
  7653. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7654. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7655. int table1Row = 0,
  7656. table2Row = 0,
  7657. table3Row = 0,
  7658. table4Row = 0,
  7659. table5Row = 0;
  7660. //住宿费
  7661. if (_EnterExitCosts.ChoiceThree == 1)
  7662. {
  7663. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  7664. table1Row = dac1.Count;
  7665. #region 填充word表格内容
  7666. for (int i = 0; i < dac1.Count; i++)
  7667. {
  7668. Grp_DayAndCost dac = dac1[i];
  7669. if (dac == null) continue;
  7670. builder.MoveToCell(0, i, 0, 0);
  7671. builder.Write("第" + dac.Days.ToString() + "晚:");
  7672. builder.MoveToCell(0, i, 1, 0);
  7673. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  7674. //builder.Write(dac.Place == null ? "" : dac.Place);
  7675. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7676. builder.MoveToCell(0, i, 2, 0);
  7677. builder.Write("费用标准:");
  7678. string curr = "";
  7679. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  7680. if (currData != null)
  7681. {
  7682. curr = currData.Name;
  7683. }
  7684. builder.MoveToCell(0, i, 3, 0);
  7685. builder.Write(dac.Cost.ToString("#0.00") + curr);
  7686. builder.MoveToCell(0, i, 4, 0);
  7687. builder.Write("费用小计:");
  7688. builder.MoveToCell(0, i, 5, 0);
  7689. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7690. }
  7691. #endregion
  7692. }
  7693. else dic.Add("SubZS", "0.00");
  7694. //删除多余行
  7695. while (table1.Rows.Count > table1Row)
  7696. {
  7697. table1.Rows.RemoveAt(table1Row);
  7698. }
  7699. //伙食费
  7700. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  7701. if (_EnterExitCosts.ChoiceFour == 1)
  7702. {
  7703. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  7704. table2Row = dac2.Count;
  7705. #region 填充word表格内容
  7706. for (int i = 0; i < dac2.Count; i++)
  7707. {
  7708. Grp_DayAndCost dac = dac2[i];
  7709. if (dac == null) continue;
  7710. builder.MoveToCell(1, i, 0, 0);
  7711. builder.Write("第" + dac.Days.ToString() + "天:");
  7712. builder.MoveToCell(1, i, 1, 0);
  7713. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7714. builder.MoveToCell(1, i, 2, 0);
  7715. builder.Write("费用标准:");
  7716. string curr = "";
  7717. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  7718. if (currData != null)
  7719. {
  7720. curr = currData.Name;
  7721. }
  7722. builder.MoveToCell(1, i, 3, 0);
  7723. builder.Write(dac.Cost.ToString("#0.00") + curr);
  7724. builder.MoveToCell(1, i, 4, 0);
  7725. builder.Write("费用小计:");
  7726. builder.MoveToCell(1, i, 5, 0);
  7727. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7728. }
  7729. #endregion
  7730. }
  7731. else dic.Add("SubHS", "0.00");
  7732. //删除多余行
  7733. while (table2.Rows.Count > table2Row)
  7734. {
  7735. table2.Rows.RemoveAt(table2Row);
  7736. }
  7737. //公杂费
  7738. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  7739. if (_EnterExitCosts.ChoiceFive == 1)
  7740. {
  7741. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  7742. table3Row = dac3.Count;
  7743. #region 填充word表格内容
  7744. for (int i = 0; i < dac3.Count; i++)
  7745. {
  7746. Grp_DayAndCost dac = dac3[i];
  7747. if (dac == null) continue;
  7748. builder.MoveToCell(2, i, 0, 0);
  7749. builder.Write("第" + dac.Days.ToString() + "天:");
  7750. builder.MoveToCell(2, i, 1, 0);
  7751. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7752. builder.MoveToCell(2, i, 2, 0);
  7753. builder.Write("费用标准:");
  7754. string curr = "";
  7755. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  7756. if (currData != null)
  7757. {
  7758. curr = currData.Name;
  7759. }
  7760. builder.MoveToCell(2, i, 3, 0);
  7761. builder.Write(dac.Cost.ToString("#0.00") + curr);
  7762. builder.MoveToCell(2, i, 4, 0);
  7763. builder.Write("费用小计:");
  7764. builder.MoveToCell(2, i, 5, 0);
  7765. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7766. }
  7767. //删除多余行
  7768. while (table3.Rows.Count > table3Row)
  7769. {
  7770. table3.Rows.RemoveAt(table3Row);
  7771. }
  7772. #endregion
  7773. }
  7774. else dic.Add("SubGZF", "0.00");
  7775. //删除多余行
  7776. while (table3.Rows.Count > table3Row)
  7777. {
  7778. table3.Rows.RemoveAt(table3Row);
  7779. }
  7780. //培训费
  7781. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  7782. if (_EnterExitCosts.ChoiceSix == 1)
  7783. {
  7784. string pxStr = $"六、培训费合计: {tainFeeTotal:#0.00} 元/人";
  7785. dic.Add("SubPX", pxStr);
  7786. table4Row = dac4.Count;
  7787. #region 填充word表格内容
  7788. for (int i = 0; i < dac4.Count; i++)
  7789. {
  7790. Grp_DayAndCost dac = dac4[i];
  7791. if (dac == null) continue;
  7792. builder.MoveToCell(3, i, 0, 0);
  7793. builder.Write("第" + dac.Days.ToString() + "天:");
  7794. builder.MoveToCell(3, i, 1, 0);
  7795. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7796. builder.MoveToCell(3, i, 2, 0);
  7797. builder.Write("费用标准:");
  7798. string curr = "";
  7799. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  7800. if (currData != null)
  7801. {
  7802. curr = currData.Name;
  7803. }
  7804. builder.MoveToCell(3, i, 3, 0);
  7805. builder.Write(dac.Cost.ToString("#0.00") + curr);
  7806. builder.MoveToCell(3, i, 4, 0);
  7807. builder.Write("费用小计:");
  7808. builder.MoveToCell(3, i, 5, 0);
  7809. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7810. }
  7811. #endregion
  7812. }
  7813. //else dic.Add("SubPX", $"六、培训费合计: 0.00 元/人");
  7814. //删除多余行
  7815. while (table4.Rows.Count > table4Row)
  7816. {
  7817. table4.Rows.RemoveAt(table4Row);
  7818. }
  7819. //其他费用
  7820. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  7821. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  7822. {
  7823. string qtStr = $"七、其他费用合计: {otherPriceTotal:#0.00} 元/人";
  7824. dic.Add("titleQi", qtStr);
  7825. table5Row = dac5.Count;
  7826. #region 填充word表格内容
  7827. for (int i = 0; i < dac5.Count; i++)
  7828. {
  7829. var dac = dac5[i];
  7830. if (dac == null) continue;
  7831. builder.MoveToCell(4, i, 0, 0);
  7832. builder.Write("第" + dac.Index.ToString() + "项:");
  7833. builder.MoveToCell(4, i, 1, 0);
  7834. builder.Write(dac.itemName);
  7835. builder.MoveToCell(4, i, 2, 0);
  7836. builder.Write("费用标准:");
  7837. builder.MoveToCell(4, i, 3, 0);
  7838. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  7839. builder.MoveToCell(4, i, 4, 0);
  7840. builder.Write("费用小计:");
  7841. builder.MoveToCell(4, i, 5, 0);
  7842. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7843. builder.MoveToCell(4, i, 6, 0);
  7844. builder.Write("备注:");
  7845. builder.MoveToCell(4, i, 7, 0);
  7846. builder.Write(dac.Remark);
  7847. }
  7848. #endregion
  7849. }
  7850. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  7851. //删除多余行
  7852. while (table5.Rows.Count > table5Row)
  7853. {
  7854. table5.Rows.RemoveAt(table5Row);
  7855. }
  7856. //加上其他费用
  7857. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  7858. decimal subJJC = 0.00M,
  7859. subGWC = 0.00M,
  7860. subTDC = 0.00M;
  7861. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  7862. string totalLabel = string.Format("全部费用总计:");
  7863. //经济舱
  7864. if (_EnterExitCosts.SumJJC == 1)
  7865. {
  7866. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  7867. totalLabel += $"{subJJC:#0.00} 元/人(经济舱)";
  7868. }
  7869. //公务舱
  7870. if (_EnterExitCosts.SumGWC == 1)
  7871. {
  7872. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  7873. totalLabel += $"{subGWC:#0.00} 元/人(公务舱)";
  7874. }
  7875. //头等舱
  7876. if (_EnterExitCosts.SumTDC == 1)
  7877. {
  7878. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  7879. totalLabel += $"{subTDC:#0.00} 元/人(头等舱)";
  7880. }
  7881. //TotalLabel
  7882. dic.Add("TotalLabel", totalLabel);
  7883. //dic.Add("SubJJC", subJJC.ToString("#0.00"));
  7884. //dic.Add("SubGWC", subGWC.ToString("#0.00"));
  7885. //dic.Add("SubTDC", subTDC.ToString("#0.00"));
  7886. #region 填充word模板书签内容
  7887. foreach (var key in dic.Keys)
  7888. {
  7889. Bookmark bookmark = doc.Range.Bookmarks[key];
  7890. if (bookmark != null)
  7891. {
  7892. builder.MoveToBookmark(key);
  7893. builder.Write(dic[key]);
  7894. }
  7895. }
  7896. #endregion
  7897. #region 设置页眉
  7898. string userLabel = string.Empty;
  7899. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  7900. if (currUserInfo != null)
  7901. {
  7902. var userInfo = await _usersRep.GetUserBriefInfo(currUserInfo.UserId);
  7903. if (userInfo != null)
  7904. {
  7905. string ext = string.IsNullOrEmpty(userInfo.ExtensionNumber) ? "-" : userInfo.ExtensionNumber;
  7906. //userLabel = $"联系人:{userInfo.Name} 职位:{userInfo.Job}\r\n座机/分机号:{ext} 手机号:{userInfo.Tel} 公司邮箱:{userInfo.Email}";
  7907. userLabel = $"联系人:{userInfo.Name} 职 位:{userInfo.Job} 手机号:{userInfo.Tel}\r\n公司邮箱:{userInfo.Email}";
  7908. }
  7909. }
  7910. //设置页脚
  7911. //GeneralMethod.AsposeWordSetFooter(builder, userLabel, "华文仿宋", 10);
  7912. #endregion
  7913. var guid = CommonFun.GUID.Substring(0, 8);
  7914. //文件名
  7915. string strFileName = CommonFun.ValidFileName($"{_DelegationInfo.TeamName}出入境费用{guid}.docx");
  7916. AsposeHelper.removewatermark_v2180();
  7917. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7918. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7919. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7920. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7921. }
  7922. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  7923. {
  7924. //获取模板
  7925. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  7926. //载入模板
  7927. var doc = new Document(tempPath);
  7928. var builder = new DocumentBuilder(doc);
  7929. var dic = new Dictionary<string, string>();
  7930. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  7931. {
  7932. var list = new List<string>();
  7933. try
  7934. {
  7935. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  7936. foreach (var item in spilitArr)
  7937. {
  7938. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  7939. var depCode = spDotandEmpty[2].Substring(0, 3);
  7940. var arrCode = spDotandEmpty[2].Substring(3, 3);
  7941. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  7942. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  7943. list.Add(depName);
  7944. list.Add(arrName);
  7945. }
  7946. list = list.Distinct().ToList();
  7947. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  7948. }
  7949. catch (Exception)
  7950. {
  7951. dic.Add("ReturnCode", "行程录入不正确!");
  7952. }
  7953. }
  7954. else
  7955. {
  7956. dic.Add("ReturnCode", "未录入行程!");
  7957. }
  7958. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  7959. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  7960. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  7961. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  7962. {
  7963. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  7964. dic.Add("Day", sp.Days.ToString());
  7965. }
  7966. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7967. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  7968. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  7969. //dic.Add("Names", Names);
  7970. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7971. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7972. decimal dac1totalPrice = 0.00M;
  7973. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  7974. foreach (var dac in dac1)
  7975. {
  7976. if (dac.SubTotal == 0.00M)
  7977. {
  7978. continue;
  7979. }
  7980. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  7981. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  7982. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7983. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7984. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  7985. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  7986. builder.Write(currency);//币种
  7987. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  7988. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7989. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  7990. builder.Write("");//人数
  7991. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  7992. builder.Write("");//天数
  7993. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  7994. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7995. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  7996. decimal rate = 0.00M;
  7997. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  7998. builder.Write(rate.ToString("#0.0000"));//汇率
  7999. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  8000. decimal rbmPrice = dac.SubTotal;
  8001. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  8002. accommodationStartIndex++;
  8003. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  8004. }
  8005. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  8006. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  8007. {
  8008. table1.Rows.RemoveAt(i - 1);
  8009. foodandotherStartIndex--;
  8010. }
  8011. if (dac2.Count == dac3.Count)//国家 币种 金额
  8012. {
  8013. for (int i = 0; i < dac2.Count; i++)
  8014. {
  8015. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  8016. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  8017. }
  8018. }
  8019. decimal dac2totalPrice = 0.00M;
  8020. foreach (var dac in dac2)
  8021. {
  8022. if (dac.SubTotal == 0)
  8023. {
  8024. continue;
  8025. }
  8026. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  8027. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  8028. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  8029. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  8030. builder.Write(currency);//币种
  8031. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  8032. builder.Write(dac.Cost.ToString("#0.00"));//标准
  8033. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  8034. builder.Write("");//人数
  8035. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  8036. builder.Write("");//天数
  8037. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  8038. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  8039. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  8040. decimal rate = 0.00M;
  8041. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  8042. builder.Write(rate.ToString("#0.0000"));//汇率
  8043. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  8044. decimal rbmPrice = dac.SubTotal;
  8045. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  8046. foodandotherStartIndex++;
  8047. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  8048. }
  8049. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  8050. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  8051. {
  8052. table1.Rows.RemoveAt(i - 1);
  8053. }
  8054. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  8055. string otherFeeStr = "";
  8056. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa:#0.00} 元,";
  8057. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe:#0.00} 元,";
  8058. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00} 元,";
  8059. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  8060. foreach (var otherInfo in dac5)
  8061. {
  8062. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  8063. }
  8064. #endregion
  8065. if (otherFeeStr.Length > 0)
  8066. {
  8067. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  8068. otherFeeStr = $"({otherFeeStr})";
  8069. dic.Add("OtherFeeStr", otherFeeStr);
  8070. }
  8071. //总计
  8072. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  8073. //国际旅费
  8074. string outsideAir = string.Empty;
  8075. string allPriceAir = string.Empty;
  8076. if (_EnterExitCosts.SumJJC == 1)
  8077. {
  8078. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  8079. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  8080. }
  8081. if (_EnterExitCosts.SumGWC == 1)
  8082. {
  8083. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  8084. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  8085. }
  8086. if (_EnterExitCosts.SumTDC == 1)
  8087. {
  8088. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  8089. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  8090. }
  8091. dic.Add("InTravelPrice", $"({outsideAir})");
  8092. dic.Add("FinalSumPrice", $"({allPriceAir})");
  8093. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  8094. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  8095. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  8096. foreach (var key in dic.Keys)
  8097. {
  8098. builder.MoveToBookmark(key);
  8099. builder.Write(dic[key]);
  8100. }
  8101. //模板文件名
  8102. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  8103. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8104. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8105. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8106. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8107. }
  8108. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  8109. {
  8110. //获取模板
  8111. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  8112. //载入模板
  8113. var designer = new WorkbookDesigner
  8114. {
  8115. Workbook = new Workbook(tempPath)
  8116. };
  8117. var dic = new Dictionary<string, string>();
  8118. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  8119. {
  8120. var list = new List<string>();
  8121. try
  8122. {
  8123. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  8124. foreach (var item in spilitArr)
  8125. {
  8126. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  8127. var depCode = spDotandEmpty[2].Substring(0, 3);
  8128. var arrCode = spDotandEmpty[2].Substring(3, 3);
  8129. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  8130. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  8131. list.Add(depName);
  8132. list.Add(arrName);
  8133. }
  8134. list = list.Distinct().ToList();
  8135. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  8136. }
  8137. catch (Exception)
  8138. {
  8139. dic.Add("ReturnCode", "行程录入不正确!");
  8140. }
  8141. }
  8142. else
  8143. {
  8144. dic.Add("ReturnCode", "未录入行程!");
  8145. }
  8146. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  8147. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  8148. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  8149. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  8150. {
  8151. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  8152. dic.Add("Day", sp.Days.ToString());
  8153. }
  8154. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  8155. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  8156. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  8157. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  8158. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  8159. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  8160. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  8161. designer.SetDataSource("Name", Names);
  8162. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  8163. designer.SetDataSource("Day", dic["Day"] + "天");
  8164. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  8165. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  8166. int startIndex = 10;
  8167. const int startIndexcopy = 10;
  8168. if (dac2.Count == dac3.Count)//国家 币种 金额
  8169. {
  8170. for (int i = 0; i < dac2.Count; i++)
  8171. {
  8172. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  8173. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  8174. }
  8175. }
  8176. var dtdac1 = new DataTable();
  8177. var place = new List<string>();
  8178. dtdac1.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. var dtdac2 = new DataTable();
  8189. dtdac2.Columns.AddRange(new DataColumn[] {
  8190. new(){ ColumnName = "city"},
  8191. new(){ ColumnName = "curr"},
  8192. new(){ ColumnName = "criterion"},
  8193. new(){ ColumnName = "number",DataType = typeof(int)},
  8194. new(){ ColumnName = "day",DataType = typeof(int)},
  8195. new(){ ColumnName = "cost", DataType = typeof(decimal)},
  8196. new(){ ColumnName = "rate", DataType = typeof(decimal) },
  8197. new(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  8198. });
  8199. dtdac1.TableName = "tb1";
  8200. dtdac2.TableName = "tb2";
  8201. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  8202. foreach (var item in dac1)
  8203. {
  8204. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  8205. if (place.Contains(item.Place))
  8206. {
  8207. continue;
  8208. }
  8209. DataRow row = dtdac1.NewRow();
  8210. row["city"] = item.Place;
  8211. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  8212. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  8213. row["curr"] = currency;
  8214. row["rate"] = rate.ToString("#0.0000");
  8215. row["criterion"] = item.Cost.ToString("#0.00");
  8216. row["number"] = 1;
  8217. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  8218. //row["costRMB"] = rbmPrice;
  8219. dtdac1.Rows.Add(row);
  8220. place.Add(item.Place);
  8221. }
  8222. place = new List<string>();
  8223. foreach (var item in dac2)
  8224. {
  8225. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  8226. if (place.Contains(item.Place))
  8227. {
  8228. continue;
  8229. }
  8230. DataRow row = dtdac2.NewRow();
  8231. row["city"] = item.Place;
  8232. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  8233. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  8234. row["curr"] = currency;
  8235. row["rate"] = rate.ToString("#0.0000");
  8236. row["criterion"] = item.Cost.ToString("#0.00");
  8237. row["number"] = 1;
  8238. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  8239. //row["cost"] = item.SubTotal;
  8240. //row["costRMB"] = rbmPrice;
  8241. dtdac2.Rows.Add(row);
  8242. place.Add(item.Place);
  8243. //dac2totalPrice += rbmPrice;
  8244. }
  8245. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  8246. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  8247. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  8248. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  8249. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic:#0.00} 元");
  8250. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic:#0.00} ");
  8251. string cell4Str1 = string.Empty;
  8252. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ:#0.00} 元/人;";
  8253. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW:#0.00} 元/人;";
  8254. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD:#0.00} 元/人;";
  8255. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  8256. string cellStr = $" 5.其他费用(";
  8257. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  8258. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  8259. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  8260. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  8261. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  8262. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  8263. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  8264. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  8265. foreach (var otherInfo in dac5)
  8266. {
  8267. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  8268. }
  8269. #endregion
  8270. if (cellStr.Length > 8)
  8271. {
  8272. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  8273. }
  8274. cellStr += ")";
  8275. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  8276. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  8277. decimal pxFee = dac4.Sum(it => it.Cost);
  8278. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  8279. string celllastStr1 = "";
  8280. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice:#0.00} 元";
  8281. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice:#0.00} 元";
  8282. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee:#0.00} 元";
  8283. celllastStr1 += $",国际旅费 元";
  8284. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee:#0.00} 元";
  8285. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  8286. designer.SetDataSource("cell4Str", cell4Str);
  8287. designer.SetDataSource("cellStr", cellStr);
  8288. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  8289. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  8290. designer.SetDataSource("celllastStr", celllastStr);
  8291. Workbook wb = designer.Workbook;
  8292. var sheet = wb.Worksheets[0];
  8293. //绑定datatable数据集
  8294. designer.SetDataSource(dtdac1);
  8295. designer.SetDataSource(dtdac2);
  8296. designer.Process();
  8297. var rowStart = dtdac1.Rows.Count;
  8298. while (rowStart > 0)
  8299. {
  8300. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  8301. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  8302. startIndex++;
  8303. rowStart--;
  8304. }
  8305. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  8306. startIndex += 1; //总计行
  8307. rowStart = dtdac2.Rows.Count;
  8308. while (rowStart > 0)
  8309. {
  8310. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  8311. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  8312. startIndex++;
  8313. rowStart--;
  8314. }
  8315. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  8316. wb.CalculateFormula(true);
  8317. //模板文件名
  8318. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  8319. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8320. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8321. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8322. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8323. }
  8324. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  8325. {
  8326. //获取模板
  8327. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  8328. //载入模板
  8329. var doc = new Document(tempPath);
  8330. var builder = new DocumentBuilder(doc);
  8331. var dic = new Dictionary<string, string>
  8332. {
  8333. { "GroupName", _DelegationInfo.TeamName },
  8334. { "ClientUnit", _DelegationInfo.ClientUnit }
  8335. };
  8336. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  8337. string missionLeaderJob = "";//负责人job
  8338. //int groupNumber = 0; //团人数
  8339. if (DeleClientList.Count > 0)
  8340. {
  8341. missionLeader = DeleClientList[0]?.Name ?? "";
  8342. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  8343. }
  8344. dic.Add("MissionLeader", missionLeader); //团负责人
  8345. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  8346. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  8347. #region MyRegion
  8348. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  8349. //{
  8350. // List<string> list = new List<string>();
  8351. // try
  8352. // {
  8353. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  8354. // foreach (var item in spilitArr)
  8355. // {
  8356. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  8357. // var depCode = spDotandEmpty[2].Substring(0, 3);
  8358. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  8359. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  8360. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  8361. // list.Add(depName);
  8362. // list.Add(arrName);
  8363. // }
  8364. // list = list.Distinct().ToList();
  8365. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  8366. // }
  8367. // catch (Exception)
  8368. // {
  8369. // dic.Add("ReturnCode", "行程录入不正确!");
  8370. // }
  8371. //}
  8372. //else
  8373. //{
  8374. // dic.Add("ReturnCode", "未录入行程!");
  8375. //}
  8376. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  8377. dic.Add("ReturnCode", string.Join("、", countrys));
  8378. #endregion
  8379. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  8380. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  8381. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  8382. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  8383. //{
  8384. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  8385. // dic.Add("Day", sp.Days.ToString());
  8386. //}
  8387. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  8388. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  8389. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  8390. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8391. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  8392. //培训人员名单
  8393. int cultivateRowIndex = 7;
  8394. foreach (var item in DeleClientList)
  8395. {
  8396. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  8397. builder.Write(item.Name);
  8398. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  8399. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  8400. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  8401. string birthDay = "";
  8402. if (item.Birthday != null)
  8403. {
  8404. DateTime dt = Convert.ToDateTime(item.Birthday);
  8405. birthDay = $"{dt.Year}.{dt.Month}";
  8406. }
  8407. builder.Write(birthDay);
  8408. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  8409. builder.Write(item.Company);
  8410. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  8411. builder.Write(item.Job);
  8412. cultivateRowIndex++;
  8413. }
  8414. //删除多余行
  8415. //cultivateRowIndex -= 2;
  8416. int delRows = 10 + 7 - cultivateRowIndex;
  8417. if (delRows > 0)
  8418. {
  8419. for (int i = 0; i < delRows; i++)
  8420. {
  8421. table1.Rows.RemoveAt(cultivateRowIndex);
  8422. //cultivateRowIndex++;
  8423. }
  8424. }
  8425. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  8426. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  8427. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  8428. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  8429. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  8430. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  8431. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  8432. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  8433. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  8434. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  8435. //其他费用
  8436. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  8437. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  8438. //其他费用合计
  8439. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  8440. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  8441. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  8442. //公务舱合计
  8443. //国际旅费
  8444. //string outsideJJ = "";
  8445. //string allPriceJJ = "";
  8446. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  8447. {
  8448. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  8449. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  8450. }
  8451. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  8452. {
  8453. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  8454. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  8455. }
  8456. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  8457. {
  8458. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ:#0.00} 公务舱:{_EnterExitCosts.AirGW:#0.00}");
  8459. dic.Add("AirFeeTotal", airFeeTotalStr);
  8460. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal:#0.00} 公务舱:{_gwcFeeToatal:#0.00}");
  8461. dic.Add("FeeTotal", feeTotalStr);
  8462. }
  8463. foreach (var key in dic.Keys)
  8464. {
  8465. builder.MoveToBookmark(key);
  8466. builder.Write(dic[key]);
  8467. }
  8468. //模板文件名
  8469. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  8470. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8471. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8472. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8473. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8474. }
  8475. }
  8476. else if (dto.ExportType == 2) //表格
  8477. {
  8478. //利用键值对存放数据
  8479. Dictionary<string, string> dic = new Dictionary<string, string>();
  8480. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  8481. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  8482. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  8483. dic.Add("Day", sp.Days.ToString());
  8484. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  8485. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  8486. {
  8487. //获取模板
  8488. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  8489. //载入模板
  8490. var doc = new Document(tempPath);
  8491. var builder = new DocumentBuilder(doc);
  8492. dic.Add("TeamName", _DelegationInfo.TeamName);
  8493. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  8494. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  8495. string missionLeaderName = "",
  8496. missionLeaderJob = "";
  8497. if (DeleClientList.Count > 0)
  8498. {
  8499. missionLeaderName = DeleClientList[0].Name;
  8500. missionLeaderJob = DeleClientList[0].Job;
  8501. }
  8502. dic.Add("MissionLeaderName", missionLeaderName);
  8503. dic.Add("MissionLeaderJob", missionLeaderJob);
  8504. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  8505. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  8506. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8507. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  8508. int rowCount = 10;//总人数行
  8509. int startRowIndex = 7; //起始行
  8510. for (int i = 0; i < DeleClientList.Count; i++)
  8511. {
  8512. builder.MoveToCell(0, startRowIndex, 0, 0);
  8513. builder.Write(DeleClientList[i].Name); //出国人员姓名
  8514. builder.MoveToCell(0, startRowIndex, 1, 0);
  8515. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  8516. builder.Write(sex);//性别
  8517. builder.MoveToCell(0, startRowIndex, 2, 0);
  8518. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  8519. builder.MoveToCell(0, startRowIndex, 3, 0);
  8520. builder.Write(DeleClientList[i].Company);//工作单位
  8521. builder.MoveToCell(0, startRowIndex, 4, 0);
  8522. builder.Write(DeleClientList[i].Job);//职务及级别
  8523. builder.MoveToCell(0, startRowIndex, 5, 0);
  8524. builder.Write("");//人员属性
  8525. builder.MoveToCell(0, startRowIndex, 6, 0);
  8526. builder.Write("");//上次出国时间
  8527. startRowIndex++;
  8528. }
  8529. int nullRow = rowCount - DeleClientList.Count;//空行
  8530. for (int i = 0; i < nullRow; i++)
  8531. {
  8532. table1.Rows.Remove(table1.Rows[startRowIndex]);
  8533. }
  8534. foreach (var key in dic.Keys)
  8535. {
  8536. builder.MoveToBookmark(key);
  8537. builder.Write(dic[key]);
  8538. }
  8539. //模板文件名
  8540. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  8541. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8542. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8543. if (dto.PortType == 1) return Ok(JsonView(true, "成功", new { Url = url }));
  8544. else if (dto.PortType == 2 || dto.PortType == 3) return Ok(JsonView(true, "成功", url));
  8545. }
  8546. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  8547. {
  8548. //获取模板
  8549. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  8550. //载入模板
  8551. var doc = new Document(tempPath);
  8552. var builder = new DocumentBuilder(doc);
  8553. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  8554. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  8555. dic.Add("Names", Names);
  8556. int accommodationRows = 12;
  8557. //int foodandotherRows = 12;
  8558. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  8559. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  8560. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8561. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  8562. int accommodationStartIndex = 6;
  8563. decimal dac1totalPrice = 0.00M;
  8564. foreach (var dac in dac1)
  8565. {
  8566. if (dac.SubTotal == 0)
  8567. {
  8568. continue;
  8569. }
  8570. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  8571. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  8572. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  8573. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  8574. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  8575. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  8576. builder.Write(currency);//币种
  8577. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  8578. builder.Write(dac.Cost.ToString("#0.00"));//标准
  8579. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  8580. builder.Write("");//人数
  8581. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  8582. builder.Write("");//天数
  8583. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  8584. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  8585. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  8586. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  8587. builder.Write(rate.ToString("#0.0000"));//汇率
  8588. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  8589. decimal rbmPrice = rate * dac.SubTotal;
  8590. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  8591. accommodationStartIndex++;
  8592. dac1totalPrice += rbmPrice;
  8593. }
  8594. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  8595. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  8596. builder.Write("小计");
  8597. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  8598. builder.Write(dac1totalPrice.ToString("#0.00"));
  8599. accommodationStartIndex++;
  8600. int nullRow = accommodationRows - dac1.Count;
  8601. //删除空行
  8602. //if (nullRow > 0)
  8603. //{
  8604. // int rowIndex = accommodationStartIndex;
  8605. // for (int i = 0; i < nullRow; i++)
  8606. // {
  8607. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  8608. // row.Remove();
  8609. // rowIndex++;
  8610. // }
  8611. //}
  8612. if (dac2.Count == dac3.Count)//国家 币种 金额
  8613. {
  8614. for (int i = 0; i < dac2.Count; i++)
  8615. {
  8616. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  8617. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  8618. }
  8619. }
  8620. int foodandotherStartIndex = 19;//
  8621. decimal dac2totalPrice = 0.00M;
  8622. foreach (var dac in dac2)
  8623. {
  8624. if (dac.SubTotal == 0)
  8625. {
  8626. continue;
  8627. }
  8628. //foodandotherStartIndex = 12;
  8629. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  8630. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  8631. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  8632. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  8633. builder.Write(currency);//币种
  8634. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  8635. builder.Write(dac.Cost.ToString("#0.00"));//标准
  8636. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  8637. builder.Write("");//人数
  8638. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  8639. builder.Write("");//天数
  8640. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  8641. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  8642. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  8643. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  8644. builder.Write(rate.ToString("#0.0000"));//汇率
  8645. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  8646. decimal rbmPrice = rate * dac.SubTotal;
  8647. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  8648. foodandotherStartIndex++;
  8649. dac2totalPrice += rbmPrice;
  8650. }
  8651. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  8652. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  8653. //删除空行
  8654. //if (dac2.Count < foodandotherRows)
  8655. //{
  8656. // while (table2.Rows.Count > dac2.Count)
  8657. // {
  8658. // table2.Rows.RemoveAt(dac2.Count);
  8659. // }
  8660. //}
  8661. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  8662. string otherFeeStr = "";
  8663. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  8664. if (_EnterExitCosts.YiMiao > 0) otherFeeStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  8665. if (_EnterExitCosts.HeSuan > 0) otherFeeStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  8666. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  8667. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  8668. if (_EnterExitCosts.Service > 0) otherFeeStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  8669. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  8670. foreach (var otherInfo in dac5)
  8671. {
  8672. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal:#0.00} 元,";
  8673. }
  8674. #endregion
  8675. if (otherFeeStr.Length > 0)
  8676. {
  8677. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  8678. otherFeeStr = $"({otherFeeStr})";
  8679. dic.Add("OtherFeeStr", otherFeeStr);
  8680. }
  8681. foreach (var key in dic.Keys)
  8682. {
  8683. builder.MoveToBookmark(key);
  8684. builder.Write(dic[key]);
  8685. }
  8686. //模板文件名
  8687. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  8688. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8689. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8690. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8691. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8692. }
  8693. }
  8694. else if (dto.ExportType == 3)
  8695. {
  8696. if (dto.SubTypeId == 1) //团组成员名单
  8697. {
  8698. if (!DeleClientList.Any()) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成员暂未录入!!!", ""));
  8699. //获取模板
  8700. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  8701. //载入模板
  8702. var doc = new Document(tempPath);
  8703. var builder = new DocumentBuilder(doc);
  8704. //获取word里所有表格
  8705. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8706. //获取所填表格的序数
  8707. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  8708. var rowStart = tableOne.Rows[0]; //获取第1行
  8709. //循环赋值
  8710. for (int i = 0; i < DeleClientList.Count; i++)
  8711. {
  8712. builder.MoveToCell(0, i + 1, 0, 0);
  8713. builder.Write(DeleClientList[i].Name);
  8714. builder.MoveToCell(0, i + 1, 1, 0);
  8715. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  8716. builder.Write(sex);
  8717. builder.MoveToCell(0, i + 1, 2, 0);
  8718. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  8719. builder.MoveToCell(0, i + 1, 3, 0);
  8720. builder.Write(DeleClientList[i].Company);
  8721. builder.MoveToCell(0, i + 1, 4, 0);
  8722. builder.Write(DeleClientList[i].Job);
  8723. }
  8724. //删除多余行
  8725. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  8726. {
  8727. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  8728. }
  8729. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  8730. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  8731. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  8732. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8733. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8734. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8735. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8736. }
  8737. }
  8738. return Ok(JsonView(400, "操作失败!", ""));
  8739. }
  8740. catch (Exception ex)
  8741. {
  8742. return Ok(JsonView(400, ex.Message, ""));
  8743. }
  8744. }
  8745. /// <summary>
  8746. /// 获取三公费用标准city
  8747. /// </summary>
  8748. /// <param name="placeData"></param>
  8749. /// <param name="nationalTravelFeeId"></param>
  8750. /// <returns></returns>
  8751. private static string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  8752. {
  8753. string _city = string.Empty;
  8754. if (placeData.Count < 1) return _city;
  8755. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  8756. if (data == null) return _city;
  8757. string country = data.Country;
  8758. string city = data.City;
  8759. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  8760. else _city = city;
  8761. return _city;
  8762. }
  8763. ///// <summary>
  8764. ///// 团组模块 - 出入境费用 - 明细表导出
  8765. ///// </summary>
  8766. ///// <returns></returns>
  8767. //[HttpPost]
  8768. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8769. //public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  8770. //{
  8771. // var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  8772. // if (data.Code != 0)
  8773. // {
  8774. // return Ok(JsonView(false, data.Msg));
  8775. // }
  8776. // return Ok(JsonView(true, data.Msg, data.Data));
  8777. //}
  8778. /// <summary>
  8779. /// 团组模块 - 出入境费用 - 一键清空
  8780. /// </summary>
  8781. /// <returns></returns>
  8782. [HttpPost]
  8783. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  8784. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8785. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  8786. {
  8787. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  8788. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  8789. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  8790. var _view = await _enterExitCostRep.OneClickClear(dto.Id, dto.DiId, dto.UserId);
  8791. await _sqlSugar.Updateable<Grp_DayOtherPrice>()
  8792. .Where(x => x.Diid == dto.DiId && x.IsDel == 0)
  8793. .SetColumns(x => new Grp_DayOtherPrice
  8794. {
  8795. IsDel = 1,
  8796. DeleteUserId = dto.UserId,
  8797. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  8798. })
  8799. .ExecuteCommandAsync();
  8800. if (_view.Code == 0)
  8801. {
  8802. return Ok(JsonView(true, "操作成功"));
  8803. }
  8804. return Ok(JsonView(false, "操作失败"));
  8805. }
  8806. /// <summary>
  8807. /// 团组模块 - 出入境费用 - 子项删除
  8808. /// </summary>
  8809. /// <returns></returns>
  8810. [HttpPost]
  8811. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  8812. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8813. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  8814. {
  8815. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  8816. if (data.Code != 0)
  8817. {
  8818. return Ok(JsonView(false, data.Msg));
  8819. }
  8820. return Ok(JsonView(true, "操作成功!", data.Data));
  8821. }
  8822. /// <summary>
  8823. /// 删除三公其他费用
  8824. /// </summary>
  8825. /// <param name="dto"></param>
  8826. /// <returns></returns>
  8827. [HttpPost]
  8828. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  8829. public IActionResult DeleteOtherExpenses(EnterExitCostSubItemDelDto dto)
  8830. {
  8831. var jw = JsonView(false, "删除失败!");
  8832. var data = new Grp_DayOtherPrice()
  8833. {
  8834. Id = dto.Id,
  8835. IsDel = 1,
  8836. DeleteUserId = dto.DeleteUserId,
  8837. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  8838. };
  8839. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  8840. if (del > 0)
  8841. {
  8842. jw.Code = 200;
  8843. jw.Msg = "删除成功!";
  8844. }
  8845. return Ok(jw);
  8846. }
  8847. /// <summary>
  8848. /// 团组模块 - 出入境国家费用标准 List
  8849. /// </summary>
  8850. /// <returns></returns>
  8851. [HttpPost]
  8852. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8853. public async Task<IActionResult> GetNationalTravelFeeData(NationalTravelFeeDataDto dto)
  8854. {
  8855. int provinceId = dto.ProvinceId;
  8856. if (provinceId < 1) provinceId = 122; //默认四川省数据
  8857. var nftData = await _sqlSugar
  8858. .Queryable<Grp_NationalTravelFee, Sys_SetData, Sys_Users, Sys_Cities>((ntf, sd1, u, c) => new JoinQueryInfos(
  8859. JoinType.Left, ntf.Currency == sd1.Id,
  8860. JoinType.Left, ntf.LastUpdateUserId == u.Id,
  8861. JoinType.Left, ntf.ProvinceId == c.Id
  8862. ))
  8863. .Where((ntf, sd1, u, c) => ntf.IsDel == 0 && ntf.ProvinceId == provinceId)
  8864. .Select((ntf, sd1, u, c) => new NationalTravelFeeInfoView
  8865. {
  8866. Id = ntf.Id,
  8867. ProvinceId = ntf.ProvinceId,
  8868. ProvinceName = c.Name_CN,
  8869. Continent = ntf.Continent,
  8870. Country = ntf.Country,
  8871. City = ntf.City,
  8872. Currency = ntf.Currency,
  8873. CurrencyCode = sd1.Name,
  8874. CurrencyName = sd1.Remark,
  8875. RoomCost = ntf.RoomCost,
  8876. FoodCost = ntf.FoodCost,
  8877. PublicCost = ntf.PublicCost,
  8878. LastUpdateUserId = ntf.LastUpdateUserId,
  8879. LastUpdateUserName = u.CnName,
  8880. LastUpdateTime = ntf.LastUpdateTime
  8881. })
  8882. .ToListAsync();
  8883. return Ok(JsonView(true, "查询成功!", nftData));
  8884. }
  8885. /// <summary>
  8886. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  8887. /// </summary>
  8888. /// <returns></returns>
  8889. [HttpPost]
  8890. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8891. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  8892. {
  8893. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  8894. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  8895. List<string> countryData = new List<string>();
  8896. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country!).ToList());
  8897. countryData = countryData.Distinct().ToList();
  8898. List<dynamic> dataSource = new List<dynamic>();
  8899. foreach (var item in countryData)
  8900. {
  8901. var cityData1 = new List<string>();
  8902. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City ?? "").ToList();
  8903. var countryData2 = new
  8904. {
  8905. CountryName = item,
  8906. CityData = cityData1
  8907. };
  8908. if (!dataSource.Contains(countryData2))
  8909. {
  8910. dataSource.Add(countryData2);
  8911. }
  8912. }
  8913. return Ok(JsonView(true, "查询成功!", dataSource));
  8914. }
  8915. /// <summary>
  8916. /// 团组模块 - 出入境国家费用标准 Page List
  8917. /// </summary>
  8918. /// <returns></returns>
  8919. [HttpPost]
  8920. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8921. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  8922. {
  8923. int portId = dto.PortType,
  8924. pageIndex = dto.PageIndex,
  8925. pageSize = dto.PageSize;
  8926. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  8927. if (pageIndex == 0) pageIndex = 1;
  8928. if (pageSize == 0) pageSize = 10;
  8929. RefAsync<int> total = 0;
  8930. var nationalTravelFeeData = await _sqlSugar
  8931. .Queryable<Grp_NationalTravelFee, Sys_SetData, Sys_Users, Sys_Cities>((ntf, sd1, u, sd2) => new JoinQueryInfos(
  8932. JoinType.Left, ntf.Currency == sd1.Id,
  8933. JoinType.Left, ntf.LastUpdateUserId == u.Id,
  8934. JoinType.Left, ntf.ProvinceId == sd2.Id
  8935. ))
  8936. .Where((ntf, sd1, u, sd2) => ntf.IsDel == 0)
  8937. .WhereIF(dto.ProvinceId > 0, (ntf, sd1, u, sd2) => ntf.ProvinceId == dto.ProvinceId)
  8938. .WhereIF(!string.IsNullOrEmpty(dto.Country), (ntf, sd1, u, sd2) => ntf.Country.Contains(dto.Country))
  8939. .WhereIF(!string.IsNullOrEmpty(dto.City), (ntf, sd1, u, sd2) => ntf.City.Contains(dto.City))
  8940. .OrderByDescending((ntf, sd1, u, sd2) => ntf.LastUpdateTime)
  8941. .Select((ntf, sd1, u, sd2) => new NationalTravelFeePageInfoView
  8942. {
  8943. RowNumber = SqlFunc.RowNumber($"{ntf.LastUpdateTime} Desc"),
  8944. Id = ntf.Id,
  8945. ProvinceId = ntf.ProvinceId,
  8946. ProvinceName = sd2.Name_CN,
  8947. Continent = ntf.Continent,
  8948. Country = ntf.Country,
  8949. City = ntf.City,
  8950. Currency = ntf.Currency,
  8951. CurrencyCode = sd1.Name,
  8952. CurrencyName = sd1.Remark,
  8953. RoomCost = ntf.RoomCost,
  8954. FoodCost = ntf.FoodCost,
  8955. PublicCost = ntf.PublicCost,
  8956. LastUpdateUserId = ntf.LastUpdateUserId,
  8957. LastUpdateUserName = u.CnName,
  8958. LastUpdateTime = ntf.LastUpdateTime,
  8959. Remark = ntf.Remark
  8960. })
  8961. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  8962. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  8963. }
  8964. /// <summary>
  8965. /// 团组模块 - 出入境国家费用标准 根据城市查询
  8966. /// </summary>
  8967. /// <returns></returns>
  8968. [HttpPost]
  8969. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8970. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  8971. {
  8972. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  8973. int portId = dto.PortType;
  8974. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  8975. string whereSql = string.Empty;
  8976. if (!string.IsNullOrEmpty(dto.Country))
  8977. {
  8978. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  8979. }
  8980. if (!string.IsNullOrEmpty(dto.City))
  8981. {
  8982. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  8983. }
  8984. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  8985. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,gntf.TrainCost,
  8986. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  8987. From Grp_NationalTravelFee gntf
  8988. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  8989. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  8990. Where gntf.Isdel = 0 {0} ", whereSql);
  8991. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  8992. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  8993. }
  8994. /// <summary>
  8995. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  8996. /// </summary>
  8997. /// <returns></returns>
  8998. [HttpPost]
  8999. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9000. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  9001. {
  9002. return Ok(await _enterExitCostRep.PostNationalTravelFeeOperate(dto));
  9003. }
  9004. /// <summary>
  9005. /// 团组模块 - 出入境国家费用标准 - Del
  9006. /// </summary>
  9007. /// <returns></returns>
  9008. [HttpPost]
  9009. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9010. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  9011. {
  9012. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  9013. {
  9014. Id = dto.Id,
  9015. DeleteUserId = dto.DeleteUserId,
  9016. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  9017. IsDel = 1
  9018. };
  9019. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  9020. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  9021. .WhereColumns(it => new { it.Id })
  9022. .ExecuteCommandAsync();
  9023. if (delStatus <= 0)
  9024. {
  9025. return Ok(JsonView(false, "删除失败!"));
  9026. }
  9027. return Ok(JsonView(true, "操作成功!"));
  9028. }
  9029. /// <summary>
  9030. /// 团组模块 - 出入境国家费用标准 - 费用导入收款账单
  9031. /// 注:Get 请求Headers 加 Token
  9032. /// </summary>
  9033. /// <param name="groupId"></param>
  9034. /// <returns></returns>
  9035. [HttpGet("{groupId}")]
  9036. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9037. public async Task<IActionResult> NationalTravelFeeImportReceivables(int groupId)
  9038. {
  9039. var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  9040. if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  9041. var data = await GeneralMethod.ReceivablesImportFeeAsync(groupId);
  9042. data.ForEach(x =>
  9043. {
  9044. x.CreateUserId = _currUserInfo.UserId;
  9045. });
  9046. if (data.Any())
  9047. {
  9048. var add = await _sqlSugar.Insertable(data).ExecuteCommandAsync();
  9049. if (add > 0)
  9050. {
  9051. return Ok(JsonView(true, "操作成功!"));
  9052. }
  9053. }
  9054. return Ok(JsonView(false, "未操作!"));
  9055. }
  9056. #endregion
  9057. #region 团组经理模块 出入境费用-草稿
  9058. /// <summary>
  9059. /// 团组模块 - 出入境费用-草稿 - 基础数据源 - 省份归属
  9060. /// </summary>
  9061. /// <returns></returns>
  9062. [HttpGet]
  9063. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9064. public async Task<IActionResult> EnterExitDraftProvBelongCostDataSource()
  9065. {
  9066. var provData = await _groupRepository.ProvinceBasicSource();
  9067. return Ok(JsonView(true, "查询成功!", provData));
  9068. }
  9069. /// <summary>
  9070. /// 团组模块 - 出入境费用-草稿 - 文件类型list 根据省份Id获取
  9071. /// </summary>
  9072. /// <returns></returns>
  9073. [HttpGet("{provinceId}")]
  9074. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9075. public async Task<IActionResult> EnterExitCostDraftFileOwner([FromRoute] int provinceId = 122)
  9076. {
  9077. //验证城市归属并给默认值
  9078. if (provinceId < 1) provinceId = 122;
  9079. /*
  9080. * 122 四川
  9081. * 108 贵州
  9082. * 103 重庆
  9083. * 132 云南
  9084. */
  9085. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostDraftRep.FileOwner(provinceId);
  9086. return Ok(JsonView(true, "查询成功!", new
  9087. {
  9088. WordTypeData = wordTypeData,
  9089. ExcelTypeData = excelTypeData,
  9090. }));
  9091. }
  9092. /// <summary>
  9093. /// 团组模块 - 出入境费用-草稿 - 基础数据源(团组名称/币种类型)
  9094. /// </summary>
  9095. /// <returns></returns>
  9096. [HttpPost]
  9097. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9098. public async Task<IActionResult> EnterExitCostDraftDataSource(EnterExitCostDraftDataSourceDto dto)
  9099. {
  9100. var draftNameDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  9101. .Where(x => x.IsDel == 0)
  9102. .OrderByDescending(x => x.CreateTime)
  9103. .Select(x => new { x.Id, x.DraftName })
  9104. .ToListAsync();
  9105. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  9106. //SetDataInfoView
  9107. var dataSource = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  9108. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  9109. var _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  9110. int provinceId = dto.ProvinceId;
  9111. if (provinceId < 1) provinceId = 122;
  9112. /*
  9113. * 122 四川
  9114. * 108 贵州
  9115. * 103 重庆
  9116. * 132 云南
  9117. */
  9118. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostRep.FileOwner(provinceId);
  9119. //默认币种显示
  9120. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  9121. var viewPermissionData = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  9122. return Ok(JsonView(true, "查询成功!", new
  9123. {
  9124. DraftNameDatas = draftNameDatas,
  9125. CurrencyData = _CurrencyData,
  9126. WordTypeData = wordTypeData,
  9127. ExcelTypeData = excelTypeData,
  9128. CurrencyInit = _currencyInfos,
  9129. ViewPermissionData = viewPermissionData
  9130. }));
  9131. }
  9132. /// <summary>
  9133. /// 团组模块 - 出入境费用-草稿
  9134. /// 实时汇率 tips
  9135. /// 机票费用 tips
  9136. /// </summary>
  9137. /// <returns></returns>
  9138. [HttpPost]
  9139. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9140. public async Task<IActionResult> EnterExitCostDraftCorrelationTips(EnterExitCostDraftCorrelationTipsDto dto)
  9141. {
  9142. //var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  9143. return Ok(JsonView(true, "查询成功!", new
  9144. {
  9145. //GroupNameData = groupNameData.Data,
  9146. //visaData = visaData.Data,
  9147. //airData = airData.Data,
  9148. reteInfos = await GeneralMethod.EnterExitCostLiveRate()
  9149. }));
  9150. }
  9151. /// <summary>
  9152. /// 团组模块 - 出入境费用-草稿
  9153. /// 签证费用 tips
  9154. /// </summary>
  9155. /// <returns></returns>
  9156. [HttpPost]
  9157. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9158. public async Task<IActionResult> EnterExitCostDraftVisaTips(EnterExitCostDraftVisaTipsDto dto)
  9159. {
  9160. //if (dto.DraftId < 1) return Ok(JsonView(false,MsgTips.Id));
  9161. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9162. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  9163. .Select(x => x.NationalTravelFeeId)
  9164. .Distinct()
  9165. .ToListAsync();
  9166. //if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  9167. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  9168. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  9169. .Select(x => x.Country)
  9170. .Distinct()
  9171. .ToArrayAsync();
  9172. //if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  9173. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  9174. return Ok(JsonView(true, "查询成功!", new
  9175. {
  9176. totalAmt,
  9177. remark
  9178. }));
  9179. }
  9180. /// <summary>
  9181. /// 团组模块 - 出入境费用-草稿 - Info
  9182. /// </summary>
  9183. /// <returns></returns>
  9184. [HttpPost]
  9185. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Details)]
  9186. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9187. public async Task<IActionResult> EnterExitCostDraftInfoById(EnterExitCostDraftInfoByIdDto dto)
  9188. {
  9189. return Ok(await _enterExitCostDraftRep.EnterExitCostDraftInfoById(dto));
  9190. }
  9191. /// <summary>
  9192. /// 团组模块 - 出入境费用-草稿 - 设置view权限
  9193. /// </summary>
  9194. /// <returns></returns>
  9195. [HttpPost]
  9196. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9197. public async Task<IActionResult> EnterExitCostDraftSetViewPermissiion(EnterExitCostDraftSetViewPermissiionDto dto)
  9198. {
  9199. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9200. if (dto.DraftId < 1) return Ok(JsonView(false, "请传入有效的DraftId;"));
  9201. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  9202. var permissions = new List<Grp_EnterExitCostDraftPermission>();
  9203. foreach (var userId in dto.UserIds)
  9204. {
  9205. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  9206. }
  9207. if (permissions.Any())
  9208. {
  9209. _sqlSugar.BeginTran();
  9210. try
  9211. {
  9212. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  9213. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  9214. if (result < 1)
  9215. {
  9216. _sqlSugar.RollbackTran();
  9217. return Ok(JsonView(false));
  9218. }
  9219. }
  9220. catch (Exception ex)
  9221. {
  9222. _sqlSugar.RollbackTran();
  9223. return Ok(JsonView(false, ex.Message));
  9224. }
  9225. _sqlSugar.CommitTran();
  9226. return Ok(JsonView(true));
  9227. }
  9228. return Ok(JsonView(false));
  9229. }
  9230. /// <summary>
  9231. /// 团组模块 - 出入境费用-草稿 - Add And Update
  9232. /// </summary>
  9233. /// <returns></returns>
  9234. [HttpPost]
  9235. [ApiLog("Grp_EnterExitCostDraft", OperationEnum.Add)]
  9236. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9237. public async Task<IActionResult> EnterExitCostDraftOp(EnterExitCostDraftOpDto dto)
  9238. {
  9239. var data = await _enterExitCostDraftRep.EnterExitCostDraftOp(dto);
  9240. if (data.Code != 0)
  9241. {
  9242. return Ok(JsonView(false, data.Msg));
  9243. }
  9244. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  9245. //汇率信息记录
  9246. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  9247. return Ok(JsonView(true, data.Msg, data.Data));
  9248. }
  9249. /// <summary>
  9250. /// 团组模块 - 出入境费用-草稿 - File downlaod
  9251. /// </summary>
  9252. /// <param name="dto"></param>
  9253. /// <returns></returns>
  9254. [HttpPost]
  9255. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Download)]
  9256. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9257. public async Task<IActionResult> EnterExitCostDraftDownload(EnterExitCostDraftDownloadDto dto)
  9258. {
  9259. try
  9260. {
  9261. var id = dto.Id;
  9262. if (id < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  9263. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  9264. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  9265. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  9266. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  9267. 3 团组成员名单 1 团组成员名单", ""));
  9268. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(it => it.IsDel == 0 && it.Id == id).OrderByDescending(x => x.CreateTime).First();
  9269. if (_EnterExitCosts == null) return Ok(JsonView(400, "未填写出入境费用-草稿;", ""));
  9270. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(it => it.IsDel == 0 && it.ParentId == id).ToList();
  9271. var countryIds = _DayAndCosts.Select(x => x.NationalTravelFeeId).ToList();
  9272. var nationalTravelFeeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0 && countryIds.Contains(it.Id)).ToList();
  9273. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  9274. //数据源
  9275. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  9276. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  9277. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  9278. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  9279. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  9280. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  9281. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  9282. .Where((x, a, b) => x.IsDel == 0 && x.ParentId == id)
  9283. .Select((x, a, b) => new
  9284. {
  9285. x.Index,
  9286. itemName = a.Name,
  9287. CurrencyStr = b.Name,
  9288. x.Cost,
  9289. x.SubTotal,
  9290. x.Remark
  9291. })
  9292. .OrderBy((x) => x.Index)
  9293. .ToList(); //其他款项费用
  9294. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  9295. var peiceItemCurrencys = new List<string>();
  9296. if (_DayAndCosts.Any())
  9297. {
  9298. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  9299. if (currencyIds.Any()) peiceItemCurrencys.AddRange(_CurrDatas.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  9300. }
  9301. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  9302. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  9303. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  9304. {
  9305. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  9306. }
  9307. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  9308. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  9309. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  9310. if (dto.ExportType == 1) //明细表
  9311. {
  9312. if (dto.SubTypeId == 1005) //1005(默认明细表)
  9313. {
  9314. //获取模板
  9315. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  9316. //载入模板
  9317. Document doc = new Document(tempPath);
  9318. DocumentBuilder builder = new DocumentBuilder(doc);
  9319. //利用键值对存放数据
  9320. Dictionary<string, string> dic = new Dictionary<string, string>();
  9321. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  9322. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  9323. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  9324. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  9325. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  9326. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  9327. //境内费用(其他费用)
  9328. if (_EnterExitCosts.ChoiceOne == 1)
  9329. {
  9330. string row1_1 = "";
  9331. if (_EnterExitCosts.Visa > 0)
  9332. {
  9333. //insidePayTotal += _EnterExitCosts.Visa;
  9334. row1_1 = $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  9335. //if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  9336. //{
  9337. // row1_1 += $"\t签证费用描述: {_EnterExitCosts.VisaRemark} 人民币/人";
  9338. //}
  9339. }
  9340. string row1_2 = "";
  9341. if (_EnterExitCosts.YiMiao > 0)
  9342. {
  9343. //insidePayTotal += _EnterExitCosts.YiMiao;
  9344. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  9345. }
  9346. if (_EnterExitCosts.HeSuan > 0)
  9347. {
  9348. //insidePayTotal += _EnterExitCosts.HeSuan;
  9349. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  9350. }
  9351. if (_EnterExitCosts.Service > 0)
  9352. {
  9353. //insidePayTotal += _EnterExitCosts.Service;
  9354. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  9355. }
  9356. string row1_3 = "";
  9357. if (_EnterExitCosts.Safe > 0)
  9358. {
  9359. //insidePayTotal += _EnterExitCosts.Safe;
  9360. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  9361. }
  9362. if (_EnterExitCosts.Ticket > 0)
  9363. {
  9364. //insidePayTotal += _EnterExitCosts.Ticket;
  9365. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  9366. }
  9367. string row1 = "";
  9368. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  9369. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  9370. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  9371. row1 += $"备注:{_EnterExitCosts.Remark}";
  9372. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  9373. dic.Add("Row1Str", row1);
  9374. }
  9375. string airTotalStr = string.Empty,
  9376. airPriceStr = string.Empty;
  9377. //经济舱
  9378. if (_EnterExitCosts.SumJJC == 1)
  9379. {
  9380. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  9381. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  9382. }
  9383. //公务舱
  9384. if (_EnterExitCosts.SumGWC == 1)
  9385. {
  9386. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  9387. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  9388. }
  9389. //头等舱
  9390. if (_EnterExitCosts.SumTDC == 1)
  9391. {
  9392. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  9393. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  9394. }
  9395. //汇率描述
  9396. string rateStr = "";
  9397. if (peiceItemCurrencyInfos.Any())
  9398. {
  9399. rateStr = "\r\n汇率描述:";
  9400. foreach (var item in peiceItemCurrencyInfos)
  9401. {
  9402. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate.ToString("#0.0000")} ";
  9403. }
  9404. }
  9405. string twoItemRemark = "备注:";
  9406. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  9407. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  9408. dic.Add("AirTotalStr", airTotalStr);
  9409. dic.Add("AirPriceStr", airPriceStr);
  9410. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  9411. dic.Add("TwoItemRemark", twoItemRemark);
  9412. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  9413. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  9414. int table1Row = 0,
  9415. table2Row = 0,
  9416. table3Row = 0,
  9417. table4Row = 0,
  9418. table5Row = 0;
  9419. //住宿费
  9420. if (_EnterExitCosts.ChoiceThree == 1)
  9421. {
  9422. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  9423. table1Row = dac1.Count;
  9424. #region 填充word表格内容
  9425. for (int i = 0; i < dac1.Count; i++)
  9426. {
  9427. var dac = dac1[i];
  9428. if (dac == null) continue;
  9429. builder.MoveToCell(0, i, 0, 0);
  9430. builder.Write("第" + dac.Days.ToString() + "晚:");
  9431. builder.MoveToCell(0, i, 1, 0);
  9432. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  9433. //builder.Write(dac.Place == null ? "" : dac.Place);
  9434. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  9435. builder.MoveToCell(0, i, 2, 0);
  9436. builder.Write("费用标准:");
  9437. string curr = "";
  9438. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  9439. if (currData != null)
  9440. {
  9441. curr = currData.Name;
  9442. }
  9443. builder.MoveToCell(0, i, 3, 0);
  9444. builder.Write(dac.Cost.ToString("#0.00") + curr);
  9445. builder.MoveToCell(0, i, 4, 0);
  9446. builder.Write("费用小计:");
  9447. builder.MoveToCell(0, i, 5, 0);
  9448. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  9449. }
  9450. #endregion
  9451. }
  9452. else dic.Add("SubZS", "0.00");
  9453. //删除多余行
  9454. while (table1.Rows.Count > table1Row)
  9455. {
  9456. table1.Rows.RemoveAt(table1Row);
  9457. }
  9458. //伙食费
  9459. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  9460. if (_EnterExitCosts.ChoiceFour == 1)
  9461. {
  9462. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  9463. table2Row = dac2.Count;
  9464. #region 填充word表格内容
  9465. for (int i = 0; i < dac2.Count; i++)
  9466. {
  9467. var dac = dac2[i];
  9468. if (dac == null) continue;
  9469. builder.MoveToCell(1, i, 0, 0);
  9470. builder.Write("第" + dac.Days.ToString() + "天:");
  9471. builder.MoveToCell(1, i, 1, 0);
  9472. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  9473. builder.MoveToCell(1, i, 2, 0);
  9474. builder.Write("费用标准:");
  9475. string curr = "";
  9476. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  9477. if (currData != null)
  9478. {
  9479. curr = currData.Name;
  9480. }
  9481. builder.MoveToCell(1, i, 3, 0);
  9482. builder.Write(dac.Cost.ToString("#0.00") + curr);
  9483. builder.MoveToCell(1, i, 4, 0);
  9484. builder.Write("费用小计:");
  9485. builder.MoveToCell(1, i, 5, 0);
  9486. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  9487. }
  9488. #endregion
  9489. }
  9490. else dic.Add("SubHS", "0.00");
  9491. //删除多余行
  9492. while (table2.Rows.Count > table2Row)
  9493. {
  9494. table2.Rows.RemoveAt(table2Row);
  9495. }
  9496. //公杂费
  9497. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  9498. if (_EnterExitCosts.ChoiceFive == 1)
  9499. {
  9500. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  9501. table3Row = dac3.Count;
  9502. #region 填充word表格内容
  9503. for (int i = 0; i < dac3.Count; i++)
  9504. {
  9505. var dac = dac3[i];
  9506. if (dac == null) continue;
  9507. builder.MoveToCell(2, i, 0, 0);
  9508. builder.Write("第" + dac.Days.ToString() + "天:");
  9509. builder.MoveToCell(2, i, 1, 0);
  9510. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  9511. builder.MoveToCell(2, i, 2, 0);
  9512. builder.Write("费用标准:");
  9513. string curr = "";
  9514. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  9515. if (currData != null)
  9516. {
  9517. curr = currData.Name;
  9518. }
  9519. builder.MoveToCell(2, i, 3, 0);
  9520. builder.Write(dac.Cost.ToString("#0.00") + curr);
  9521. builder.MoveToCell(2, i, 4, 0);
  9522. builder.Write("费用小计:");
  9523. builder.MoveToCell(2, i, 5, 0);
  9524. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  9525. }
  9526. //删除多余行
  9527. while (table3.Rows.Count > table3Row)
  9528. {
  9529. table3.Rows.RemoveAt(table3Row);
  9530. }
  9531. #endregion
  9532. }
  9533. else dic.Add("SubGZF", "0.00");
  9534. //删除多余行
  9535. while (table3.Rows.Count > table3Row)
  9536. {
  9537. table3.Rows.RemoveAt(table3Row);
  9538. }
  9539. //培训费
  9540. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  9541. if (_EnterExitCosts.ChoiceSix == 1)
  9542. {
  9543. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  9544. dic.Add("SubPX", pxStr);
  9545. table4Row = dac4.Count;
  9546. #region 填充word表格内容
  9547. for (int i = 0; i < dac4.Count; i++)
  9548. {
  9549. var dac = dac4[i];
  9550. if (dac == null) continue;
  9551. builder.MoveToCell(3, i, 0, 0);
  9552. builder.Write("第" + dac.Days.ToString() + "天:");
  9553. builder.MoveToCell(3, i, 1, 0);
  9554. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  9555. builder.MoveToCell(3, i, 2, 0);
  9556. builder.Write("费用标准:");
  9557. string curr = "";
  9558. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  9559. if (currData != null)
  9560. {
  9561. curr = currData.Name;
  9562. }
  9563. builder.MoveToCell(3, i, 3, 0);
  9564. builder.Write(dac.Cost.ToString("#0.00") + curr);
  9565. builder.MoveToCell(3, i, 4, 0);
  9566. builder.Write("费用小计:");
  9567. builder.MoveToCell(3, i, 5, 0);
  9568. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  9569. }
  9570. #endregion
  9571. }
  9572. //else dic.Add("SubPX", $"六、培训费合计: 0 元/人");
  9573. //删除多余行
  9574. while (table4.Rows.Count > table4Row)
  9575. {
  9576. table4.Rows.RemoveAt(table4Row);
  9577. }
  9578. //其他费用
  9579. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  9580. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  9581. {
  9582. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  9583. dic.Add("titleQi", qtStr);
  9584. table5Row = dac5.Count;
  9585. #region 填充word表格内容
  9586. for (int i = 0; i < dac5.Count; i++)
  9587. {
  9588. var dac = dac5[i];
  9589. if (dac == null) continue;
  9590. builder.MoveToCell(4, i, 0, 0);
  9591. builder.Write("第" + dac.Index.ToString() + "项:");
  9592. builder.MoveToCell(4, i, 1, 0);
  9593. builder.Write(dac.itemName);
  9594. builder.MoveToCell(4, i, 2, 0);
  9595. builder.Write("费用标准:");
  9596. builder.MoveToCell(4, i, 3, 0);
  9597. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  9598. builder.MoveToCell(4, i, 4, 0);
  9599. builder.Write("费用小计:");
  9600. builder.MoveToCell(4, i, 5, 0);
  9601. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  9602. builder.MoveToCell(4, i, 6, 0);
  9603. builder.Write("备注:");
  9604. builder.MoveToCell(4, i, 7, 0);
  9605. builder.Write(dac.Remark);
  9606. }
  9607. #endregion
  9608. }
  9609. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  9610. //删除多余行
  9611. while (table5.Rows.Count > table5Row)
  9612. {
  9613. table5.Rows.RemoveAt(table5Row);
  9614. }
  9615. //加上其他费用
  9616. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  9617. decimal subJJC = 0.00M,
  9618. subGWC = 0.00M,
  9619. subTDC = 0.00M;
  9620. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  9621. string totalLabel = string.Format("全部费用总计:");
  9622. //经济舱
  9623. if (_EnterExitCosts.SumJJC == 1)
  9624. {
  9625. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  9626. totalLabel += $"{subJJC.ToString("#0.00")} 元/人(经济舱)";
  9627. }
  9628. //公务舱
  9629. if (_EnterExitCosts.SumGWC == 1)
  9630. {
  9631. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  9632. totalLabel += $"{subGWC.ToString("#0.00")} 元/人(公务舱)";
  9633. }
  9634. //头等舱
  9635. if (_EnterExitCosts.SumTDC == 1)
  9636. {
  9637. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  9638. totalLabel += $"{subTDC.ToString("#0.00")} 元/人(头等舱)";
  9639. }
  9640. //TotalLabel
  9641. dic.Add("TotalLabel", totalLabel);
  9642. #region 填充word模板书签内容
  9643. foreach (var key in dic.Keys)
  9644. {
  9645. Bookmark bookmark = doc.Range.Bookmarks[key];
  9646. if (bookmark != null)
  9647. {
  9648. builder.MoveToBookmark(key);
  9649. builder.Write(dic[key]);
  9650. }
  9651. }
  9652. #endregion
  9653. //文件名
  9654. string strFileName = $"{_EnterExitCosts.DraftName}_出入境费用-草稿{Guid.NewGuid().ToString()}.docx";
  9655. strFileName = CommonFun.ValidFileName(strFileName);
  9656. AsposeHelper.removewatermark_v2180();
  9657. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  9658. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  9659. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  9660. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  9661. }
  9662. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  9663. {
  9664. //获取模板
  9665. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  9666. //载入模板
  9667. Document doc = new Document(tempPath);
  9668. DocumentBuilder builder = new DocumentBuilder(doc);
  9669. Dictionary<string, string> dic = new Dictionary<string, string>();
  9670. string returnCodeLabel = string.Empty;
  9671. if (nationalTravelFeeData.Any())
  9672. {
  9673. List<string> list = new List<string>();
  9674. foreach (var item in nationalTravelFeeData)
  9675. {
  9676. list.Add($"{item.Country}({item.City})");
  9677. }
  9678. list = list.Distinct().ToList();
  9679. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  9680. }
  9681. var countryLabel = string.Empty;
  9682. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  9683. if (countryData.Any())
  9684. {
  9685. countryLabel = string.Join("、", countryData);
  9686. }
  9687. dic.Add("ReturnCodeAir", returnCodeLabel);
  9688. dic.Add("VisitStartDate", "-");
  9689. dic.Add("VisitEndDate", "-");
  9690. dic.Add("Day", "-");
  9691. dic.Add("VisitCountry", countryLabel);
  9692. dic.Add("ClientUnit", "-");
  9693. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  9694. //dic.Add("Names", Names);
  9695. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  9696. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  9697. decimal dac1totalPrice = 0.00M;
  9698. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  9699. foreach (var dac in dac1)
  9700. {
  9701. if (dac.SubTotal == 0.00M)
  9702. {
  9703. continue;
  9704. }
  9705. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  9706. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  9707. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  9708. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  9709. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  9710. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  9711. builder.Write(currency);//币种
  9712. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  9713. builder.Write(dac.Cost.ToString("#0.00"));//标准
  9714. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  9715. builder.Write("");//人数
  9716. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  9717. builder.Write("");//天数
  9718. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  9719. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  9720. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  9721. decimal rate = 0.00M;
  9722. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  9723. builder.Write(rate.ToString("#0.0000"));//汇率
  9724. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  9725. decimal rbmPrice = dac.SubTotal;
  9726. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  9727. accommodationStartIndex++;
  9728. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  9729. }
  9730. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  9731. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  9732. {
  9733. table1.Rows.RemoveAt(i - 1);
  9734. foodandotherStartIndex--;
  9735. }
  9736. if (dac2.Count == dac3.Count)//国家 币种 金额
  9737. {
  9738. for (int i = 0; i < dac2.Count; i++)
  9739. {
  9740. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  9741. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  9742. }
  9743. }
  9744. decimal dac2totalPrice = 0.00M;
  9745. foreach (var dac in dac2)
  9746. {
  9747. if (dac.SubTotal == 0)
  9748. {
  9749. continue;
  9750. }
  9751. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  9752. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  9753. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  9754. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  9755. builder.Write(currency);//币种
  9756. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  9757. builder.Write(dac.Cost.ToString("#0.00"));//标准
  9758. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  9759. builder.Write("");//人数
  9760. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  9761. builder.Write("");//天数
  9762. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  9763. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  9764. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  9765. decimal rate = 0.00M;
  9766. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  9767. builder.Write(rate.ToString("#0.0000"));//汇率
  9768. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  9769. decimal rbmPrice = dac.SubTotal;
  9770. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  9771. foodandotherStartIndex++;
  9772. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  9773. }
  9774. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  9775. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  9776. {
  9777. table1.Rows.RemoveAt(i - 1);
  9778. }
  9779. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  9780. string otherFeeStr = "";
  9781. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  9782. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  9783. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  9784. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  9785. foreach (var otherInfo in dac5)
  9786. {
  9787. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  9788. }
  9789. #endregion
  9790. if (otherFeeStr.Length > 0)
  9791. {
  9792. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  9793. otherFeeStr = $"({otherFeeStr})";
  9794. dic.Add("OtherFeeStr", otherFeeStr);
  9795. }
  9796. //总计
  9797. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  9798. //国际旅费
  9799. string outsideAir = string.Empty;
  9800. string allPriceAir = string.Empty;
  9801. if (_EnterExitCosts.SumJJC == 1)
  9802. {
  9803. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  9804. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  9805. }
  9806. if (_EnterExitCosts.SumGWC == 1)
  9807. {
  9808. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  9809. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  9810. }
  9811. if (_EnterExitCosts.SumTDC == 1)
  9812. {
  9813. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  9814. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  9815. }
  9816. dic.Add("InTravelPrice", $"({outsideAir})");
  9817. dic.Add("FinalSumPrice", $"({allPriceAir})");
  9818. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  9819. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  9820. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  9821. foreach (var key in dic.Keys)
  9822. {
  9823. builder.MoveToBookmark(key);
  9824. builder.Write(dic[key]);
  9825. }
  9826. //模板文件名
  9827. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  9828. strFileName = CommonFun.ValidFileName(strFileName);
  9829. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  9830. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  9831. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  9832. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  9833. }
  9834. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  9835. {
  9836. //获取模板
  9837. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  9838. //载入模板
  9839. WorkbookDesigner designer = new WorkbookDesigner();
  9840. designer.Workbook = new Workbook(tempPath);
  9841. Dictionary<string, string> dic = new Dictionary<string, string>();
  9842. string returnCodeLabel = string.Empty;
  9843. if (nationalTravelFeeData.Any())
  9844. {
  9845. List<string> list = new List<string>();
  9846. foreach (var item in nationalTravelFeeData)
  9847. {
  9848. list.Add($"{item.Country}({item.City})");
  9849. }
  9850. list = list.Distinct().ToList();
  9851. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  9852. }
  9853. var countryLabel = string.Empty;
  9854. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  9855. if (countryData.Any())
  9856. {
  9857. countryLabel = string.Join("、", countryData);
  9858. }
  9859. dic.Add("ReturnCodeAir", returnCodeLabel);
  9860. dic.Add("VisitStartDate", "-");
  9861. dic.Add("VisitEndDate", "-");
  9862. dic.Add("Day", "0");
  9863. dic.Add("VisitCountry", countryLabel);
  9864. dic.Add("ClientUnit", "-");
  9865. designer.SetDataSource("ClientUnit", "-");
  9866. designer.SetDataSource("VisitCountry", countryLabel);
  9867. designer.SetDataSource("Group", "-");
  9868. designer.SetDataSource("ClientUnitTitle", "-");
  9869. designer.SetDataSource("Name", "-");
  9870. designer.SetDataSource("VisitStartDate", "-");
  9871. designer.SetDataSource("Day", "0");
  9872. designer.SetDataSource("ReturnCode", returnCodeLabel);
  9873. designer.SetDataSource("ReturnCodeAir", "-");
  9874. int startIndex = 10;
  9875. const int startIndexcopy = 10;
  9876. if (dac2.Count == dac3.Count)//国家 币种 金额
  9877. {
  9878. for (int i = 0; i < dac2.Count; i++)
  9879. {
  9880. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  9881. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  9882. }
  9883. }
  9884. DataTable dtdac1 = new DataTable();
  9885. List<string> place = new List<string>();
  9886. dtdac1.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. DataTable dtdac2 = new DataTable();
  9897. dtdac2.Columns.AddRange(new DataColumn[] {
  9898. new DataColumn(){ ColumnName = "city"},
  9899. new DataColumn(){ ColumnName = "curr"},
  9900. new DataColumn(){ ColumnName = "criterion"},
  9901. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  9902. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  9903. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  9904. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  9905. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  9906. });
  9907. dtdac1.TableName = "tb1";
  9908. dtdac2.TableName = "tb2";
  9909. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  9910. foreach (var item in dac1)
  9911. {
  9912. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  9913. if (place.Contains(item.Place))
  9914. {
  9915. continue;
  9916. }
  9917. DataRow row = dtdac1.NewRow();
  9918. row["city"] = item.Place;
  9919. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  9920. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  9921. row["curr"] = currency;
  9922. row["rate"] = rate.ToString("#0.0000");
  9923. row["criterion"] = item.Cost.ToString("#0.00");
  9924. row["number"] = 1;
  9925. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  9926. //row["costRMB"] = rbmPrice;
  9927. dtdac1.Rows.Add(row);
  9928. place.Add(item.Place);
  9929. }
  9930. place = new List<string>();
  9931. foreach (var item in dac2)
  9932. {
  9933. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  9934. if (place.Contains(item.Place))
  9935. {
  9936. continue;
  9937. }
  9938. DataRow row = dtdac2.NewRow();
  9939. row["city"] = item.Place;
  9940. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  9941. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  9942. row["curr"] = currency;
  9943. row["rate"] = rate.ToString("#0.0000");
  9944. row["criterion"] = item.Cost.ToString("#0.00");
  9945. row["number"] = 1;
  9946. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  9947. //row["cost"] = item.SubTotal;
  9948. //row["costRMB"] = rbmPrice;
  9949. dtdac2.Rows.Add(row);
  9950. place.Add(item.Place);
  9951. //dac2totalPrice += rbmPrice;
  9952. }
  9953. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  9954. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  9955. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  9956. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  9957. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic:#0.00} 元");
  9958. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic:#0.00} ");
  9959. string cell4Str1 = string.Empty;
  9960. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ:#0.00} 元/人;";
  9961. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW:#0.00} 元/人;";
  9962. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD:#0.00} 元/人;";
  9963. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  9964. string cellStr = $" 5.其他费用(";
  9965. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  9966. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  9967. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  9968. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  9969. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  9970. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  9971. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  9972. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  9973. foreach (var otherInfo in dac5)
  9974. {
  9975. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal:#0.00} 元,";
  9976. }
  9977. #endregion
  9978. if (cellStr.Length > 8)
  9979. {
  9980. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  9981. }
  9982. cellStr += ")";
  9983. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  9984. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  9985. decimal pxFee = dac4.Sum(it => it.Cost);
  9986. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  9987. string celllastStr1 = "";
  9988. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice:#0.00} 元";
  9989. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice:#0.00} 元";
  9990. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee:#0.00} 元";
  9991. celllastStr1 += $",国际旅费 元";
  9992. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee:#0.00} 元";
  9993. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  9994. designer.SetDataSource("cell4Str", cell4Str);
  9995. designer.SetDataSource("cellStr", cellStr);
  9996. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  9997. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  9998. designer.SetDataSource("celllastStr", celllastStr);
  9999. Workbook wb = designer.Workbook;
  10000. var sheet = wb.Worksheets[0];
  10001. //绑定datatable数据集
  10002. designer.SetDataSource(dtdac1);
  10003. designer.SetDataSource(dtdac2);
  10004. designer.Process();
  10005. var rowStart = dtdac1.Rows.Count;
  10006. while (rowStart > 0)
  10007. {
  10008. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  10009. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  10010. startIndex++;
  10011. rowStart--;
  10012. }
  10013. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  10014. startIndex += 1; //总计行
  10015. rowStart = dtdac2.Rows.Count;
  10016. while (rowStart > 0)
  10017. {
  10018. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  10019. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  10020. startIndex++;
  10021. rowStart--;
  10022. }
  10023. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  10024. wb.CalculateFormula(true);
  10025. //模板文件名
  10026. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  10027. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  10028. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  10029. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  10030. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  10031. }
  10032. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  10033. {
  10034. //获取模板
  10035. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  10036. //载入模板
  10037. Document doc = new Document(tempPath);
  10038. DocumentBuilder builder = new DocumentBuilder(doc);
  10039. Dictionary<string, string> dic = new Dictionary<string, string>();
  10040. dic.Add("GroupName", "-");
  10041. dic.Add("ClientUnit", "-");
  10042. //string missionLeader = ""; //团负责人默认接团客户名单第一个人
  10043. //string missionLeaderJob = "";//负责人job
  10044. //int groupNumber = 0; //团人数
  10045. dic.Add("MissionLeader", "-"); //团负责人
  10046. dic.Add("MissionLeaderJob", "-"); //团负责人job
  10047. dic.Add("GroupNumber", "0"); //团人数
  10048. dic.Add("Day", "0");
  10049. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  10050. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  10051. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  10052. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  10053. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  10054. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  10055. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  10056. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  10057. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  10058. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  10059. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  10060. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  10061. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  10062. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  10063. //其他费用
  10064. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  10065. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  10066. //其他费用合计
  10067. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  10068. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  10069. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  10070. //公务舱合计
  10071. //国际旅费
  10072. //string outsideJJ = "";
  10073. //string allPriceJJ = "";
  10074. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  10075. {
  10076. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  10077. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  10078. }
  10079. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  10080. {
  10081. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  10082. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  10083. }
  10084. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  10085. {
  10086. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ:#0.00} 公务舱:{_EnterExitCosts.AirGW:#0.00}");
  10087. dic.Add("AirFeeTotal", airFeeTotalStr);
  10088. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal:#0.00} 公务舱:{_gwcFeeToatal:#0.00}");
  10089. dic.Add("FeeTotal", feeTotalStr);
  10090. }
  10091. foreach (var key in dic.Keys)
  10092. {
  10093. builder.MoveToBookmark(key);
  10094. builder.Write(dic[key]);
  10095. }
  10096. //模板文件名
  10097. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  10098. strFileName = CommonFun.ValidFileName(strFileName);
  10099. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  10100. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  10101. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  10102. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  10103. }
  10104. }
  10105. else if (dto.ExportType == 2) //表格
  10106. {
  10107. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  10108. }
  10109. else if (dto.ExportType == 3)
  10110. {
  10111. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  10112. }
  10113. return Ok(JsonView(400, "只可导出明细表!", ""));
  10114. }
  10115. catch (Exception ex)
  10116. {
  10117. return Ok(JsonView(400, ex.Message, ""));
  10118. }
  10119. }
  10120. /// <summary>
  10121. /// 获取三公费用标准city
  10122. /// </summary>
  10123. /// <param name="placeData"></param>
  10124. /// <param name="nationalTravelFeeId"></param>
  10125. /// <returns></returns>
  10126. private string GetEnterExitCostDraftExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  10127. {
  10128. string _city = string.Empty;
  10129. if (!placeData.Any()) return _city;
  10130. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  10131. if (data == null) return _city;
  10132. string country = data.Country;
  10133. string city = data.City;
  10134. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  10135. else _city = city;
  10136. return _city;
  10137. }
  10138. /// <summary>
  10139. /// 团组模块 - 出入境费用-草稿 - 一键清空
  10140. /// </summary>
  10141. /// <returns></returns>
  10142. [HttpPost]
  10143. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  10144. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10145. public async Task<IActionResult> EnterExitCostDraftOneClickEmpty(EnterExitCostDraftOneClickEmptyDto dto)
  10146. {
  10147. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  10148. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  10149. var _view = await _enterExitCostDraftRep.OneClickEmpty(dto.Id, dto.UserId);
  10150. if (_view.Code == 0)
  10151. {
  10152. return Ok(JsonView(true, "操作成功"));
  10153. }
  10154. return Ok(JsonView(false, "操作失败"));
  10155. }
  10156. /// <summary>
  10157. /// 团组模块 - 出入境费用-草稿 - 子项删除
  10158. /// </summary>
  10159. /// <returns></returns>
  10160. [HttpPost]
  10161. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  10162. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10163. public async Task<IActionResult> EnterExitCostDraftSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  10164. {
  10165. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  10166. if (data.Code != 0)
  10167. {
  10168. return Ok(JsonView(false, data.Msg));
  10169. }
  10170. return Ok(JsonView(true, "操作成功!", data.Data));
  10171. }
  10172. /// <summary>
  10173. /// 三公其他费用草稿 删除
  10174. /// </summary>
  10175. /// <param name="dto"></param>
  10176. /// <returns></returns>
  10177. [HttpPost]
  10178. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  10179. public IActionResult EnterExitCostDraftOtherExpensesDel(EnterExitCostDraftOtherExpensesDelDto dto)
  10180. {
  10181. var jw = JsonView(false, "删除失败!");
  10182. var data = new Grp_DayOtherPriceDraft()
  10183. {
  10184. Id = dto.Id,
  10185. IsDel = 1,
  10186. DeleteUserId = dto.DeleteUserId,
  10187. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  10188. };
  10189. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  10190. if (del > 0)
  10191. {
  10192. jw.Code = 200;
  10193. jw.Msg = "删除成功!";
  10194. }
  10195. return Ok(jw);
  10196. }
  10197. /// <summary>
  10198. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用基础数据
  10199. /// </summary>
  10200. /// <returns></returns>
  10201. [HttpPost]
  10202. public async Task<IActionResult> EnterExitCostDraftImportDataInit()
  10203. {
  10204. var jw = JsonView(false);
  10205. var groupNameDatas = await _groupRepository.EnterExitCostGroupNameAsync();
  10206. var draftDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0).OrderByDescending(x => x.CreateTime).Select(x => new { x.Id, x.DraftName }).ToListAsync();
  10207. jw.Code = StatusCodes.Status200OK;
  10208. jw.Msg = "操作成功!";
  10209. jw.Data = new { groupNameDatas = groupNameDatas, draftNames = draftDatas };
  10210. return Ok(jw);
  10211. }
  10212. /// <summary>
  10213. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用
  10214. /// </summary>
  10215. /// <param name="dto"></param>
  10216. /// <returns></returns>
  10217. [HttpPost]
  10218. public async Task<IActionResult> EnterExitCostDraftImportData(EnterExitCostDraftImportDataDto dto)
  10219. {
  10220. int userId = dto.UserId,
  10221. portId = dto.PortType,
  10222. groupId = dto.GroupId,
  10223. draftId = dto.DraftId;
  10224. _portTypeData.Add(1);
  10225. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10226. if (!_portTypeData.Contains(portId)) return Ok(JsonView(false, MsgTips.Port));
  10227. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId!"));
  10228. if (draftId < 1) return Ok(JsonView(false, "请传入有效的DraftId!"));
  10229. _sqlSugar.BeginTran();
  10230. try
  10231. {
  10232. var draftDatas = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).First();
  10233. if (draftDatas == null)
  10234. {
  10235. _sqlSugar.RollbackTran();
  10236. return Ok(JsonView(false, "草稿数据为空,不可导入!"));
  10237. }
  10238. //验证可覆盖已有数据 两边创建人需为同一人;
  10239. int draftCreateUserId = draftDatas.CreateUserId,
  10240. formalCreateUserId = 0;
  10241. var formalData = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  10242. if (formalData != null)
  10243. {
  10244. formalCreateUserId = formalData.CreateUserId;
  10245. if (draftCreateUserId != formalCreateUserId)
  10246. {
  10247. _sqlSugar.RollbackTran();
  10248. return Ok(JsonView(false, "由草稿数据到入至正式数据,两边创建人为同一人才可导入正式版!"));
  10249. }
  10250. }
  10251. //默认添加查看、编辑权限(创建人、自己)
  10252. await _enterExitCostRep.InitPerm(dto.GroupId, dto.UserId);
  10253. var dayDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  10254. var otherDatas = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  10255. var newExterData = _mapper.Map<Grp_EnterExitCost>(draftDatas);
  10256. newExterData.DiId = groupId;
  10257. newExterData.CreateUserId = userId;
  10258. newExterData.Remark = $"由草稿数据导入;草稿数Id:{draftId}";
  10259. var newDayDatas = _mapper.Map<List<Grp_DayAndCost>>(dayDatas);
  10260. if (newDayDatas.Any()) newDayDatas.Select(x => { x.DiId = groupId; x.CreateUserId = userId; return x; }).ToList();
  10261. var newOtherDatas = _mapper.Map<List<Grp_DayOtherPrice>>(otherDatas);
  10262. if (newOtherDatas.Any()) newOtherDatas.Select(x => { x.Diid = groupId; x.CreateUserId = userId; return x; }).ToList();
  10263. var enterExitCostInfo = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  10264. //数据如果存在执行删除
  10265. if (enterExitCostInfo != null)
  10266. {
  10267. _sqlSugar.Updateable<Grp_EnterExitCost>()
  10268. .SetColumns(x => new Grp_EnterExitCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Remark = "由草稿数据导入前软删除数据!" })
  10269. .Where(x => x.Id == enterExitCostInfo.Id)
  10270. .ExecuteCommand();
  10271. _sqlSugar.Updateable<Grp_DayAndCost>()
  10272. .SetColumns(x => new Grp_DayAndCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  10273. .Where(x => x.DiId == groupId)
  10274. .ExecuteCommand();
  10275. _sqlSugar.Updateable<Grp_DayOtherPrice>()
  10276. .SetColumns(x => new Grp_DayOtherPrice() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  10277. .Where(x => x.Diid == groupId)
  10278. .ExecuteCommand();
  10279. _sqlSugar.Updateable<Grp_EnterExitCostPermission>()
  10280. .SetColumns(x => new Grp_EnterExitCostPermission() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  10281. .Where(x => x.GroupId == groupId)
  10282. .ExecuteCommand();
  10283. }
  10284. //执行insert
  10285. var insertId = _sqlSugar.Insertable(newExterData).ExecuteReturnIdentity();
  10286. if (insertId < 1)
  10287. {
  10288. _sqlSugar.RollbackTran();
  10289. return Ok(JsonView(false, "草稿数据导入失败!"));
  10290. }
  10291. if (newDayDatas.Any()) _sqlSugar.Insertable(newDayDatas).ExecuteCommand();
  10292. if (newOtherDatas.Any()) _sqlSugar.Insertable(newOtherDatas).ExecuteCommand();
  10293. #region 默认添加权限
  10294. #endregion
  10295. _sqlSugar.CommitTran();
  10296. //执行操作之后
  10297. //生成默认文件pdf并且通知人员
  10298. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  10299. {
  10300. DiId = groupId,
  10301. ExportType = 1,
  10302. SubTypeId = 1005
  10303. }, "pdf");
  10304. //发送通知
  10305. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  10306. string md5Sign = GeneralMethod.Encrypt($"{insertId}&fileName={fileUrl}");
  10307. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", insertId, fileUrl);
  10308. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(groupId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  10309. //汇率信息记录
  10310. await GeneralMethod.RateRecordSave(userId, insertId, "出入境费用-草稿导入");
  10311. return Ok(JsonView(true));
  10312. }
  10313. catch (Exception ex)
  10314. {
  10315. _sqlSugar.RollbackTran();
  10316. return Ok(JsonView(false, ex.Message));
  10317. }
  10318. }
  10319. #endregion
  10320. #region 团组经理模块 出入境费用 移动端(Android/IOS)
  10321. /// <summary>
  10322. /// 获取币种基础数据(含逻辑处理)
  10323. /// </summary>
  10324. /// <returns></returns>
  10325. private async Task<List<CurrencyInfo>> EnterExitCostMobileGetCurrencyInit()
  10326. {
  10327. return await GeneralMethod.EnterExitCostInitRate();
  10328. }
  10329. /// <summary>
  10330. /// 团组模块 - 出入境费用-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  10331. /// </summary>
  10332. /// <returns></returns>
  10333. [HttpPost]
  10334. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10335. public async Task<IActionResult> EnterExitCostMobileDataSource(EnterExitCostMobileDataSourceDto dto)
  10336. {
  10337. //验证城市归属并给默认值
  10338. int provinceId = dto.ProvinceId;
  10339. if (provinceId < 1) provinceId = 122;
  10340. var dataSource = await _sqlSugar
  10341. .Queryable<Sys_SetData>()
  10342. .Where(x => x.IsDel == 0 && (x.STid == 72 || x.STid == 73) && x.Remark.Contains(provinceId.ToString()))
  10343. .ToListAsync();
  10344. var fileTypes = new List<EecSetDataInfoView>();
  10345. //三公费用-Word明细类型
  10346. var wordTypeData = dataSource
  10347. .Where(it => it.STid == 72)
  10348. .Select(x => new EecSetDataInfoView
  10349. {
  10350. ParentId = 1,
  10351. Id = x.Id,
  10352. Name = x.Name
  10353. })
  10354. .ToArray();
  10355. if (wordTypeData.Any()) fileTypes.AddRange(wordTypeData);
  10356. var excelTypeData = dataSource
  10357. .Where(it => it.STid == 73)
  10358. .Select(x => new EecSetDataInfoView
  10359. {
  10360. ParentId = 2,
  10361. Id = x.Id,
  10362. Name = x.Name
  10363. })
  10364. .ToArray();
  10365. if (excelTypeData.Any()) fileTypes.AddRange(excelTypeData);
  10366. var groupNameList = new EecSetDataInfoView() { ParentId = 3, Id = 1, Name = "团组成员名单" };
  10367. fileTypes.Add(groupNameList);
  10368. fileTypes = fileTypes.OrderBy(x => x.ParentId).ThenBy(x => x.Id).ToList();
  10369. //默认币种显示
  10370. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  10371. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  10372. return Ok(JsonView(true, "查询成功!", new
  10373. {
  10374. FileTypeData = fileTypes,
  10375. CurrencyInit = _currencyInfos,
  10376. viewPermissionData = viewPermissionData
  10377. }));
  10378. }
  10379. /// <summary>
  10380. /// 团组模块 - 出入境费用-移动端 - 团组基础数据Data
  10381. /// </summary>
  10382. /// <returns></returns>
  10383. [HttpPost]
  10384. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10385. public async Task<IActionResult> EnterExitCostMobileGroupData(PostEnterExitCostMobileGroupDataDto dto)
  10386. {
  10387. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10388. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10389. RefAsync<int> total = 0;
  10390. int diId = 0;
  10391. var status = int.TryParse(dto.GroupName, out diId);
  10392. var basicUserId = await _enterExitCostRep.PermissionViewUsersAsync();
  10393. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  10394. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  10395. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  10396. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  10397. .OrderByDescending(x => x.VisitStartDate)
  10398. .Select(x => new EnterExitCostMobileGroupView()
  10399. {
  10400. Id = x.Id,
  10401. GroupName = x.TeamName,
  10402. IsNull = SqlFunc.Subqueryable<Grp_EnterExitCost>().Where(x1 => x1.DiId == x.Id && x1.IsDel == 0).Any() ? false : true,
  10403. IsView = SqlFunc.Subqueryable<Grp_EnterExitCostPermission>().Where(x1 => x1.GroupId == x.Id && x1.UserId == dto.CurrUserId).Any(),
  10404. ProvinceId = x.CityId
  10405. })
  10406. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10407. //处理省份Id
  10408. if (data.Any())
  10409. {
  10410. var provCityDatas = await _groupRepository.ProvinceCityBasicSource();
  10411. if (provCityDatas.Any())
  10412. {
  10413. foreach (var item in data)
  10414. {
  10415. var provinceId = item.ProvinceId;
  10416. var isDefualtVal = true;
  10417. if (provinceId > 0)
  10418. {
  10419. var parentId = _groupRepository.FindParentIdByChildId(provCityDatas, provinceId);
  10420. if (parentId != null)
  10421. {
  10422. isDefualtVal = false;
  10423. item.ProvinceId = (int)parentId;
  10424. }
  10425. }
  10426. if (isDefualtVal)
  10427. {
  10428. item.ProvinceId = 122; //默认四川
  10429. }
  10430. }
  10431. }
  10432. }
  10433. //处理是否显示
  10434. if (basicUserId.Any(x => x.Id == dto.CurrUserId))
  10435. {
  10436. foreach (var item in data)
  10437. {
  10438. item.IsView = true;
  10439. }
  10440. }
  10441. return Ok(JsonView(true, "查询成功!", data, total));
  10442. }
  10443. /// <summary>
  10444. /// 团组模块 - 出入境费用-移动端 - 币种基础数据Data
  10445. /// </summary>
  10446. /// <returns></returns>
  10447. [HttpPost]
  10448. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10449. public async Task<IActionResult> EnterExitCostMobileCurrencyData(PostEnterExitCostMobileCurrencyDataDto dto)
  10450. {
  10451. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10452. RefAsync<int> total = 0;
  10453. var data = await _sqlSugar.Queryable<Sys_SetData>()
  10454. .Where(x => x.IsDel == 0 && x.STid == 66)
  10455. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  10456. .Select(x => new
  10457. {
  10458. id = x.Id,
  10459. name = x.Name,
  10460. remark = x.Remark,
  10461. })
  10462. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10463. return Ok(JsonView(true, "查询成功!", data, total));
  10464. }
  10465. /// <summary>
  10466. /// 团组模块 - 出入境费用-移动端 - 其他款项 - 币种、费用类型基础数据Data
  10467. /// </summary>
  10468. /// <returns></returns>
  10469. [HttpPost]
  10470. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10471. public async Task<IActionResult> EnterExitCostMobileOtherItemCurrencyData(PostEnterExitCostMobileOtherItemCurrencyDataDto dto)
  10472. {
  10473. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10474. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10475. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType, dto.DiId, 98);
  10476. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  10477. var groupOtherRateData = groupRateData.TeamRates;
  10478. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  10479. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  10480. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  10481. groupOtherRateData = groupOtherRateData
  10482. .Select(x => new TeamRateDescAddCurrencyIdView
  10483. {
  10484. CurrencyId = x.CurrencyId,
  10485. CurrencyName = x.CurrencyName,
  10486. CurrencyCode = x.CurrencyCode,
  10487. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  10488. }).ToList();
  10489. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  10490. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  10491. }
  10492. /// <summary>
  10493. /// 团组模块 - 出入境费用-移动端 - 实时汇率、签证费用、机票费用 Tips
  10494. /// </summary>
  10495. /// <returns></returns>
  10496. [HttpPost]
  10497. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10498. public async Task<IActionResult> EnterExitCostMobileFeeTips(GetEnterExitCostMobileFeeTipsDto dto)
  10499. {
  10500. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10501. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10502. var tipsData = new List<int>() { 1, 2, 3 };
  10503. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  10504. if (dto.TipsType == 1)
  10505. {
  10506. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  10507. }
  10508. else if (dto.TipsType == 2)
  10509. {
  10510. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.GroupId);
  10511. return Ok(JsonView(true, "查询成功!", visaData.Data));
  10512. }
  10513. else if (dto.TipsType == 3)
  10514. {
  10515. var airData = await GeneralMethod.EntryAndExitTips(dto.GroupId);
  10516. return Ok(JsonView(true, "查询成功!", airData));
  10517. }
  10518. return Ok(JsonView(false));
  10519. }
  10520. /// <summary>
  10521. /// 团组模块 - 出入境国家费用标准-移动端 List
  10522. /// </summary>
  10523. /// <returns></returns>
  10524. [HttpPost]
  10525. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10526. public async Task<IActionResult> NationalTravelFeeMobileData(PostNationalTravelFeeMobileDataDto dto)
  10527. {
  10528. Stopwatch sw = new Stopwatch();
  10529. sw.Start();
  10530. int provinceId = dto.ProvinceId;
  10531. if (provinceId < 1) provinceId = 122; // 默认四川
  10532. RefAsync<int> total = 0;
  10533. var data = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  10534. .LeftJoin<Sys_SetData>((ntf, sd) => ntf.Currency == sd.Id)
  10535. .LeftJoin<Sys_Users>((ntf, sd, u) => ntf.CreateUserId == u.Id)
  10536. .LeftJoin<Sys_Cities>((ntf, sd, u, sd1) => ntf.ProvinceId == sd1.Id)
  10537. .Where((ntf, sd, u, sd1) => ntf.IsDel == 0 && ntf.ProvinceId == provinceId)
  10538. .WhereIF(!string.IsNullOrEmpty(dto.Search), (ntf, sd, u, sd1) => dto.Search.Contains(ntf.Country) || dto.Search.Contains(ntf.City))
  10539. .Select((ntf, sd, u, sd1) => new
  10540. {
  10541. Id = ntf.Id,
  10542. Area = $"{ntf.Country}-{ntf.City}",
  10543. Currency = ntf.Currency,
  10544. CurrencyCode = sd.Name,
  10545. CurrencyName = sd.Remark,
  10546. RoomCost = ntf.RoomCost,
  10547. FoodCost = ntf.FoodCost,
  10548. PublicCost = ntf.PublicCost,
  10549. TrainCost = ntf.TrainCost,
  10550. LastUpdateUserId = ntf.LastUpdateUserId,
  10551. LastUpdateUserName = u.CnName,
  10552. LastUpdateTime = ntf.LastUpdateTime
  10553. })
  10554. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10555. sw.Stop();
  10556. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", data, total));
  10557. }
  10558. /// <summary>
  10559. /// 团组模块 - 出入境费用-移动端 - Info
  10560. /// </summary>
  10561. /// <returns></returns>
  10562. [HttpPost]
  10563. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10564. public async Task<IActionResult> EnterExitCostMobileInfo(EnterExitCostInfobyDiIdDto dto)
  10565. {
  10566. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10567. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10568. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  10569. return Ok(data);
  10570. }
  10571. /// <summary>
  10572. /// 团组模块 - 出入境费用-移动端 - ParentInfo
  10573. /// </summary>
  10574. /// <returns></returns>
  10575. [HttpPost]
  10576. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10577. public async Task<IActionResult> EnterExitCostMobileParentInfo(EnterExitCostInfobyDiIdDto dto)
  10578. {
  10579. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10580. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10581. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10582. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  10583. var mobileInfo = new EnterExitCostMobileParentInfoView();
  10584. mobileInfo.DiId = dto.DiId;
  10585. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  10586. if (eecInfo == null) return Ok(mobileInfo);
  10587. //验证查看权限
  10588. (bool isView, bool isSet) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);
  10589. if (!isView) return Ok(JsonView(false, "没有查看权限!"));
  10590. mobileInfo = _mapper.Map<EnterExitCostMobileParentInfoView>(eecInfo);
  10591. mobileInfo.IsAssignPerm = isSet;
  10592. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCost>()
  10593. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10594. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10595. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  10596. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  10597. {
  10598. SubId = dac.Id,
  10599. DiId = dac.DiId,
  10600. Type = dac.Type,
  10601. Days = dac.Days,
  10602. NationalTravelFeeId = dac.NationalTravelFeeId,
  10603. Arae = $"{ntf.Country}-{ntf.City}",
  10604. Cost = dac.Cost,
  10605. Currency = dac.Currency,
  10606. CurrencyName = sd.Name,
  10607. SubTotal = dac.SubTotal,
  10608. })
  10609. .ToList();
  10610. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  10611. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  10612. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  10613. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  10614. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  10615. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  10616. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  10617. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  10618. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  10619. //其他款项
  10620. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  10621. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  10622. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  10623. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  10624. .OrderBy((dop, sd1, sd2) => dop.Index)
  10625. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  10626. {
  10627. SubId = dop.Id,
  10628. DiId = dop.Diid,
  10629. Index = dop.Index,
  10630. SetDataId = dop.SetDataId,
  10631. SetDataName = sd1.Name,
  10632. Cost = dop.Cost,
  10633. Currency = dop.Currency,
  10634. CurrencyName = sd2.Remark,
  10635. SubTotal = dop.SubTotal,
  10636. Remark = dop.Remark,
  10637. })
  10638. .ToArray();
  10639. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  10640. return Ok(mobileInfo);
  10641. }
  10642. /// <summary>
  10643. /// 团组模块 - 出入境费用-移动端 - 查看权限用户
  10644. /// </summary>
  10645. /// <returns></returns>
  10646. [HttpPost]
  10647. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10648. public async Task<IActionResult> EnterExitCostMobileViewPermissionUsers(EnterExitCostMobileViewPermissionUsersDto dto)
  10649. {
  10650. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10651. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10652. //验证查看权限
  10653. (bool viewPerm, bool assignPerm) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);//分配权限
  10654. if (!viewPerm) return Ok(JsonView(false, "未分配查看权限,如要查看,请联系市场部或国交部负责人!"));
  10655. var userIds = await _sqlSugar
  10656. .Queryable<Grp_EnterExitCostPermission>()
  10657. .Where(x => x.IsDel == 0 && x.GroupId == dto.DiId)
  10658. .Select(x => x.UserId)
  10659. .ToArrayAsync();
  10660. var perUsers = await _enterExitCostRep.PermissionViewUsersAsync();
  10661. var perUsersView = new List<dynamic>();
  10662. foreach (var item in perUsers)
  10663. {
  10664. bool isView1 = false;
  10665. if (userIds.Any(x => x == item.Id)) isView1 = true;
  10666. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  10667. }
  10668. return Ok(JsonView(perUsersView));
  10669. }
  10670. /// <summary>
  10671. /// 团组模块 - 出入境费用-移动端 - SubInfo
  10672. /// </summary>
  10673. /// <returns></returns>
  10674. [HttpPost]
  10675. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10676. public async Task<IActionResult> EnterExitCostMobileSubInfo(PostEnterExitCostMobileSubInfoDto dto)
  10677. {
  10678. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10679. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10680. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10681. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  10682. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  10683. //验证查看权限
  10684. //(bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  10685. //if (!isView) return Ok(JsonView(false, msg));
  10686. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  10687. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  10688. var subType = dto.SubType;
  10689. if (subType == 1) //1:境内费用
  10690. {
  10691. var oneData = new ChoiceOneMobileSubInfoView()
  10692. {
  10693. Id = eecInfo.Id,
  10694. ChoiceOne = eecInfo.ChoiceOne,
  10695. ChoiceOneTotalCost = eecInfo.InsidePay,
  10696. Visa = eecInfo.Visa,
  10697. VisaRemark = eecInfo.VisaRemark,
  10698. YiMiao = eecInfo.YiMiao,
  10699. HeSuan = eecInfo.HeSuan,
  10700. Service = eecInfo.Service,
  10701. Ticket = eecInfo.Ticket,
  10702. Safe = eecInfo.Safe,
  10703. FirstItemRemark = eecInfo.FirstItemRemark
  10704. };
  10705. return Ok(JsonView(oneData));
  10706. }
  10707. else if (subType == 2) //2:国际旅费
  10708. {
  10709. var twoData = new ChoiceTwoMobileSubInfoView()
  10710. {
  10711. Id = eecInfo.Id,
  10712. ChoiceTwoJJ = eecInfo.SumJJC,
  10713. OutsideJJPay = eecInfo.OutsideJJPay,
  10714. ChoiceTwoGW = eecInfo.SumGWC,
  10715. OutsideGWPay = eecInfo.OutsideGWPay,
  10716. ChoiceTwoTD = eecInfo.SumTDC,
  10717. OutsideTDPay = eecInfo.OutsideTDPay,
  10718. AirJJ = eecInfo.AirJJ,
  10719. AirGW = eecInfo.AirGW,
  10720. AirTD = eecInfo.AirTD,
  10721. CityTranffic = eecInfo.CityTranffic,
  10722. TwoItemRemark = eecInfo.TwoItemRemark
  10723. };
  10724. return Ok(JsonView(twoData));
  10725. }
  10726. else if (subType == 3) //3:住宿费
  10727. {
  10728. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  10729. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10730. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10731. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 1)
  10732. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  10733. {
  10734. SubId = dac.Id,
  10735. DiId = dac.DiId,
  10736. Type = dac.Type,
  10737. Days = dac.Days,
  10738. NationalTravelFeeId = dac.NationalTravelFeeId,
  10739. Arae = $"{ntf.Country}-{ntf.City}",
  10740. Cost = dac.Cost,
  10741. Currency = dac.Currency,
  10742. CurrencyName = sd.Name,
  10743. SubTotal = dac.SubTotal,
  10744. })
  10745. .ToArray();
  10746. var data = new ChoiceMobileSubInfo3To6View()
  10747. {
  10748. ParentId = eecInfo.Id,
  10749. Choice = eecInfo.ChoiceThree,
  10750. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10751. Details = dayAndCostDatas
  10752. };
  10753. return Ok(JsonView(data));
  10754. }
  10755. else if (subType == 4) //4:伙食费
  10756. {
  10757. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  10758. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10759. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10760. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 2)
  10761. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  10762. {
  10763. SubId = dac.Id,
  10764. DiId = dac.DiId,
  10765. Type = dac.Type,
  10766. Days = dac.Days,
  10767. NationalTravelFeeId = dac.NationalTravelFeeId,
  10768. Arae = $"{ntf.Country}-{ntf.City}",
  10769. Cost = dac.Cost,
  10770. Currency = dac.Currency,
  10771. CurrencyName = sd.Name,
  10772. SubTotal = dac.SubTotal,
  10773. })
  10774. .ToArray();
  10775. var data = new ChoiceMobileSubInfo3To6View()
  10776. {
  10777. ParentId = eecInfo.Id,
  10778. Choice = eecInfo.ChoiceFour,
  10779. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10780. Details = dayAndCostDatas
  10781. };
  10782. return Ok(JsonView(data));
  10783. }
  10784. else if (subType == 5) //5:公杂费
  10785. {
  10786. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  10787. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10788. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10789. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 3)
  10790. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  10791. {
  10792. SubId = dac.Id,
  10793. DiId = dac.DiId,
  10794. Type = dac.Type,
  10795. Days = dac.Days,
  10796. NationalTravelFeeId = dac.NationalTravelFeeId,
  10797. Arae = $"{ntf.Country}-{ntf.City}",
  10798. Cost = dac.Cost,
  10799. Currency = dac.Currency,
  10800. CurrencyName = sd.Name,
  10801. SubTotal = dac.SubTotal,
  10802. })
  10803. .ToArray();
  10804. var data = new ChoiceMobileSubInfo3To6View()
  10805. {
  10806. ParentId = eecInfo.Id,
  10807. Choice = eecInfo.ChoiceFive,
  10808. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10809. Details = dayAndCostDatas
  10810. };
  10811. return Ok(JsonView(data));
  10812. }
  10813. else if (subType == 6) //6:培训费
  10814. {
  10815. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  10816. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10817. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10818. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 4)
  10819. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  10820. {
  10821. SubId = dac.Id,
  10822. DiId = dac.DiId,
  10823. Type = dac.Type,
  10824. Days = dac.Days,
  10825. NationalTravelFeeId = dac.NationalTravelFeeId,
  10826. Arae = $"{ntf.Country}-{ntf.City}",
  10827. Cost = dac.Cost,
  10828. Currency = dac.Currency,
  10829. CurrencyName = sd.Name,
  10830. SubTotal = dac.SubTotal,
  10831. })
  10832. .ToArray();
  10833. var data = new ChoiceMobileSubInfo3To6View()
  10834. {
  10835. ParentId = eecInfo.Id,
  10836. Choice = eecInfo.ChoiceSix,
  10837. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10838. Details = dayAndCostDatas
  10839. };
  10840. return Ok(JsonView(data));
  10841. }
  10842. else if (subType == 7) //7:其他
  10843. {
  10844. //其他款项
  10845. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  10846. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  10847. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  10848. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  10849. .OrderBy((dop, sd1, sd2) => dop.Index)
  10850. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  10851. {
  10852. SubId = dop.Id,
  10853. DiId = dop.Diid,
  10854. Index = dop.Index,
  10855. SetDataId = dop.SetDataId,
  10856. SetDataName = sd1.Name,
  10857. Cost = dop.Cost,
  10858. Currency = dop.Currency,
  10859. CurrencyName = sd2.Name,
  10860. SubTotal = dop.SubTotal,
  10861. Remark = dop.Remark,
  10862. })
  10863. .ToArray();
  10864. var data = new ChoiceSevenMobileSubInfoView()
  10865. {
  10866. ParentId = eecInfo.Id,
  10867. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  10868. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  10869. Details = otherData
  10870. };
  10871. return Ok(JsonView(data));
  10872. }
  10873. return Ok(JsonView(false));
  10874. }
  10875. #region op
  10876. ///// <summary>
  10877. ///// 移动端更新费用消息通知
  10878. ///// </summary>
  10879. ///// <param name="diid"></param>
  10880. ///// <param name="id"></param>
  10881. ///// <param name="currUserId"></param>
  10882. //private async Task EnterExitCostMobileOpNotice(int diid, int id, int currUserId)
  10883. //{
  10884. // try
  10885. // {
  10886. // ////生成默认文件pdf并且通知人员
  10887. // //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  10888. // //{
  10889. // // DiId = diid,
  10890. // // ExportType = 1,
  10891. // // SubTypeId = 1005
  10892. // //}, "pdf");
  10893. // ////发送通知
  10894. // //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  10895. // //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  10896. // //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  10897. // //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(diid, new List<string>() { "208", "233", "21" }, currUserId, url);
  10898. // ////汇率信息记录
  10899. // //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  10900. // }
  10901. // catch (Exception ex)
  10902. // {
  10903. // //记录日志
  10904. // throw;
  10905. // }
  10906. //}
  10907. /// <summary>
  10908. /// 验证出入境费用数据是否存在
  10909. /// 不存在添加
  10910. /// </summary>
  10911. /// <param name="diId"></param>
  10912. /// <param name="currUserId"></param>
  10913. /// <returns></returns>
  10914. /// <exception cref="CustomException"></exception>
  10915. private async Task<int> EnterExitCostVerifyIsNull(int diId, int currUserId)
  10916. {
  10917. var parentId = 0;
  10918. var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).OrderByDescending(x => x.CreateTime).FirstAsync();
  10919. if (info != null)
  10920. {
  10921. parentId = info.Id;
  10922. }
  10923. else
  10924. {
  10925. var currencys = await EnterExitCostMobileGetCurrencyInit();
  10926. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCost() { DiId = diId, CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  10927. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  10928. parentId = addId;
  10929. }
  10930. return parentId;
  10931. }
  10932. /// <summary>
  10933. /// 团组模块 - 出入境费用-移动端 - 设置view权限
  10934. /// </summary>
  10935. /// <returns></returns>
  10936. [HttpPost]
  10937. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10938. public async Task<IActionResult> EnterExitCostMobileSetViewPermissiion(EnterExitCostMobileSetViewPermissiionDto dto)
  10939. {
  10940. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10941. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10942. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  10943. //验证编辑权限
  10944. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10945. //if (!isEdit) return Ok(JsonView(false, msg));
  10946. var permissions = new List<Grp_EnterExitCostPermission>();
  10947. foreach (var userId in dto.UserIds)
  10948. {
  10949. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = userId, CreateUserId = dto.CurrUserId });
  10950. }
  10951. if (permissions.Any())
  10952. {
  10953. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  10954. {
  10955. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  10956. }
  10957. _sqlSugar.BeginTran();
  10958. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.DiId).ExecuteCommandAsync();
  10959. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  10960. if (result < 1)
  10961. {
  10962. _sqlSugar.RollbackTran();
  10963. return Ok(JsonView(false));
  10964. }
  10965. _sqlSugar.CommitTran();
  10966. return Ok(JsonView(true));
  10967. }
  10968. return Ok(JsonView(false));
  10969. }
  10970. /// <summary>
  10971. /// 团组模块 - 出入境费用-移动端 - OP --> 汇率
  10972. /// </summary>
  10973. /// <returns></returns>
  10974. [HttpPost]
  10975. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10976. public async Task<IActionResult> EnterExitCostMobileOpRate(PostEnterExitCostMobileFeeRateOpDto dto)
  10977. {
  10978. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10979. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10980. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10981. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  10982. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  10983. int id = dto.Id;
  10984. if (id <= 0) //add
  10985. {
  10986. //int provinceId = dto.ProvinceId;
  10987. int groupId = dto.DiId;
  10988. //if (provinceId < 1) provinceId = 122;
  10989. var info = new Grp_EnterExitCost() { DiId = groupId, CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId };
  10990. info.LastUpdateUserId = dto.CurrUserId;
  10991. info.LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  10992. var add = await _sqlSugar.Insertable(info).ExecuteCommandAsync();
  10993. if (add < 1) return Ok(JsonView(false));
  10994. id = add;
  10995. }
  10996. else //update
  10997. {
  10998. ////验证编辑权限
  10999. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  11000. //if (!isEdit) return Ok(JsonView(false, msg));
  11001. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>().SetColumns(x => new Grp_EnterExitCost()
  11002. {
  11003. CurrencyRemark = currencyStr,
  11004. LastUpdateUserId = dto.CurrUserId,
  11005. LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  11006. }).Where(x => x.Id == dto.Id).ExecuteCommandAsync();
  11007. if (upd < 1) return Ok(JsonView(false));
  11008. }
  11009. #region 汇率变更时更改币种相关费用
  11010. var opDayCosts = new List<Grp_DayAndCost>();
  11011. var opDayOtherCosts = new List<Grp_DayOtherPrice>();
  11012. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  11013. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCost>()
  11014. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  11015. .Where((dac, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  11016. .Select((dac, sd) => new
  11017. {
  11018. dac.Id,
  11019. dac.DiId,
  11020. CurrencyCode = sd.Name,
  11021. dac.Cost
  11022. })
  11023. .ToList();
  11024. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  11025. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  11026. .Where((dop, sd) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  11027. .Select((dop, sd) => new
  11028. {
  11029. dop.Id,
  11030. dop.Diid,
  11031. CurrencyCode = sd.Name,
  11032. dop.Cost
  11033. })
  11034. .ToList();
  11035. if (dayCosts.Count > 0)
  11036. {
  11037. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  11038. foreach (var dc in new_dayCosts)
  11039. {
  11040. var thisCurrency = dc.Key.ToUpper();
  11041. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  11042. if (thisRate == 0.00M) continue;
  11043. foreach (var dcSub in dc)
  11044. {
  11045. opDayCosts.Add(new Grp_DayAndCost()
  11046. {
  11047. Id = dcSub.Id,
  11048. DiId = dcSub.DiId,
  11049. Cost = dcSub.Cost,
  11050. SubTotal = dcSub.Cost * thisRate,
  11051. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  11052. });
  11053. }
  11054. }
  11055. if (opDayCosts.Count > 0)
  11056. {
  11057. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  11058. }
  11059. }
  11060. if (dayOtherCosts.Count > 0)
  11061. {
  11062. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  11063. foreach (var dc in new_dayOtherCosts)
  11064. {
  11065. var thisCurrency = dc.Key.ToUpper();
  11066. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  11067. if (thisRate == 0.00M) continue;
  11068. foreach (var dcSub in dc)
  11069. {
  11070. opDayOtherCosts.Add(new Grp_DayOtherPrice()
  11071. {
  11072. Id = dcSub.Id,
  11073. Diid = dcSub.Diid,
  11074. Cost = dcSub.Cost,
  11075. SubTotal = dcSub.Cost * thisRate,
  11076. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  11077. });
  11078. }
  11079. }
  11080. if (opDayOtherCosts.Count > 0)
  11081. {
  11082. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  11083. }
  11084. }
  11085. #endregion
  11086. //消息通知
  11087. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11088. //汇率信息记录
  11089. await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  11090. return Ok(JsonView(new { parentId = id }));
  11091. }
  11092. /// <summary>
  11093. /// 团组模块 - 出入境费用-移动端 - OP --> 复选框
  11094. /// </summary>
  11095. /// <returns></returns>
  11096. [HttpPost]
  11097. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11098. public async Task<IActionResult> EnterExitCostMobileOpCheckbox(PostEnterExitCostMobileFeeOpCheckboxDto dto)
  11099. {
  11100. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11101. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11102. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11103. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11104. var checkboxInfo = _mapper.Map<Grp_EnterExitCost>(dto);
  11105. checkboxInfo.LastUpdateUserId = dto.CurrUserId;
  11106. checkboxInfo.LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  11107. int id = dto.Id;
  11108. if (id <= 0) //add
  11109. {
  11110. checkboxInfo.CreateUserId = dto.CurrUserId;
  11111. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11112. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  11113. if (add < 1) return Ok(JsonView(false));
  11114. }
  11115. else //update
  11116. {
  11117. ////验证编辑权限
  11118. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  11119. //if (!isEdit) return Ok(JsonView(false, msg));
  11120. var upd = await _sqlSugar.Updateable(checkboxInfo)
  11121. .UpdateColumns(x => new
  11122. {
  11123. x.ChoiceOne,
  11124. x.ChoiceTwo,
  11125. x.SumJJC,
  11126. x.SumGWC,
  11127. x.SumTDC,
  11128. x.ChoiceThree,
  11129. x.ChoiceFour,
  11130. x.ChoiceFive,
  11131. x.ChoiceSix,
  11132. x.OtherExpenses_Checked
  11133. })
  11134. .Where(x => x.Id == id)
  11135. .ExecuteCommandAsync();
  11136. if (upd < 1) return Ok(JsonView(false));
  11137. }
  11138. return Ok(JsonView(new { parentId = id }));
  11139. }
  11140. /// <summary>
  11141. /// 团组模块 - 出入境费用-移动端 - OP --> 3-7项复选框单个复选框更改
  11142. /// </summary>
  11143. /// <returns></returns>
  11144. [HttpPost]
  11145. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11146. public async Task<IActionResult> EnterExitCostMobileOpSingleCheckbox(EnterExitCostMobileOpSingleCheckboxDto dto)
  11147. {
  11148. int itemTypeId = dto.ItemType, id = dto.Id, currUserId = dto.CurrUserId, diId = dto.DiId, isSelected = dto.IsSelected;
  11149. // if (provinceId < 1) provinceId = 122;
  11150. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  11151. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11152. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11153. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11154. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  11155. var checkboxInfo = new Grp_EnterExitCost()
  11156. {
  11157. Id = id,
  11158. //ProvinceId = provinceId,
  11159. DiId = diId,
  11160. CreateUserId = currUserId,
  11161. LastUpdateUserId = dto.CurrUserId,
  11162. LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  11163. };
  11164. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  11165. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  11166. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  11167. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  11168. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  11169. if (id <= 0) //add
  11170. {
  11171. checkboxInfo.CreateUserId = dto.CurrUserId;
  11172. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11173. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  11174. if (add < 1) return Ok(JsonView(false));
  11175. }
  11176. else //update
  11177. {
  11178. ////验证编辑权限
  11179. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  11180. //if (!isEdit) return Ok(JsonView(false, msg));
  11181. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>()
  11182. .SetColumns(it => it.LastUpdateUserId == dto.CurrUserId)
  11183. .SetColumns(it => it.LastUpdateTime == DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
  11184. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  11185. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  11186. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  11187. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  11188. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  11189. .Where(x => x.Id == id)
  11190. .ExecuteCommandAsync();
  11191. if (upd < 1) return Ok(JsonView(false));
  11192. }
  11193. return Ok(JsonView(new { parentId = id }));
  11194. }
  11195. /// <summary>
  11196. /// 团组模块 - 出入境费用-移动端 - OP --> 境内费用 Step1
  11197. /// </summary>
  11198. /// <returns></returns>
  11199. [HttpPost]
  11200. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11201. public async Task<IActionResult> EnterExitCostMobileOpStep1(PostEnterExitCostMobileOpStep1Dto dto)
  11202. {
  11203. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11204. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11205. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11206. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11207. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  11208. info.FirstItemRemark = dto.FirstItemRemark;
  11209. info.LastUpdateUserId = dto.CurrUserId;
  11210. info.LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  11211. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  11212. int id = dto.Id;
  11213. if (id <= 0) //add
  11214. {
  11215. info.CreateUserId = dto.CurrUserId;
  11216. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11217. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  11218. if (add < 1) return Ok(JsonView(false));
  11219. id = add;
  11220. }
  11221. else //update
  11222. {
  11223. ////验证编辑权限
  11224. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  11225. //if (!isEdit) return Ok(JsonView(false, msg));
  11226. var upd = await _sqlSugar.Updateable(info)
  11227. .UpdateColumns(x => new
  11228. {
  11229. x.ChoiceOne,
  11230. x.InsidePay,
  11231. x.VisaRemark,
  11232. x.Visa,
  11233. x.Service,
  11234. x.Safe,
  11235. x.Ticket,
  11236. x.HeSuan,
  11237. x.YiMiao,
  11238. x.FirstItemRemark,
  11239. x.LastUpdateUserId,
  11240. x.LastUpdateTime
  11241. })
  11242. .Where(x => x.Id == id)
  11243. .ExecuteCommandAsync();
  11244. if (upd < 1) return Ok(JsonView(false));
  11245. }
  11246. //消息通知
  11247. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11248. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  11249. }
  11250. /// <summary>
  11251. /// 团组模块 - 出入境费用-移动端 - OP --> 国际旅费 Step2
  11252. /// </summary>
  11253. /// <returns></returns>
  11254. [HttpPost]
  11255. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11256. public async Task<IActionResult> EnterExitCostMobileOpStep2(PostEnterExitCostMobileOpStep2Dto dto)
  11257. {
  11258. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11259. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11260. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11261. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11262. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  11263. info.DiId = dto.DiId;
  11264. //info.ProvinceId = dto.ProvinceId;
  11265. info.OutsideJJPay = dto.OutsideJJPay;
  11266. info.OutsideGWPay = dto.OutsideGWPay;
  11267. info.OutsideTDPay = dto.OutsideTDPay;
  11268. info.AirJJ = dto.AirJJ;
  11269. info.AirGW = dto.AirGW;
  11270. info.AirTD = dto.AirTD;
  11271. info.CityTranffic = dto.CityTranffic;
  11272. info.TwoItemRemark = dto.TwoItemRemark;
  11273. info.SumJJC = dto.ChoiceTwoJJ;
  11274. info.SumGWC = dto.ChoiceTwoGW;
  11275. info.SumTDC = dto.ChoiceTwoTD;
  11276. info.LastUpdateUserId = dto.CurrUserId;
  11277. info.LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  11278. int id = dto.Id;
  11279. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  11280. if (id <= 0) //add i
  11281. {
  11282. info.CreateUserId = dto.CurrUserId;
  11283. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11284. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  11285. if (addId <= 0) return Ok(JsonView(false));
  11286. id = addId;
  11287. }
  11288. else //update
  11289. {
  11290. ////验证编辑权限
  11291. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  11292. //if (!isEdit) return Ok(JsonView(false, msg));
  11293. var upd = await _sqlSugar.Updateable(info)
  11294. .UpdateColumns(x => new
  11295. {
  11296. x.SumJJC,
  11297. x.OutsideJJPay,
  11298. x.SumGWC,
  11299. x.OutsideGWPay,
  11300. x.SumTDC,
  11301. x.OutsideTDPay,
  11302. x.AirJJ,
  11303. x.AirGW,
  11304. x.AirTD,
  11305. x.CityTranffic,
  11306. x.TwoItemRemark,
  11307. x.LastUpdateTime,
  11308. x.LastUpdateUserId
  11309. })
  11310. .Where(x => x.Id == id)
  11311. .ExecuteCommandAsync();
  11312. if (upd < 1) return Ok(JsonView(false));
  11313. }
  11314. jjcItemTotal = info.AirJJ + info.CityTranffic;
  11315. gwcItemTotal = info.AirGW + info.CityTranffic;
  11316. tdcItemTotal = info.AirTD + info.CityTranffic;
  11317. //消息通知
  11318. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11319. return Ok(JsonView(new
  11320. {
  11321. parentId = id,
  11322. choiceTwoJJ = dto.ChoiceTwoJJ,
  11323. jjcItemTotal = jjcItemTotal,
  11324. choiceTwoGW = dto.ChoiceTwoGW,
  11325. gwcItemTotal = gwcItemTotal,
  11326. choiceTwoTD = dto.ChoiceTwoTD,
  11327. tdcItemTotal = tdcItemTotal
  11328. }));
  11329. }
  11330. /// <summary>
  11331. /// 团组模块 - 出入境费用-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  11332. /// </summary>
  11333. /// <returns></returns>
  11334. [HttpPost]
  11335. [ApiExplorerSettings(IgnoreApi = true)]
  11336. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11337. public async Task<IActionResult> EnterExitCostMobileOpBatchStep3To6(PostEnterExitCostMobileOpStep3To6Dto dto)
  11338. {
  11339. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11340. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11341. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11342. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  11343. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  11344. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  11345. var infos1 = _mapper.Map<List<Grp_DayAndCost>>(dto.Infos);
  11346. var infos = infos1.Select(x => new Grp_DayAndCost
  11347. {
  11348. Id = x.Id,
  11349. DiId = dto.DiId,
  11350. Type = dto.FeeType,
  11351. Days = x.Days,
  11352. NationalTravelFeeId = x.NationalTravelFeeId,
  11353. Cost = x.Cost,
  11354. Currency = x.Currency,
  11355. SubTotal = x.SubTotal,
  11356. CreateUserId = dto.CurrUserId
  11357. })
  11358. .ToList();
  11359. var adds = infos.Where(x => x.Id <= 0).ToList();
  11360. var upds = infos.Where(x => x.Id > 0).ToList();
  11361. if (adds.Count > 0)
  11362. {
  11363. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  11364. if (add < 1) return Ok(JsonView(false));
  11365. }
  11366. if (upds.Count > 0)
  11367. {
  11368. var upd = await _sqlSugar.Updateable(adds)
  11369. .UpdateColumns(x => new
  11370. {
  11371. x.Days,
  11372. x.NationalTravelFeeId,
  11373. x.Cost,
  11374. x.Currency,
  11375. x.SubTotal
  11376. })
  11377. .WhereColumns(x => new { x.Id })
  11378. .ExecuteCommandAsync();
  11379. if (upd < 1) return Ok(JsonView(false));
  11380. }
  11381. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  11382. //消息通知
  11383. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  11384. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11385. return Ok(JsonView(new { itemTotal = itemTotal }));
  11386. }
  11387. /// <summary>
  11388. /// 团组模块 - 出入境费用-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  11389. /// </summary>
  11390. /// <returns></returns>
  11391. [HttpPost]
  11392. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11393. public async Task<IActionResult> EnterExitCostMobileOpSingleStep3To6(PostEnterExitCostMobileOpSingleStep3To6Dto dto)
  11394. {
  11395. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  11396. int subId = dto.SubId, feeType = dto.FeeType;
  11397. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11398. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11399. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11400. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  11401. var subInfo = _mapper.Map<Grp_DayAndCost>(dto);
  11402. subInfo.Id = subId;
  11403. subInfo.DiId = dto.DiId;
  11404. if (feeType == 3) subInfo.Type = 1;
  11405. else if (feeType == 4) subInfo.Type = 2;
  11406. else if (feeType == 5) subInfo.Type = 3;
  11407. else if (feeType == 6) subInfo.Type = 4;
  11408. subInfo.CreateUserId = dto.CurrUserId;
  11409. int parentId = await EnterExitCostVerifyIsNull(dto.DiId, dto.CurrUserId); //主表验证
  11410. if (parentId < 1) return Ok(JsonView(false));
  11411. //子表op
  11412. if (subId < 1)
  11413. {
  11414. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  11415. if (subAdd < 1) return Ok(JsonView(false));
  11416. }
  11417. else
  11418. {
  11419. ////验证编辑权限
  11420. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  11421. //if (!isEdit) return Ok(JsonView(false, msg));
  11422. var subUpd = await _sqlSugar.Updateable(subInfo)
  11423. .UpdateColumns(x => new
  11424. {
  11425. x.Days,
  11426. x.NationalTravelFeeId,
  11427. x.Cost,
  11428. x.Currency,
  11429. x.SubTotal
  11430. })
  11431. .WhereColumns(x => new { x.Id })
  11432. .ExecuteCommandAsync();
  11433. if (subUpd < 1) return Ok(JsonView(false));
  11434. }
  11435. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == feeType).Sum(x => x.SubTotal);
  11436. //await EnterExitCostMobileOpNotice(dto.DiId, parentId, dto.CurrUserId);
  11437. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  11438. }
  11439. /// <summary>
  11440. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-批量 Step7
  11441. /// </summary>
  11442. /// <returns></returns>
  11443. [HttpPost]
  11444. [ApiExplorerSettings(IgnoreApi = true)]
  11445. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11446. public async Task<IActionResult> EnterExitCostMobileOpBatchStep7(PostEnterExitCostMobileOpStep7Dto dto)
  11447. {
  11448. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11449. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11450. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11451. var infos1 = _mapper.Map<List<Grp_DayOtherPrice>>(dto.Infos);
  11452. var infos = infos1.Select(x => new Grp_DayOtherPrice()
  11453. {
  11454. Id = x.Id,
  11455. Diid = dto.DiId,
  11456. SetDataId = x.SetDataId,
  11457. Index = x.Index,
  11458. Cost = x.Cost,
  11459. Currency = x.Currency,
  11460. SubTotal = x.SubTotal,
  11461. CreateUserId = dto.CurrUserId,
  11462. Remark = x.Remark
  11463. }).ToList();
  11464. var adds = infos.Where(x => x.Id <= 0).ToList();
  11465. var upds = infos.Where(x => x.Id > 0).ToList();
  11466. if (adds.Count > 0)
  11467. {
  11468. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  11469. if (add < 1) return Ok(JsonView(false));
  11470. }
  11471. if (upds.Count > 0)
  11472. {
  11473. var upd = await _sqlSugar.Updateable(adds)
  11474. .UpdateColumns(x => new
  11475. {
  11476. x.Index,
  11477. x.SetDataId,
  11478. x.Cost,
  11479. x.Currency,
  11480. x.SubTotal,
  11481. x.Remark
  11482. })
  11483. .WhereColumns(x => new { x.Id })
  11484. .ExecuteCommandAsync();
  11485. if (upd < 1) return Ok(JsonView(false));
  11486. }
  11487. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == dto.DiId).Sum(x => x.SubTotal);
  11488. //消息通知
  11489. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  11490. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11491. return Ok(JsonView(new { itemTotal = itemTotal }));
  11492. }
  11493. /// <summary>
  11494. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-单条 Step7
  11495. /// </summary>
  11496. /// <returns></returns>
  11497. [HttpPost]
  11498. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11499. public async Task<IActionResult> EnterExitCostMobileOpSingleStep7(PostEnterExitCostMobileOpSingleStep7Dto dto)
  11500. {
  11501. int subId = dto.SubId;
  11502. int diId = dto.Diid;
  11503. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11504. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11505. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11506. var subInfo = _mapper.Map<Grp_DayOtherPrice>(dto);
  11507. subInfo.Id = subId;
  11508. subInfo.Diid = dto.Diid;
  11509. subInfo.CreateUserId = dto.CurrUserId;
  11510. int parentId = await EnterExitCostVerifyIsNull(diId, dto.CurrUserId); //主表验证
  11511. if (parentId < 1) return Ok(JsonView(false));
  11512. #region 子表op
  11513. if (subId < 1)//add
  11514. {
  11515. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  11516. if (subAdd < 1) return Ok(JsonView(false));
  11517. }
  11518. else //upd
  11519. {
  11520. ////验证编辑权限
  11521. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.Diid, dto.CurrUserId, 2);
  11522. //if (!isEdit) return Ok(JsonView(false, msg));
  11523. var subUpd = await _sqlSugar.Updateable(subInfo)
  11524. .UpdateColumns(x => new
  11525. {
  11526. x.Index,
  11527. x.SetDataId,
  11528. x.Cost,
  11529. x.Currency,
  11530. x.SubTotal,
  11531. x.Remark
  11532. })
  11533. .WhereColumns(x => new { x.Id })
  11534. .ExecuteCommandAsync();
  11535. if (subUpd < 1) return Ok(JsonView(false));
  11536. }
  11537. #endregion
  11538. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == diId).Sum(x => x.SubTotal);
  11539. //消息通知
  11540. //await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  11541. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  11542. }
  11543. /// <summary>
  11544. /// 团组模块 - 出入境费用-移动端 - 3-6子项删除
  11545. /// </summary>
  11546. /// <returns></returns>
  11547. [HttpPost]
  11548. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11549. public async Task<IActionResult> EnterExitCostMobileSubItemDel(EnterExitCostSubItemDelDto dto)
  11550. {
  11551. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  11552. if (data.Code != 0)
  11553. {
  11554. return Ok(JsonView(false, data.Msg));
  11555. }
  11556. return Ok(JsonView(true, "操作成功!", data.Data));
  11557. }
  11558. /// <summary>
  11559. /// 团组模块 - 出入境费用-移动端 - 其他费用删除
  11560. /// </summary>
  11561. /// <param name="dto"></param>
  11562. /// <returns></returns>
  11563. [HttpPost]
  11564. public IActionResult EnterExitCostMobileOtherFeeDel(EnterExitCostSubItemDelDto dto)
  11565. {
  11566. var data = new Grp_DayOtherPrice()
  11567. {
  11568. Id = dto.Id,
  11569. IsDel = 1,
  11570. DeleteUserId = dto.DeleteUserId,
  11571. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  11572. };
  11573. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  11574. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  11575. return Ok(JsonView(false, "删除失败!"));
  11576. }
  11577. #endregion
  11578. #endregion
  11579. #region 团组经理模块 出入境费用-草稿 移动端(Android/IOS)
  11580. /// <summary>
  11581. /// 团组模块 - 出入境费用-草稿 - 基础数据源 - 省份归属
  11582. /// </summary>
  11583. /// <returns></returns>
  11584. [HttpGet]
  11585. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11586. public async Task<IActionResult> EnterExitDraftMobileProvBelongCostDataSource()
  11587. {
  11588. var provData = await _groupRepository.ProvinceBasicSource();
  11589. return Ok(JsonView(true, "查询成功!", provData));
  11590. }
  11591. /// <summary>
  11592. /// 团组模块 - 出入境费用-草稿-移动端 - 草稿名称数据Data
  11593. /// </summary>
  11594. /// <returns></returns>
  11595. [HttpPost]
  11596. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11597. public async Task<IActionResult> EnterExitCostDraftMobileNameData(EnterExitCostDraftMobileNameDataDto dto)
  11598. {
  11599. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11600. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11601. RefAsync<int> total = 0;
  11602. var data = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  11603. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.DraftName))
  11604. .WhereIF(!string.IsNullOrEmpty(dto.DraftName), x => x.DraftName.Contains(dto.DraftName))
  11605. .Select(x => new
  11606. {
  11607. Id = x.Id,
  11608. DraftName = x.DraftName,
  11609. IsViewOrEdit = SqlFunc.Subqueryable<Grp_EnterExitCostDraftPermission>()
  11610. .Where(x1 => x1.IsDel == 0 && x1.Permission == 1 && x1.DraftId == x.Id && x1.UserId == dto.CurrUserId)
  11611. .Any()
  11612. })
  11613. .OrderByDescending(x => x.Id)
  11614. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  11615. return Ok(JsonView(true, "查询成功!", data, total));
  11616. }
  11617. /// <summary>
  11618. /// 出入境费用-草稿 移动端
  11619. /// 获取币种基础数据(含逻辑处理)
  11620. /// </summary>
  11621. /// <returns></returns>
  11622. private async Task<List<CurrencyInfo>> EnterExitCostDraftMobileGetCurrencyInit()
  11623. {
  11624. return await GeneralMethod.EnterExitCostInitRate();
  11625. }
  11626. /// <summary>
  11627. /// 团组模块 - 出入境费用-草稿-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  11628. /// </summary>
  11629. /// <returns></returns>
  11630. [HttpPost]
  11631. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11632. public async Task<IActionResult> EnterExitCostDraftMobileDataSource(EnterExitCostDraftMobileDataSourceDto dto)
  11633. {
  11634. //验证城市归属并给默认值
  11635. int provinceId = dto.ProvinceId;
  11636. if (provinceId < 1) provinceId = 122;
  11637. var dataSource = await _sqlSugar
  11638. .Queryable<Sys_SetData>()
  11639. .Where(x => x.IsDel == 0 && (x.STid == 72 || x.STid == 73) && x.Remark.Contains(provinceId.ToString()))
  11640. .ToListAsync();
  11641. //三公费用-Word明细类型
  11642. var wordTypeData = dataSource.Where(it => it.STid == 72)
  11643. .Select(x => new SetDataInfoView
  11644. {
  11645. Id = x.Id,
  11646. Name = x.Name,
  11647. Remark = x.Remark
  11648. })
  11649. .ToList();
  11650. //三公费用-Excel明细类型
  11651. var excelTypeData = dataSource.Where(it => it.STid == 73)
  11652. .Select(x => new SetDataInfoView
  11653. {
  11654. Id = x.Id,
  11655. Name = x.Name,
  11656. Remark = x.Remark
  11657. })
  11658. .ToList();
  11659. //默认币种显示
  11660. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  11661. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  11662. return Ok(JsonView(true, "查询成功!", new
  11663. {
  11664. WordTypeData = wordTypeData,
  11665. ExcelTypeData = excelTypeData,
  11666. CurrencyInit = _currencyInfos,
  11667. viewPermissionData = viewPermissionData
  11668. }));
  11669. }
  11670. /// <summary>
  11671. /// 团组模块 - 出入境费用-草稿-移动端 - 团组基础数据Data
  11672. /// </summary>
  11673. /// <returns></returns>
  11674. [HttpPost]
  11675. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11676. public async Task<IActionResult> EnterExitCostDraftMobileGroupData(PostEnterExitCostDraftMobileGroupDataDto dto)
  11677. {
  11678. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11679. RefAsync<int> total = 0;
  11680. int diId = 0;
  11681. var status = int.TryParse(dto.GroupName, out diId);
  11682. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  11683. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  11684. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  11685. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  11686. .OrderByDescending(x => x.VisitStartDate)
  11687. .Select(x => new
  11688. {
  11689. Id = x.Id,
  11690. GroupName = x.TeamName
  11691. })
  11692. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  11693. return Ok(JsonView(true, "查询成功!", data, total));
  11694. }
  11695. /// <summary>
  11696. /// 团组模块 - 出入境费用-草稿-移动端 - 币种基础数据Data
  11697. /// </summary>
  11698. /// <returns></returns>
  11699. [HttpPost]
  11700. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11701. public async Task<IActionResult> EnterExitCostDraftMobileCurrencyData(PostEnterExitCostDraftMobileCurrencyDataDto dto)
  11702. {
  11703. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11704. RefAsync<int> total = 0;
  11705. var data = await _sqlSugar.Queryable<Sys_SetData>()
  11706. .Where(x => x.IsDel == 0 && x.STid == 66)
  11707. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  11708. .Select(x => new
  11709. {
  11710. id = x.Id,
  11711. name = x.Name,
  11712. remark = x.Remark,
  11713. })
  11714. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  11715. return Ok(JsonView(true, "查询成功!", data, total));
  11716. }
  11717. /// <summary>
  11718. /// 团组模块 - 出入境费用-草稿-移动端 - 其他款项 - 币种、费用类型基础数据Data
  11719. /// </summary>
  11720. /// <returns></returns>
  11721. [HttpPost]
  11722. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11723. public async Task<IActionResult> EnterExitCostDraftMobileOtherItemCurrencyData(PostEnterExitCostDraftMobileOtherItemCurrencyDataDto dto)
  11724. {
  11725. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11726. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11727. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(1, 2477, 98);
  11728. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  11729. var groupOtherRateData = groupRateData.TeamRates;
  11730. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  11731. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  11732. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  11733. groupOtherRateData = groupOtherRateData
  11734. .Select(x => new TeamRateDescAddCurrencyIdView
  11735. {
  11736. CurrencyId = x.CurrencyId,
  11737. CurrencyName = x.CurrencyName,
  11738. CurrencyCode = x.CurrencyCode,
  11739. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  11740. }).ToList();
  11741. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  11742. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  11743. }
  11744. /// <summary>
  11745. /// 团组模块 - 出入境费用-草稿-移动端 - 实时汇率、签证费用、机票费用 Tips
  11746. /// </summary>
  11747. /// <returns></returns>
  11748. [HttpPost]
  11749. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11750. public async Task<IActionResult> EnterExitCostDraftMobileFeeTips(EnterExitCostDraftMobileFeeTipsDto dto)
  11751. {
  11752. int portType = dto.PortType;
  11753. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11754. var tipsData = new List<int>() { 1, 2, 3 };
  11755. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  11756. if (dto.TipsType == 1)
  11757. {
  11758. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  11759. }
  11760. else if (dto.TipsType == 2)
  11761. {
  11762. if (portType == 2)
  11763. {
  11764. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11765. }
  11766. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11767. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  11768. .Select(x => x.NationalTravelFeeId)
  11769. .Distinct()
  11770. .ToListAsync();
  11771. if (portType == 2)
  11772. {
  11773. if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  11774. }
  11775. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  11776. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  11777. .Select(x => x.Country)
  11778. .Distinct()
  11779. .ToArrayAsync();
  11780. if (portType == 2)
  11781. {
  11782. if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  11783. }
  11784. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  11785. return Ok(JsonView(true, "查询成功!", new
  11786. {
  11787. totalAmt = totalAmt,
  11788. remark = remark
  11789. }));
  11790. }
  11791. else if (dto.TipsType == 3)
  11792. {
  11793. return Ok(JsonView(false, "暂无机票费用提示信息!"));
  11794. }
  11795. return Ok(JsonView(false));
  11796. }
  11797. /// <summary>
  11798. /// 团组模块 - 出入境费用-草稿-移动端 - 创建
  11799. /// </summary>
  11800. /// <returns></returns>
  11801. [HttpPost]
  11802. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11803. public async Task<IActionResult> EnterExitCostDraftMobileCreate(EnterExitCostDraftMobileCreateDto dto)
  11804. {
  11805. if (string.IsNullOrEmpty(dto.DraftName)) return Ok(JsonView(false, "草稿名称为空!"));
  11806. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11807. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11808. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DraftName.Equals(dto.DraftName) && it.IsDel == 0);
  11809. if (eecInfo != null) return Ok(JsonView(false, "草稿名称重复!"));
  11810. var rateInfos = await EnterExitCostMobileGetCurrencyInit();
  11811. var info = new Grp_EnterExitCostDraft()
  11812. {
  11813. ProvinceId = dto.ProvinceId,
  11814. DraftName = dto.DraftName,
  11815. CurrencyRemark = CommonFun.GetCurrencyChinaToString(rateInfos),
  11816. CreateUserId = dto.CurrUserId
  11817. };
  11818. _sqlSugar.BeginTran();
  11819. var draftId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  11820. if (draftId < 1)
  11821. {
  11822. _sqlSugar.RollbackTran();
  11823. return Ok(JsonView(false, "草稿创建失败!"));
  11824. }
  11825. //添加默认权限
  11826. await _enterExitCostDraftRep.InitPerm(draftId, dto.CurrUserId);
  11827. _sqlSugar.CommitTran();
  11828. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(draftId, dto.CurrUserId);
  11829. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  11830. mobileInfo.Id = draftId;
  11831. mobileInfo.DraftName = dto.DraftName;
  11832. mobileInfo.Currencys = rateInfos;
  11833. mobileInfo.IsAssignPerm = assignPerm;
  11834. return Ok(JsonView(mobileInfo));
  11835. }
  11836. /// <summary>
  11837. /// 出入境费用-草稿-移动端 查看编辑提示消息
  11838. /// </summary>
  11839. private static string _viewPermStr = $"未分配查看权限,如要查看,请联系市场部或国交部负责人!";
  11840. /// <summary>
  11841. /// 团组模块 - 出入境费用-草稿-移动端 - ParentInfo
  11842. /// </summary>
  11843. /// <returns></returns>
  11844. [HttpPost]
  11845. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11846. public async Task<IActionResult> EnterExitCostDraftMobileParentInfo(EnterExitCostDraftMobileParentInfoDto dto)
  11847. {
  11848. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11849. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11850. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  11851. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  11852. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  11853. if (eecInfo == null) return Ok(JsonView(mobileInfo));
  11854. //验证查看编辑权限
  11855. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11856. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  11857. mobileInfo = _mapper.Map<EnterExitCostDraftMobileParentInfoView>(eecInfo);
  11858. mobileInfo.ProvinceId = eecInfo.ProvinceId;
  11859. mobileInfo.IsAssignPerm = assignPerm;
  11860. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11861. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  11862. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  11863. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  11864. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  11865. {
  11866. ParentId = dac.ParentId,
  11867. SubId = dac.Id,
  11868. Type = dac.Type,
  11869. Days = dac.Days,
  11870. NationalTravelFeeId = dac.NationalTravelFeeId,
  11871. Arae = $"{ntf.Country}-{ntf.City}",
  11872. Cost = dac.Cost,
  11873. Currency = dac.Currency,
  11874. CurrencyName = sd.Name,
  11875. SubTotal = dac.SubTotal,
  11876. })
  11877. .ToList();
  11878. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  11879. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  11880. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  11881. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  11882. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  11883. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  11884. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  11885. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  11886. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  11887. //其他款项
  11888. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  11889. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  11890. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  11891. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  11892. .OrderBy((dop, sd1, sd2) => dop.Index)
  11893. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  11894. {
  11895. ParentId = dop.ParentId,
  11896. SubId = dop.Id,
  11897. Index = dop.Index,
  11898. SetDataId = dop.SetDataId,
  11899. SetDataName = sd1.Name,
  11900. Cost = dop.Cost,
  11901. Currency = dop.Currency,
  11902. CurrencyName = sd2.Remark,
  11903. SubTotal = dop.SubTotal,
  11904. Remark = dop.Remark,
  11905. })
  11906. .ToArray();
  11907. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  11908. return Ok(mobileInfo);
  11909. }
  11910. /// <summary>
  11911. /// 团组模块 - 出入境费用-草稿-移动端 - SubInfo
  11912. /// </summary>
  11913. /// <returns></returns>
  11914. [HttpPost]
  11915. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11916. public async Task<IActionResult> EnterExitCostDraftMobileSubInfo(PostEnterExitCostDraftMobileSubInfoDto dto)
  11917. {
  11918. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11919. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11920. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11921. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  11922. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  11923. //验证查看编辑权限
  11924. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11925. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  11926. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  11927. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  11928. var subType = dto.SubType;
  11929. if (subType == 1) //1:境内费用
  11930. {
  11931. var oneData = new ChoiceOneMobileSubInfoView()
  11932. {
  11933. Id = eecInfo.Id,
  11934. ChoiceOne = eecInfo.ChoiceOne,
  11935. ChoiceOneTotalCost = eecInfo.InsidePay,
  11936. Visa = eecInfo.Visa,
  11937. VisaRemark = eecInfo.VisaRemark,
  11938. YiMiao = eecInfo.YiMiao,
  11939. HeSuan = eecInfo.HeSuan,
  11940. Service = eecInfo.Service,
  11941. Ticket = eecInfo.Ticket,
  11942. Safe = eecInfo.Safe,
  11943. FirstItemRemark = eecInfo.FirstItemRemark
  11944. };
  11945. return Ok(JsonView(oneData));
  11946. }
  11947. else if (subType == 2) //2:国际旅费
  11948. {
  11949. var twoData = new ChoiceTwoMobileSubInfoView()
  11950. {
  11951. Id = eecInfo.Id,
  11952. ChoiceTwoJJ = eecInfo.SumJJC,
  11953. OutsideJJPay = eecInfo.OutsideJJPay,
  11954. ChoiceTwoGW = eecInfo.SumGWC,
  11955. OutsideGWPay = eecInfo.OutsideGWPay,
  11956. ChoiceTwoTD = eecInfo.SumTDC,
  11957. OutsideTDPay = eecInfo.OutsideTDPay,
  11958. AirJJ = eecInfo.AirJJ,
  11959. AirGW = eecInfo.AirGW,
  11960. AirTD = eecInfo.AirTD,
  11961. CityTranffic = eecInfo.CityTranffic,
  11962. TwoItemRemark = eecInfo.TwoItemRemark
  11963. };
  11964. return Ok(JsonView(twoData));
  11965. }
  11966. else if (subType == 3) //3:住宿费
  11967. {
  11968. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11969. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  11970. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  11971. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 1)
  11972. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  11973. {
  11974. ParentId = dac.ParentId,
  11975. SubId = dac.Id,
  11976. Type = dac.Type,
  11977. Days = dac.Days,
  11978. NationalTravelFeeId = dac.NationalTravelFeeId,
  11979. Arae = $"{ntf.Country}-{ntf.City}",
  11980. Cost = dac.Cost,
  11981. Currency = dac.Currency,
  11982. CurrencyName = sd.Name,
  11983. SubTotal = dac.SubTotal,
  11984. })
  11985. .ToArray();
  11986. var data = new ChoiceDraftMobileSubInfo3To6View()
  11987. {
  11988. ParentId = eecInfo.Id,
  11989. Choice = eecInfo.ChoiceThree,
  11990. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  11991. Details = dayAndCostDatas
  11992. };
  11993. return Ok(JsonView(data));
  11994. }
  11995. else if (subType == 4) //4:伙食费
  11996. {
  11997. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11998. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  11999. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  12000. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 2)
  12001. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  12002. {
  12003. ParentId = dac.ParentId,
  12004. SubId = dac.Id,
  12005. Type = dac.Type,
  12006. Days = dac.Days,
  12007. NationalTravelFeeId = dac.NationalTravelFeeId,
  12008. Arae = $"{ntf.Country}-{ntf.City}",
  12009. Cost = dac.Cost,
  12010. Currency = dac.Currency,
  12011. CurrencyName = sd.Name,
  12012. SubTotal = dac.SubTotal,
  12013. })
  12014. .ToArray();
  12015. var data = new ChoiceDraftMobileSubInfo3To6View()
  12016. {
  12017. ParentId = eecInfo.Id,
  12018. Choice = eecInfo.ChoiceFour,
  12019. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  12020. Details = dayAndCostDatas
  12021. };
  12022. return Ok(JsonView(data));
  12023. }
  12024. else if (subType == 5) //5:公杂费
  12025. {
  12026. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  12027. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  12028. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  12029. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 3)
  12030. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  12031. {
  12032. ParentId = dac.ParentId,
  12033. SubId = dac.Id,
  12034. Type = dac.Type,
  12035. Days = dac.Days,
  12036. NationalTravelFeeId = dac.NationalTravelFeeId,
  12037. Arae = $"{ntf.Country}-{ntf.City}",
  12038. Cost = dac.Cost,
  12039. Currency = dac.Currency,
  12040. CurrencyName = sd.Name,
  12041. SubTotal = dac.SubTotal,
  12042. })
  12043. .ToArray();
  12044. var data = new ChoiceDraftMobileSubInfo3To6View()
  12045. {
  12046. ParentId = eecInfo.Id,
  12047. Choice = eecInfo.ChoiceFive,
  12048. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  12049. Details = dayAndCostDatas
  12050. };
  12051. return Ok(JsonView(data));
  12052. }
  12053. else if (subType == 6) //6:培训费
  12054. {
  12055. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  12056. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  12057. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  12058. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 4)
  12059. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  12060. {
  12061. ParentId = dac.ParentId,
  12062. SubId = dac.Id,
  12063. Type = dac.Type,
  12064. Days = dac.Days,
  12065. NationalTravelFeeId = dac.NationalTravelFeeId,
  12066. Arae = $"{ntf.Country}-{ntf.City}",
  12067. Cost = dac.Cost,
  12068. Currency = dac.Currency,
  12069. CurrencyName = sd.Name,
  12070. SubTotal = dac.SubTotal,
  12071. })
  12072. .ToArray();
  12073. var data = new ChoiceDraftMobileSubInfo3To6View()
  12074. {
  12075. ParentId = eecInfo.Id,
  12076. Choice = eecInfo.ChoiceSix,
  12077. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  12078. Details = dayAndCostDatas
  12079. };
  12080. return Ok(JsonView(data));
  12081. }
  12082. else if (subType == 7) //7:其他
  12083. {
  12084. //其他款项
  12085. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  12086. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  12087. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  12088. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  12089. .OrderBy((dop, sd1, sd2) => dop.Index)
  12090. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  12091. {
  12092. ParentId = dop.ParentId,
  12093. SubId = dop.Id,
  12094. Index = dop.Index,
  12095. SetDataId = dop.SetDataId,
  12096. SetDataName = sd1.Name,
  12097. Cost = dop.Cost,
  12098. Currency = dop.Currency,
  12099. CurrencyName = sd2.Name,
  12100. SubTotal = dop.SubTotal,
  12101. Remark = dop.Remark,
  12102. })
  12103. .ToArray();
  12104. var data = new ChoiceSevenDraftMobileSubInfoView()
  12105. {
  12106. ParentId = eecInfo.Id,
  12107. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  12108. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  12109. Details = otherData
  12110. };
  12111. return Ok(JsonView(data));
  12112. }
  12113. return Ok(JsonView(false));
  12114. }
  12115. #region op
  12116. ///// <summary>
  12117. ///// 移动端更新费用消息通知
  12118. ///// </summary>
  12119. ///// <param name="draftId"></param>
  12120. ///// <param name="id"></param>
  12121. ///// <param name="currUserId"></param>
  12122. //private async Task EnterExitCostDraftMobileOpNotice(int draftId, int id, int currUserId)
  12123. //{
  12124. // try
  12125. // {
  12126. // ////生成默认文件pdf并且通知人员
  12127. // //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  12128. // //{
  12129. // // DiId = draftId,
  12130. // // ExportType = 1,
  12131. // // SubTypeId = 1005
  12132. // //}, "pdf");
  12133. // ////发送通知
  12134. // //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  12135. // //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  12136. // //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  12137. // //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(draftId, new List<string>() { "208", "233", "21" }, currUserId, url);
  12138. // ////汇率信息记录
  12139. // //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  12140. // }
  12141. // catch (Exception ex)
  12142. // {
  12143. // //记录日志
  12144. // throw;
  12145. // }
  12146. //}
  12147. /// <summary>
  12148. /// 验证出入境费用数据是否存在
  12149. /// 不存在添加
  12150. /// </summary>
  12151. /// <param name="draftId"></param>
  12152. /// <param name="currUserId"></param>
  12153. /// <returns></returns>
  12154. /// <exception cref="CustomException"></exception>
  12155. private async Task<int> EnterExitCostDraftVerifyIsNull(int draftId, int currUserId)
  12156. {
  12157. var parentId = 0;
  12158. var info = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).OrderByDescending(x => x.CreateTime).FirstAsync();
  12159. if (info != null) parentId = info.Id;
  12160. else
  12161. {
  12162. var currencys = await EnterExitCostDraftMobileGetCurrencyInit();
  12163. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  12164. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  12165. parentId = addId;
  12166. }
  12167. return parentId;
  12168. }
  12169. /// <summary>
  12170. /// 团组模块 - 出入境费用-草稿-移动端 - 查看权限用户
  12171. /// </summary>
  12172. /// <returns></returns>
  12173. [HttpPost]
  12174. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12175. public async Task<IActionResult> EnterExitCostDraftMobileViewPermissionUsers(EnterExitCostDraftMobileViewPermissionUsersDto dto)
  12176. {
  12177. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  12178. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12179. //验证查看权限
  12180. (bool isView, bool isSet) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  12181. if (!isView) return Ok(JsonView(false, _viewPermStr));
  12182. var userIds = await _sqlSugar
  12183. .Queryable<Grp_EnterExitCostDraftPermission>()
  12184. .Where(x => x.IsDel == 0 && x.DraftId == dto.DraftId)
  12185. .Select(x => x.UserId)
  12186. .ToArrayAsync();
  12187. var perUsers = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  12188. var perUsersView = new List<dynamic>();
  12189. var feeBasePerm = AppSettingsHelper.Get<FeeBasePermView>("FeeBasePerm");
  12190. var viewPermissionData = new List<PermissionViewUserview>();
  12191. if (feeBasePerm.Any())
  12192. {
  12193. foreach (var item in feeBasePerm)
  12194. {
  12195. if (item.Users.Any())
  12196. {
  12197. viewPermissionData.AddRange(item.Users);
  12198. }
  12199. }
  12200. }
  12201. foreach (var item in perUsers)
  12202. {
  12203. bool isView1 = false;
  12204. if (userIds.Any(x => x == item.Id)) isView1 = true;
  12205. else if (viewPermissionData.Any(x => x.Id == dto.CurrUserId) && item.Id == dto.CurrUserId) isView1 = true;
  12206. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  12207. }
  12208. return Ok(JsonView(perUsersView));
  12209. }
  12210. /// <summary>
  12211. /// 团组模块 - 出入境费用-草稿-移动端 - 设置view权限
  12212. /// </summary>
  12213. /// <returns></returns>
  12214. [HttpPost]
  12215. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12216. public async Task<IActionResult> EnterExitCostDraftMobileSetViewPermissiion(EnterExitCostDraftMobileSetViewPermissiionDto dto)
  12217. {
  12218. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12219. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  12220. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  12221. //验证查看编辑权限
  12222. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  12223. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  12224. var permissions = new List<Grp_EnterExitCostDraftPermission>() { };
  12225. foreach (var userId in dto.UserIds)
  12226. {
  12227. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  12228. }
  12229. if (permissions.Any())
  12230. {
  12231. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  12232. {
  12233. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  12234. }
  12235. _sqlSugar.BeginTran();
  12236. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  12237. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  12238. if (result < 1)
  12239. {
  12240. _sqlSugar.RollbackTran();
  12241. return Ok(JsonView(false));
  12242. }
  12243. _sqlSugar.CommitTran();
  12244. return Ok(JsonView(true));
  12245. }
  12246. return Ok(JsonView(false));
  12247. }
  12248. /// <summary>
  12249. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 省份
  12250. /// </summary>
  12251. /// <returns></returns>
  12252. [HttpPost]
  12253. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12254. public async Task<IActionResult> EnterExitCostDraftMobileOpProv(EnterExitCostDraftMobileOpProvDto dto)
  12255. {
  12256. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12257. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12258. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12259. if (dto.ProvinceId < 1) return Ok(JsonView(false, "请传入有效的省份Id!"));
  12260. int id = dto.DraftId;
  12261. if (id <= 0) //add
  12262. {
  12263. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  12264. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  12265. if (add < 1) return Ok(JsonView(false));
  12266. id = add;
  12267. }
  12268. else //update
  12269. {
  12270. //验证查看编辑权限
  12271. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  12272. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  12273. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  12274. if (upd < 1) return Ok(JsonView(false));
  12275. }
  12276. return Ok(JsonView(new { parentId = id }));
  12277. }
  12278. /// <summary>
  12279. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 汇率
  12280. /// </summary>
  12281. /// <returns></returns>
  12282. [HttpPost]
  12283. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12284. public async Task<IActionResult> EnterExitCostDraftMobileOpRate(PostEnterExitCostDraftMobileFeeRateOpDto dto)
  12285. {
  12286. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12287. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12288. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12289. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  12290. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  12291. int id = dto.DraftId;
  12292. if (id <= 0) //add
  12293. {
  12294. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  12295. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId, CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  12296. if (add < 1) return Ok(JsonView(false));
  12297. id = add;
  12298. }
  12299. else //update
  12300. {
  12301. //验证查看编辑权限
  12302. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  12303. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  12304. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  12305. if (upd < 1) return Ok(JsonView(false));
  12306. }
  12307. #region 汇率变更时更改币种相关费用
  12308. var opDayCosts = new List<Grp_DayAndCostDraft>();
  12309. var opDayOtherCosts = new List<Grp_DayOtherPriceDraft>();
  12310. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  12311. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  12312. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  12313. .Where((dac, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  12314. .Select((dac, sd) => new
  12315. {
  12316. dac.Id,
  12317. dac.ParentId,
  12318. CurrencyCode = sd.Name,
  12319. dac.Cost
  12320. })
  12321. .ToList();
  12322. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  12323. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  12324. .Where((dop, sd) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  12325. .Select((dop, sd) => new
  12326. {
  12327. dop.Id,
  12328. dop.ParentId,
  12329. CurrencyCode = sd.Name,
  12330. dop.Cost
  12331. })
  12332. .ToList();
  12333. if (dayCosts.Count > 0)
  12334. {
  12335. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  12336. foreach (var dc in new_dayCosts)
  12337. {
  12338. var thisCurrency = dc.Key.ToUpper();
  12339. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  12340. if (thisRate == 0.00M) continue;
  12341. foreach (var dcSub in dc)
  12342. {
  12343. opDayCosts.Add(new Grp_DayAndCostDraft()
  12344. {
  12345. Id = dcSub.Id,
  12346. ParentId = dcSub.ParentId,
  12347. Cost = dcSub.Cost,
  12348. SubTotal = dcSub.Cost * thisRate,
  12349. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now:yyyy-MM-dd HH:mm:ss}、opUserId:{dto.CurrUserId}]"
  12350. });
  12351. }
  12352. }
  12353. if (opDayCosts.Count > 0)
  12354. {
  12355. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  12356. }
  12357. }
  12358. if (dayOtherCosts.Count > 0)
  12359. {
  12360. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  12361. foreach (var dc in new_dayOtherCosts)
  12362. {
  12363. var thisCurrency = dc.Key.ToUpper();
  12364. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  12365. if (thisRate == 0.00M) continue;
  12366. foreach (var dcSub in dc)
  12367. {
  12368. opDayOtherCosts.Add(new Grp_DayOtherPriceDraft()
  12369. {
  12370. Id = dcSub.Id,
  12371. ParentId = dcSub.ParentId,
  12372. Cost = dcSub.Cost,
  12373. SubTotal = dcSub.Cost * thisRate,
  12374. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  12375. });
  12376. }
  12377. }
  12378. if (opDayOtherCosts.Count > 0)
  12379. {
  12380. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  12381. }
  12382. }
  12383. #endregion
  12384. ////消息通知
  12385. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  12386. ////汇率信息记录
  12387. //await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  12388. return Ok(JsonView(new { parentId = id }));
  12389. }
  12390. /// <summary>
  12391. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 复选框
  12392. /// </summary>
  12393. /// <returns></returns>
  12394. [HttpPost]
  12395. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12396. public async Task<IActionResult> EnterExitCostDraftMobileOpCheckbox(PostEnterExitCostDraftMobileFeeOpCheckboxDto dto)
  12397. {
  12398. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12399. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  12400. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12401. var checkboxInfo = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  12402. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  12403. int id = dto.DraftId;
  12404. if (id <= 0) //add
  12405. {
  12406. checkboxInfo.ProvinceId = dto.ProvinceId;
  12407. checkboxInfo.CreateUserId = dto.CurrUserId;
  12408. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostDraftMobileGetCurrencyInit());
  12409. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  12410. if (add < 1) return Ok(JsonView(false));
  12411. }
  12412. else //update
  12413. {
  12414. var upd = await _sqlSugar.Updateable(checkboxInfo)
  12415. .UpdateColumns(x => new
  12416. {
  12417. x.ChoiceOne,
  12418. x.ChoiceTwo,
  12419. x.SumJJC,
  12420. x.SumGWC,
  12421. x.SumTDC,
  12422. x.ChoiceThree,
  12423. x.ChoiceFour,
  12424. x.ChoiceFive,
  12425. x.ChoiceSix,
  12426. x.OtherExpenses_Checked
  12427. })
  12428. .Where(x => x.Id == id)
  12429. .ExecuteCommandAsync();
  12430. if (upd < 1) return Ok(JsonView(false));
  12431. }
  12432. return Ok(JsonView(new { parentId = id }));
  12433. }
  12434. /// <summary>
  12435. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 3-7项复选框单个复选框
  12436. /// </summary>
  12437. /// <returns></returns>
  12438. [HttpPost]
  12439. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12440. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleCheckbox(EnterExitCostDarftMobileOpSingleCheckboxDto dto)
  12441. {
  12442. int itemTypeId = dto.ItemType, currUserId = dto.CurrUserId, draftId = dto.DraftId, isSelected = dto.IsSelected;
  12443. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  12444. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12445. if (draftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  12446. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12447. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  12448. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  12449. var checkboxInfo = new Grp_EnterExitCostDraft()
  12450. {
  12451. Id = draftId,
  12452. ProvinceId = dto.ProvinceId,
  12453. CreateUserId = currUserId
  12454. };
  12455. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  12456. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  12457. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  12458. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  12459. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  12460. if (draftId <= 0) //add
  12461. {
  12462. checkboxInfo.CreateUserId = dto.CurrUserId;
  12463. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  12464. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  12465. if (add < 1) return Ok(JsonView(false));
  12466. }
  12467. else //update
  12468. {
  12469. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>()
  12470. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  12471. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  12472. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  12473. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  12474. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  12475. .Where(x => x.Id == draftId)
  12476. .ExecuteCommandAsync();
  12477. if (upd < 1) return Ok(JsonView(false));
  12478. }
  12479. return Ok(JsonView(new { parentId = draftId }));
  12480. }
  12481. /// <summary>
  12482. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 境内费用 Step1
  12483. /// </summary>
  12484. /// <returns></returns>
  12485. [HttpPost]
  12486. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12487. public async Task<IActionResult> EnterExitCostDraftMobileOpStep1(PostEnterExitCostDraftMobileOpStep1Dto dto)
  12488. {
  12489. int id = dto.DraftId, currUserId = dto.CurrUserId;
  12490. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12491. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  12492. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12493. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  12494. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  12495. info.ProvinceId = dto.ProvinceId;
  12496. info.FirstItemRemark = dto.FirstItemRemark;
  12497. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  12498. if (id <= 0) //add
  12499. {
  12500. info.CreateUserId = dto.CurrUserId;
  12501. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  12502. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  12503. if (add < 1) return Ok(JsonView(false));
  12504. id = add;
  12505. }
  12506. else //update
  12507. {
  12508. var upd = await _sqlSugar.Updateable(info)
  12509. .UpdateColumns(x => new
  12510. {
  12511. x.ChoiceOne,
  12512. x.InsidePay,
  12513. x.VisaRemark,
  12514. x.Visa,
  12515. x.Service,
  12516. x.Safe,
  12517. x.Ticket,
  12518. x.HeSuan,
  12519. x.YiMiao,
  12520. x.FirstItemRemark
  12521. })
  12522. .Where(x => x.Id == id)
  12523. .ExecuteCommandAsync();
  12524. if (upd < 1) return Ok(JsonView(false));
  12525. }
  12526. ////消息通知
  12527. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  12528. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  12529. }
  12530. /// <summary>
  12531. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 国际旅费 Step2
  12532. /// </summary>
  12533. /// <returns></returns>
  12534. [HttpPost]
  12535. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12536. public async Task<IActionResult> EnterExitCostDraftMobileOpStep2(PostEnterExitCostDraftMobileOpStep2Dto dto)
  12537. {
  12538. int id = dto.DraftId;
  12539. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12540. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  12541. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12542. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  12543. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  12544. info.ProvinceId = dto.ProvinceId;
  12545. info.OutsideJJPay = dto.OutsideJJPay;
  12546. info.OutsideGWPay = dto.OutsideGWPay;
  12547. info.OutsideTDPay = dto.OutsideTDPay;
  12548. info.AirJJ = dto.AirJJ;
  12549. info.AirGW = dto.AirGW;
  12550. info.AirTD = dto.AirTD;
  12551. info.CityTranffic = dto.CityTranffic;
  12552. info.TwoItemRemark = dto.TwoItemRemark;
  12553. info.SumJJC = dto.ChoiceTwoJJ;
  12554. info.SumGWC = dto.ChoiceTwoGW;
  12555. info.SumTDC = dto.ChoiceTwoTD;
  12556. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  12557. if (id <= 0) //add
  12558. {
  12559. info.CreateUserId = dto.CurrUserId;
  12560. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  12561. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  12562. if (addId <= 0) return Ok(JsonView(false));
  12563. id = addId;
  12564. }
  12565. else //update
  12566. {
  12567. var upd = await _sqlSugar.Updateable(info)
  12568. .UpdateColumns(x => new
  12569. {
  12570. x.SumJJC,
  12571. x.OutsideJJPay,
  12572. x.SumGWC,
  12573. x.OutsideGWPay,
  12574. x.SumTDC,
  12575. x.OutsideTDPay,
  12576. x.AirJJ,
  12577. x.AirGW,
  12578. x.AirTD,
  12579. x.CityTranffic,
  12580. x.TwoItemRemark
  12581. })
  12582. .Where(x => x.Id == id)
  12583. .ExecuteCommandAsync();
  12584. if (upd < 1) return Ok(JsonView(false));
  12585. }
  12586. jjcItemTotal = info.AirJJ + info.CityTranffic;
  12587. gwcItemTotal = info.AirGW + info.CityTranffic;
  12588. tdcItemTotal = info.AirTD + info.CityTranffic;
  12589. ////消息通知
  12590. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  12591. return Ok(JsonView(new
  12592. {
  12593. parentId = id,
  12594. choiceTwoJJ = dto.ChoiceTwoJJ,
  12595. jjcItemTotal = jjcItemTotal,
  12596. choiceTwoGW = dto.ChoiceTwoGW,
  12597. gwcItemTotal = gwcItemTotal,
  12598. choiceTwoTD = dto.ChoiceTwoTD,
  12599. tdcItemTotal = tdcItemTotal
  12600. }));
  12601. }
  12602. /// <summary>
  12603. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  12604. /// </summary>
  12605. /// <returns></returns>
  12606. [HttpPost]
  12607. [ApiExplorerSettings(IgnoreApi = true)]
  12608. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12609. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep3To6(PostEnterExitCostDraftMobileOpStep3To6Dto dto)
  12610. {
  12611. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12612. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  12613. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12614. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  12615. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  12616. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  12617. var infos1 = _mapper.Map<List<Grp_DayAndCostDraft>>(dto.Infos);
  12618. var infos = infos1.Select(x => new Grp_DayAndCostDraft
  12619. {
  12620. Id = x.Id,
  12621. ParentId = dto.DraftId,
  12622. Type = dto.FeeType,
  12623. Days = x.Days,
  12624. NationalTravelFeeId = x.NationalTravelFeeId,
  12625. Cost = x.Cost,
  12626. Currency = x.Currency,
  12627. SubTotal = x.SubTotal,
  12628. CreateUserId = dto.CurrUserId
  12629. })
  12630. .ToList();
  12631. var adds = infos.Where(x => x.Id <= 0).ToList();
  12632. var upds = infos.Where(x => x.Id > 0).ToList();
  12633. if (adds.Count > 0)
  12634. {
  12635. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  12636. if (add < 1) return Ok(JsonView(false));
  12637. }
  12638. if (upds.Count > 0)
  12639. {
  12640. var upd = await _sqlSugar.Updateable(adds)
  12641. .UpdateColumns(x => new
  12642. {
  12643. x.Days,
  12644. x.NationalTravelFeeId,
  12645. x.Cost,
  12646. x.Currency,
  12647. x.SubTotal
  12648. })
  12649. .WhereColumns(x => new { x.Id })
  12650. .ExecuteCommandAsync();
  12651. if (upd < 1) return Ok(JsonView(false));
  12652. }
  12653. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  12654. ////消息通知
  12655. //var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).First()?.Id ?? 0;
  12656. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  12657. return Ok(JsonView(new { itemTotal = itemTotal }));
  12658. }
  12659. /// <summary>
  12660. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  12661. /// </summary>
  12662. /// <returns></returns>
  12663. [HttpPost]
  12664. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12665. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep3To6(PostEnterExitCostDraftMobileOpSingleStep3To6Dto dto)
  12666. {
  12667. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  12668. int subId = dto.SubId, feeType = dto.FeeType;
  12669. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12670. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  12671. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12672. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  12673. var subInfo = _mapper.Map<Grp_DayAndCostDraft>(dto);
  12674. subInfo.Id = subId;
  12675. subInfo.ParentId = dto.DraftId;
  12676. if (feeType == 3) subInfo.Type = 1;
  12677. else if (feeType == 4) subInfo.Type = 2;
  12678. else if (feeType == 5) subInfo.Type = 3;
  12679. else if (feeType == 6) subInfo.Type = 4;
  12680. subInfo.CreateUserId = dto.CurrUserId;
  12681. int parentId = await EnterExitCostDraftVerifyIsNull(dto.DraftId, dto.CurrUserId); //主表验证
  12682. if (parentId < 1) return Ok(JsonView(false));
  12683. //子表op
  12684. if (subId < 1)
  12685. {
  12686. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  12687. if (subAdd < 1) return Ok(JsonView(false));
  12688. }
  12689. else
  12690. {
  12691. var subUpd = await _sqlSugar.Updateable(subInfo)
  12692. .UpdateColumns(x => new
  12693. {
  12694. x.Days,
  12695. x.NationalTravelFeeId,
  12696. x.Cost,
  12697. x.Currency,
  12698. x.SubTotal
  12699. })
  12700. .WhereColumns(x => new { x.Id })
  12701. .ExecuteCommandAsync();
  12702. if (subUpd < 1) return Ok(JsonView(false));
  12703. }
  12704. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == feeType).Sum(x => x.SubTotal);
  12705. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  12706. }
  12707. /// <summary>
  12708. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-批量 Step7
  12709. /// </summary>
  12710. /// <returns></returns>
  12711. [HttpPost]
  12712. [ApiExplorerSettings(IgnoreApi = true)]
  12713. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12714. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep7(PostEnterExitCostDraftMobileOpStep7Dto dto)
  12715. {
  12716. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12717. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  12718. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12719. var infos1 = _mapper.Map<List<Grp_DayOtherPriceDraft>>(dto.Infos);
  12720. var infos = infos1.Select(x => new Grp_DayOtherPriceDraft()
  12721. {
  12722. Id = x.Id,
  12723. ParentId = dto.DraftId,
  12724. SetDataId = x.SetDataId,
  12725. Index = x.Index,
  12726. Cost = x.Cost,
  12727. Currency = x.Currency,
  12728. SubTotal = x.SubTotal,
  12729. CreateUserId = dto.CurrUserId,
  12730. Remark = x.Remark
  12731. }).ToList();
  12732. var adds = infos.Where(x => x.Id <= 0).ToList();
  12733. var upds = infos.Where(x => x.Id > 0).ToList();
  12734. if (adds.Count > 0)
  12735. {
  12736. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  12737. if (add < 1) return Ok(JsonView(false));
  12738. }
  12739. if (upds.Count > 0)
  12740. {
  12741. var upd = await _sqlSugar.Updateable(adds)
  12742. .UpdateColumns(x => new
  12743. {
  12744. x.Index,
  12745. x.SetDataId,
  12746. x.Cost,
  12747. x.Currency,
  12748. x.SubTotal,
  12749. x.Remark
  12750. })
  12751. .WhereColumns(x => new { x.Id })
  12752. .ExecuteCommandAsync();
  12753. if (upd < 1) return Ok(JsonView(false));
  12754. }
  12755. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).Sum(x => x.SubTotal);
  12756. //消息通知
  12757. //var id = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == dto.DraftId).First()?.Id ?? 0;
  12758. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  12759. return Ok(JsonView(new { itemTotal = itemTotal }));
  12760. }
  12761. /// <summary>
  12762. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-单条 Step7
  12763. /// </summary>
  12764. /// <returns></returns>
  12765. [HttpPost]
  12766. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12767. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep7(PostEnterExitCostDraftMobileOpSingleStep7Dto dto)
  12768. {
  12769. int subId = dto.SubId, id = dto.DraftId;
  12770. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12771. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  12772. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12773. var subInfo = _mapper.Map<Grp_DayOtherPriceDraft>(dto);
  12774. subInfo.Id = subId;
  12775. subInfo.ParentId = id;
  12776. subInfo.CreateUserId = dto.CurrUserId;
  12777. int parentId = await EnterExitCostDraftVerifyIsNull(id, dto.CurrUserId); //主表验证
  12778. if (parentId < 1) return Ok(JsonView(false));
  12779. #region 子表op
  12780. if (subId < 1)//add
  12781. {
  12782. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  12783. if (subAdd < 1) return Ok(JsonView(false));
  12784. }
  12785. else //upd
  12786. {
  12787. var subUpd = await _sqlSugar.Updateable(subInfo)
  12788. .UpdateColumns(x => new
  12789. {
  12790. x.Index,
  12791. x.SetDataId,
  12792. x.Cost,
  12793. x.Currency,
  12794. x.SubTotal,
  12795. x.Remark
  12796. })
  12797. .WhereColumns(x => new { x.Id })
  12798. .ExecuteCommandAsync();
  12799. if (subUpd < 1) return Ok(JsonView(false));
  12800. }
  12801. #endregion
  12802. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == id).Sum(x => x.SubTotal);
  12803. ////消息通知
  12804. //await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  12805. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  12806. }
  12807. /// <summary>
  12808. /// 团组模块 - 出入境费用-草稿-移动端 - 3-6子项删除
  12809. /// </summary>
  12810. /// <returns></returns>
  12811. [HttpPost]
  12812. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12813. public async Task<IActionResult> EnterExitCostDraftMobileSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  12814. {
  12815. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  12816. if (data.Code != 0)
  12817. {
  12818. return Ok(JsonView(false, data.Msg));
  12819. }
  12820. return Ok(JsonView(true, "操作成功!", data.Data));
  12821. }
  12822. /// <summary>
  12823. /// 团组模块 - 出入境费用-草稿-移动端 - 其他费用删除
  12824. /// </summary>
  12825. /// <param name="dto"></param>
  12826. /// <returns></returns>
  12827. [HttpPost]
  12828. public IActionResult EnterExitCostDraftMobileOtherFeeDel(EnterExitCostDraftSubItemDelDto dto)
  12829. {
  12830. var data = new Grp_DayOtherPriceDraft()
  12831. {
  12832. Id = dto.Id,
  12833. IsDel = 1,
  12834. DeleteUserId = dto.DeleteUserId,
  12835. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  12836. };
  12837. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  12838. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  12839. return Ok(JsonView(false, "删除失败!"));
  12840. }
  12841. #endregion
  12842. #endregion
  12843. #region 团组经理模块 出入境费用报价表
  12844. /// <summary>
  12845. /// 团组模块 - 出入境费用报价表 - 初始化数据源(币种类型)
  12846. /// </summary>
  12847. /// <returns></returns>
  12848. [HttpPost]
  12849. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12850. public async Task<IActionResult> EnterExitCostQuoteInitData(PortDtoBase dto)
  12851. {
  12852. var initRates = await GeneralMethod.EnterExitCostInitRate();
  12853. var liveRates = await GeneralMethod.EnterExitCostLiveRate();
  12854. var cnyInfo = new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.0000M };
  12855. initRates.Insert(0, cnyInfo);
  12856. liveRates.Insert(0, cnyInfo);
  12857. return Ok(JsonView(true, "查询成功!", new
  12858. {
  12859. InitRates = initRates,
  12860. LiveRates = liveRates
  12861. }));
  12862. }
  12863. /// <summary>
  12864. /// 团组模块 - 出入境费用报价表 - 报价表名称列表
  12865. /// </summary>
  12866. /// <returns></returns>
  12867. [HttpPost]
  12868. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12869. public async Task<IActionResult> EnterExitCostQuoteNameList(EnterExitCostQuoteNameListDto dto)
  12870. {
  12871. return Ok(await _enterExitCostQuoteRep.QuoteNameListAsync(dto));
  12872. }
  12873. /// <summary>
  12874. /// 团组模块 - 出入境费用报价表 - 团组名称列表
  12875. /// </summary>
  12876. /// <returns></returns>
  12877. [HttpPost]
  12878. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12879. public async Task<IActionResult> EnterExitCostQuoteGroupNameList(EnterExitCostQuoteGroupNameListDto dto)
  12880. {
  12881. return Ok(await _enterExitCostQuoteRep.GroupNameListAsync(dto));
  12882. }
  12883. /// <summary>
  12884. /// 团组模块 - 出入境费用报价表 - 根据团组Id获出入境费用相关信息
  12885. /// </summary>
  12886. /// <returns></returns>
  12887. [HttpPost]
  12888. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12889. public async Task<IActionResult> EnterExitCostQuoteEntryExitCosts(EnterExitCostInfobyDiIdDto dto)
  12890. {
  12891. int groupId = dto.DiId,
  12892. currUserId = dto.CurrUserId;
  12893. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId;"));
  12894. if (currUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId;"));
  12895. //验证报价数据是否存在
  12896. var isNull = await _sqlSugar.Queryable<Grp_EnterExitCostQuote>().FirstAsync(x => x.IsDel == 0 && x.GroupId == dto.DiId);
  12897. if (isNull != null)
  12898. {
  12899. var info1 = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { Id = isNull.Id });
  12900. if (!info1.Rates.Any())
  12901. {
  12902. var rates = await GeneralMethod.EnterExitCostInitRate();
  12903. rates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  12904. info1.Rates = rates.ToArray();
  12905. }
  12906. return Ok(JsonView(info1));
  12907. }
  12908. var result = await _enterExitCostQuoteRep.InfoByGroupIdAsync(dto.DiId);
  12909. result.GroupId = groupId;
  12910. //处理报价名称
  12911. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.DiId && x.IsDel == 0);
  12912. if (groupInfo != null)
  12913. {
  12914. var visitCountry = groupInfo.VisitCountry;
  12915. if (!string.IsNullOrEmpty(visitCountry))
  12916. {
  12917. string quoteName = string.Empty;
  12918. if (visitCountry.Contains("|"))
  12919. {
  12920. var countrys = visitCountry.Split("|");
  12921. quoteName = string.Join("、", countrys);
  12922. }
  12923. else quoteName = visitCountry;
  12924. quoteName += $"团组报价表";
  12925. result.Name = quoteName;
  12926. }
  12927. }
  12928. var info = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  12929. if (info.Code != StatusCodes.Status200OK)
  12930. {
  12931. if (!result.Rates.Any())
  12932. {
  12933. var rates = await GeneralMethod.EnterExitCostInitRate();
  12934. result.Rates = rates.ToArray();
  12935. }
  12936. return Ok(JsonView(true, $"出入境费用明细未填写!", result));
  12937. }
  12938. var infoView = info.Data as EnterExitCostInfoView;
  12939. if (infoView == null) return Ok(JsonView(false, "数据类型转换失败!;"));
  12940. var countryFees = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).ToListAsync();
  12941. var cityFilter = new List<string>() { "全部城市", "其他城市" };
  12942. var currencys = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  12943. var eecRates = infoView.Currencys;
  12944. //默认添加人名币
  12945. if (!eecRates.Any(x => x.CurrencyCode.Equals("CNY")))
  12946. {
  12947. eecRates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  12948. }
  12949. //处理团组人数
  12950. int pplNum = 1;
  12951. if (groupInfo != null) pplNum = groupInfo.VisitPNumber;
  12952. var views = new List<QuoteSubItemInfo>();
  12953. #region 数据填充
  12954. var intTravelCosts = new List<QuoteSubItemInfo>();
  12955. #region 机票费用 1354
  12956. int intTravelIndex = 1;
  12957. if (infoView.SumJJC == 1)
  12958. {
  12959. intTravelCosts.Add(new QuoteSubItemInfo
  12960. {
  12961. ItemId = 1354,
  12962. Index = intTravelIndex,
  12963. FeeName = "经济舱",
  12964. UnitPrice = infoView.AirJJ,
  12965. Currency = "CNY",
  12966. Quantity = 1,
  12967. PplNum = 1,
  12968. TotalAmt = infoView.AirJJ,
  12969. Remark = "",
  12970. });
  12971. intTravelIndex++;
  12972. }
  12973. if (infoView.SumGWC == 1)
  12974. {
  12975. intTravelCosts.Add(new QuoteSubItemInfo
  12976. {
  12977. ItemId = 1354,
  12978. Index = intTravelIndex,
  12979. FeeName = "公务舱",
  12980. UnitPrice = infoView.AirGW,
  12981. Currency = "CNY",
  12982. Quantity = 1,
  12983. PplNum = 1,
  12984. TotalAmt = infoView.AirGW,
  12985. Remark = "",
  12986. });
  12987. intTravelIndex++;
  12988. }
  12989. if (infoView.SumTDC == 1)
  12990. {
  12991. intTravelCosts.Add(new QuoteSubItemInfo
  12992. {
  12993. ItemId = 1354,
  12994. Index = intTravelIndex,
  12995. FeeName = "头等舱",
  12996. UnitPrice = infoView.AirTD,
  12997. Currency = "CNY",
  12998. Quantity = 1,
  12999. PplNum = 1,
  13000. TotalAmt = infoView.AirTD,
  13001. Remark = "",
  13002. });
  13003. intTravelIndex++;
  13004. }
  13005. intTravelCosts.Add(new QuoteSubItemInfo
  13006. {
  13007. ItemId = 1354,
  13008. Index = intTravelIndex,
  13009. FeeName = "城市间交通费用",
  13010. UnitPrice = infoView.CityTranffic,
  13011. Currency = "CNY",
  13012. Quantity = 1,
  13013. PplNum = pplNum,
  13014. TotalAmt = infoView.CityTranffic * pplNum,
  13015. Remark = "",
  13016. });
  13017. views.AddRange(intTravelCosts);
  13018. #endregion
  13019. var accomCosts = new List<QuoteSubItemInfo>();
  13020. #region 住宿费 1355
  13021. if (infoView.QuarterageData.Any())
  13022. {
  13023. int accomIndex = 1;
  13024. int accomItemTypeId = 1355;
  13025. var groupData = infoView.QuarterageData.GroupBy(x => x.NationalTravelFeeId);
  13026. foreach (var item in groupData)
  13027. {
  13028. string feeName = string.Empty;
  13029. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  13030. if (countryInfo != null)
  13031. {
  13032. feeName = countryInfo.Country;
  13033. var city = countryInfo.City;
  13034. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  13035. {
  13036. feeName += $"-{city}";
  13037. }
  13038. }
  13039. var hotelInfo = item.FirstOrDefault();
  13040. if (hotelInfo == null) continue;
  13041. var thisCurrency = currencys.FirstOrDefault(x => x.Id == hotelInfo.Currency)?.Name ?? "nuknow";
  13042. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  13043. int quantity = item.ToList().Count;
  13044. accomCosts.Add(new QuoteSubItemInfo
  13045. {
  13046. ItemId = accomItemTypeId,
  13047. Index = accomIndex,
  13048. FeeName = feeName,
  13049. UnitPrice = hotelInfo.Cost,
  13050. Currency = thisCurrency,
  13051. Quantity = quantity,
  13052. PplNum = pplNum,
  13053. TotalAmt = hotelInfo.Cost * thisRate * quantity * pplNum,
  13054. Remark = "",
  13055. });
  13056. accomIndex++;
  13057. }
  13058. views.AddRange(accomCosts);
  13059. }
  13060. #endregion
  13061. var mealCosts = new List<QuoteSubItemInfo>();
  13062. #region 餐饮费 1356
  13063. if (infoView.BoardWagesData.Any())
  13064. {
  13065. var mealIndex = 1;
  13066. int mealItemTypeId = 1356;
  13067. var groupData = infoView.BoardWagesData.GroupBy(x => x.NationalTravelFeeId);
  13068. foreach (var item in groupData)
  13069. {
  13070. string feeName = string.Empty;
  13071. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  13072. if (countryInfo != null)
  13073. {
  13074. feeName = countryInfo.Country;
  13075. var city = countryInfo.City;
  13076. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  13077. {
  13078. feeName += $"-{city}";
  13079. }
  13080. }
  13081. var mealInfo = item.FirstOrDefault();
  13082. if (mealInfo == null) continue;
  13083. var thisCurrency = currencys.FirstOrDefault(x => x.Id == mealInfo.Currency)?.Name ?? "nuknow";
  13084. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  13085. int quantity = item.ToList().Count;
  13086. mealCosts.Add(new QuoteSubItemInfo
  13087. {
  13088. ItemId = mealItemTypeId,
  13089. Index = mealIndex,
  13090. FeeName = feeName,
  13091. UnitPrice = mealInfo.Cost,
  13092. Currency = thisCurrency,
  13093. Quantity = quantity,
  13094. PplNum = pplNum,
  13095. TotalAmt = mealInfo.Cost * thisRate * quantity * pplNum,
  13096. Remark = "",
  13097. });
  13098. mealIndex++;
  13099. }
  13100. views.AddRange(mealCosts);
  13101. }
  13102. #endregion
  13103. var miscCosts = new List<QuoteSubItemInfo>();
  13104. #region 公杂费 1364
  13105. if (infoView.MiscellaneousFeeData.Any())
  13106. {
  13107. var miscIndex = 1;
  13108. int miscItemTypeId = 1364;
  13109. var groupData = infoView.MiscellaneousFeeData.GroupBy(x => x.NationalTravelFeeId);
  13110. foreach (var item in groupData)
  13111. {
  13112. string feeName = string.Empty;
  13113. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  13114. if (countryInfo != null)
  13115. {
  13116. feeName = countryInfo.Country;
  13117. var city = countryInfo.City;
  13118. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  13119. {
  13120. feeName += $"-{city}";
  13121. }
  13122. }
  13123. var miscInfo = item.FirstOrDefault();
  13124. if (miscInfo == null) continue;
  13125. var thisCurrency = currencys.FirstOrDefault(x => x.Id == miscInfo.Currency)?.Name ?? "nuknow";
  13126. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  13127. int quantity = item.ToList().Count;
  13128. miscCosts.Add(new QuoteSubItemInfo
  13129. {
  13130. ItemId = miscItemTypeId,
  13131. Index = miscIndex,
  13132. FeeName = feeName,
  13133. UnitPrice = miscInfo.Cost,
  13134. Currency = thisCurrency,
  13135. Quantity = quantity,
  13136. PplNum = pplNum,
  13137. TotalAmt = miscInfo.Cost * thisRate * quantity * pplNum,
  13138. Remark = "",
  13139. });
  13140. miscIndex++;
  13141. }
  13142. views.AddRange(miscCosts);
  13143. }
  13144. #endregion
  13145. #region 签证+保险 1362
  13146. int visaInsIndex = 1;
  13147. int visaInsItemTypeId = 1362;
  13148. if (infoView.Visa > 0)
  13149. {
  13150. views.Add(new QuoteSubItemInfo()
  13151. {
  13152. ItemId = visaInsItemTypeId,
  13153. Index = visaInsIndex,
  13154. FeeName = $"签证",
  13155. UnitPrice = infoView.Visa,
  13156. Currency = $"CNY",
  13157. Quantity = 1,
  13158. PplNum = pplNum,
  13159. TotalAmt = infoView.Visa * pplNum,
  13160. Remark = "",
  13161. });
  13162. visaInsIndex++;
  13163. }
  13164. if (infoView.Safe > 0)
  13165. {
  13166. views.Add(new QuoteSubItemInfo()
  13167. {
  13168. ItemId = visaInsItemTypeId,
  13169. Index = visaInsIndex,
  13170. FeeName = $"保险",
  13171. UnitPrice = infoView.Safe,
  13172. Currency = $"CNY",
  13173. Quantity = 1,
  13174. PplNum = pplNum,
  13175. TotalAmt = infoView.Safe * pplNum,
  13176. Remark = "",
  13177. });
  13178. }
  13179. #endregion
  13180. #region 服务费 1363
  13181. int serviceFeeIndex = 1;
  13182. int serviceFeeItemTypeId = 1363;
  13183. if (infoView.Service > 0)
  13184. {
  13185. views.Add(new QuoteSubItemInfo()
  13186. {
  13187. ItemId = serviceFeeItemTypeId,
  13188. Index = serviceFeeIndex,
  13189. FeeName = $"服务费",
  13190. UnitPrice = infoView.Service,
  13191. Currency = $"CNY",
  13192. Quantity = 1,
  13193. PplNum = pplNum,
  13194. TotalAmt = infoView.Service * pplNum,
  13195. Remark = "",
  13196. });
  13197. }
  13198. #endregion
  13199. #endregion
  13200. if (result.FeeItems.Any())
  13201. {
  13202. result.FeeItems.Select(x =>
  13203. {
  13204. var feeInfos = views.Where(y => y.ItemId == x.ItemId).OrderBy(y => y.Index).ToArray();
  13205. if (feeInfos.Any()) x.Infos = feeInfos;
  13206. return x;
  13207. }
  13208. ).OrderBy(x => x.Index)
  13209. .ToList();
  13210. if (!result.Rates.Any())
  13211. {
  13212. if (eecRates.Any()) result.Rates = eecRates?.ToArray() ?? Array.Empty<CurrencyInfo>();
  13213. else
  13214. {
  13215. var rates = await GeneralMethod.EnterExitCostInitRate();
  13216. rates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  13217. result.Rates = rates.ToArray();
  13218. }
  13219. }
  13220. }
  13221. return Ok(JsonView(result));
  13222. }
  13223. /// <summary>
  13224. /// 团组模块 - 出入境费用报价表 - Info
  13225. /// </summary>
  13226. /// <returns></returns>
  13227. [HttpPost]
  13228. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13229. public async Task<IActionResult> EnterExitCostQuoteInfo(EnterExitCostQuoteInfoDto dto)
  13230. {
  13231. var info = await _enterExitCostQuoteRep.InfoAsync(dto);
  13232. if (!info.Rates.Any())
  13233. {
  13234. var rates = await GeneralMethod.EnterExitCostInitRate();
  13235. rates.Add(new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  13236. info.Rates = rates.ToArray();
  13237. }
  13238. return Ok(JsonView(info));
  13239. }
  13240. /// <summary>
  13241. /// 团组模块 - 出入境费用报价表 - OP
  13242. /// </summary>
  13243. /// <returns></returns>
  13244. [HttpPost]
  13245. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13246. public async Task<IActionResult> EnterExitCostQuoteOp(EnterExitCostQuoteOpDto dto)
  13247. {
  13248. return Ok(await _enterExitCostQuoteRep.OpAsync(dto));
  13249. }
  13250. /// <summary>
  13251. /// 团组模块 - 出入境费用报价表 - 删除 项
  13252. /// </summary>
  13253. /// <returns></returns>
  13254. [HttpPost]
  13255. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13256. public async Task<IActionResult> EnterExitCostQuoteItemDel(EnterExitCostQuoteItemDelDto dto)
  13257. {
  13258. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  13259. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  13260. return Ok(await _enterExitCostQuoteRep.ItemDelAsync(dto));
  13261. }
  13262. /// <summary>
  13263. /// 团组模块 - 出入境费用报价表 - 导出
  13264. /// </summary>
  13265. /// <returns></returns>
  13266. [HttpPost]
  13267. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13268. public async Task<IActionResult> EnterExitCostQuoteExcelExport(EnterExitCostQuoteExcelExportDto dto)
  13269. {
  13270. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  13271. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  13272. var info = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { Id = dto.Id });
  13273. if (info == null) return Ok(JsonView(false, "报价信息未填写!"));
  13274. var rates = info.Rates;
  13275. var intTravelCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1354);//国际旅费
  13276. var accomCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1355); //住宿费
  13277. var mealCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1356); //餐饮费
  13278. var vehArranges = info.FeeItems.FirstOrDefault(x => x.ItemId == 1357); //车辆安排
  13279. var inviteTo = info.FeeItems.FirstOrDefault(x => x.ItemId == 1358); //邀请函发放对象
  13280. var inviteCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1359); //邀请函费用
  13281. var inviteTime = info.FeeItems.FirstOrDefault(x => x.ItemId == 1360); //邀请函发放时间
  13282. var officialActs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1361); //公务活动
  13283. var visaIns = info.FeeItems.FirstOrDefault(x => x.ItemId == 1362); //签证+保险
  13284. var serviceCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1363); //服务费
  13285. var pubMiscs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1364); //公杂费
  13286. var taxCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1365); //税费
  13287. //获取模板
  13288. string tempPath = AppSettingsHelper.Get("ExcelBasePath") + "Template/出入境费用明细报价表模板.xlsx";
  13289. var designer = new WorkbookDesigner();
  13290. designer.Workbook = new Workbook(tempPath);
  13291. designer.SetDataSource("QuoteName", info.Name);
  13292. designer.SetDataSource("CompanyTitle", "公司名称");
  13293. designer.SetDataSource("CompanyLabel", "");
  13294. #region 国际旅费
  13295. designer.SetDataSource("IntTravelTitle", intTravelCosts?.ItemWrapName ?? "国际旅费\r\n(公务舱和经济舱分别罗列)");
  13296. if (intTravelCosts != null && intTravelCosts.Infos.Any())
  13297. {
  13298. var cabClassFilter = new string[] { "经济舱", "公务舱", "头等舱" };
  13299. var label = new StringBuilder();
  13300. var infos = intTravelCosts.Infos.Where(x => cabClassFilter.Contains(x.FeeName)).ToArray();
  13301. if (infos.Any())
  13302. {
  13303. label.Append(infos.Sum(x => x.PplNum));
  13304. label.Append("人全程机票:");
  13305. label.Append(infos.Sum(x => x.TotalAmt).TruncDecimals(2));
  13306. label.AppendLine("元");
  13307. }
  13308. foreach (var item in intTravelCosts.Infos)
  13309. {
  13310. label.Append(item.FeeName);
  13311. label.Append(":");
  13312. label.Append(item.UnitPrice.TruncDecimals(2));
  13313. label.Append("元/人*");
  13314. label.Append(item.PplNum);
  13315. label.AppendLine("人");
  13316. }
  13317. if (label.HasValue())
  13318. {
  13319. label.Append("\r\n以上小计:");
  13320. label.Append(intTravelCosts.TotalAmt.TruncDecimals(2));
  13321. label.Append("元");
  13322. }
  13323. designer.SetDataSource("IntTravelLabel", label.ToString());
  13324. }
  13325. #endregion
  13326. #region 住宿费
  13327. designer.SetDataSource("AccomTitle", accomCosts?.ItemWrapName ?? "住宿费\r\n(请备注明酒店星级)");
  13328. if (accomCosts != null && accomCosts.Infos.Any())
  13329. {
  13330. string currencyName = string.Empty,
  13331. countryName = string.Empty;
  13332. decimal rate = 1.0000M;
  13333. var label = new StringBuilder();
  13334. label.AppendLine("全程五星酒店,每人1间房");
  13335. foreach (var item in accomCosts.Infos)
  13336. {
  13337. //乌兹别克斯坦: 塔什干:120美金/间/晚*2*6人
  13338. string name = string.Empty, thisCountryName = string.Empty;
  13339. if (item.FeeName.Contains('-'))
  13340. {
  13341. var feeName = item.FeeName.Split('-');
  13342. thisCountryName = feeName[0];
  13343. if (!thisCountryName.Equals(countryName)) countryName = feeName[0];
  13344. name = feeName[1];
  13345. }
  13346. else name = item.FeeName;
  13347. string thisFeeName = string.Empty;
  13348. if (!thisCountryName.Equals(countryName)) thisFeeName = $"{countryName}:\r\n{name}:";
  13349. else thisFeeName = $"\r\n{name}:";
  13350. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  13351. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  13352. rate = rateInfo?.Rate ?? 1.0000M;
  13353. string subLabel = string.Format("{0}{1}{2}/间/晚*{3}*{4}人", thisFeeName, item.UnitPrice.TruncDecimals(2), currencyName, item.Quantity.ToString("#0"), item.PplNum.ToString("#0"));
  13354. label.AppendLine(subLabel);
  13355. }
  13356. if (label.HasValue())
  13357. {
  13358. //以上小计:52440元(美金汇率:7.5 )
  13359. string subLabel = string.Format("\r\n以上小计:{0}元({1}汇率:{2})", accomCosts.TotalAmt.TruncDecimals(2), currencyName, rate.TruncDecimals(4));
  13360. label.AppendLine(subLabel);
  13361. }
  13362. designer.SetDataSource("AccomLabel", label.ToString());
  13363. }
  13364. #endregion
  13365. #region 餐饮费
  13366. designer.SetDataSource("MealTitle", mealCosts?.ItemWrapName ?? "餐饮费");
  13367. if (mealCosts != null && mealCosts.Infos.Any())
  13368. {
  13369. string currencyName = string.Empty;
  13370. decimal rate = 1.0000M;
  13371. var label = new StringBuilder();
  13372. label.Append("全程酒店含早,\r\n若因航班过早,\r\n酒店准备路早。\r\n\r\n");
  13373. foreach (var item in mealCosts.Infos)
  13374. {
  13375. string name = string.Empty;
  13376. if (item.FeeName.Contains('-'))
  13377. {
  13378. var feeName = item.FeeName.Split('-');
  13379. name = $"\r\n{feeName[0]}:\r\n{feeName[1]}:";
  13380. }
  13381. else name = $"\r\n{item.FeeName}:";
  13382. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  13383. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  13384. rate = rateInfo?.Rate ?? 1.0000M;
  13385. label.Append(name);
  13386. label.Append(item.UnitPrice.TruncDecimals(2));
  13387. label.Append(currencyName);
  13388. label.Append("/天*");
  13389. label.Append(item.Quantity.ToString("#0"));
  13390. label.Append('*');
  13391. label.Append(item.PplNum);
  13392. label.Append("人\r\n");
  13393. }
  13394. if (label.HasValue())
  13395. {
  13396. label.Append("\r\n以上小计:");
  13397. label.Append(accomCosts.TotalAmt.TruncDecimals(2));
  13398. label.Append("元\r\n(");
  13399. label.Append("汇率:");
  13400. label.Append(rate.TruncDecimals(4));
  13401. label.Append(')');
  13402. }
  13403. designer.SetDataSource("MealLabel", label.ToString());
  13404. }
  13405. #endregion
  13406. #region 车辆安排
  13407. designer.SetDataSource("VehArrangeTitle", vehArranges?.ItemWrapName ?? "车辆安排\r\n(司兼导分开的情况下,车辆品牌、座位及费用)");
  13408. if (vehArranges != null && vehArranges.Infos.Any())
  13409. {
  13410. string currencyName = string.Empty;
  13411. //decimal rate = 1.0000M;
  13412. var label = new StringBuilder();
  13413. foreach (var item in vehArranges.Infos)
  13414. {
  13415. label.AppendLine();
  13416. label.AppendLine();
  13417. label.Append(item.FeeName);
  13418. label.Append($"\r\n\r\n费用:{item.TotalAmt.TruncDecimals(2)}元");
  13419. }
  13420. designer.SetDataSource("VehArrangeLabel", label.ToString());
  13421. }
  13422. #endregion
  13423. #region 邀请函发放对象
  13424. designer.SetDataSource("InviteToTitle", inviteTo?.ItemWrapName ?? "邀请函发放对象");
  13425. designer.SetDataSource("InviteToContent", "");
  13426. #endregion
  13427. #region 邀请函费
  13428. designer.SetDataSource("InviteCostTitle", inviteCosts?.ItemWrapName ?? "邀请函费用");
  13429. var is_label = new StringBuilder();
  13430. if (inviteCosts != null && inviteCosts.Infos.Any())
  13431. {
  13432. string currencyName = string.Empty;
  13433. decimal rate = 1.0000M;
  13434. foreach (var item in inviteCosts.Infos)
  13435. {
  13436. //乌兹别克斯坦:2000美金
  13437. currencyName = item.Currency;
  13438. rate = rates.FirstOrDefault(x => currencyName.Equals(x.CurrencyCode))?.Rate ?? 1.0000M;
  13439. string label = string.Format("{0}:{1}{2}", item.FeeName, item.UnitPrice.TruncDecimals(2), currencyName);
  13440. is_label.AppendLine(label);
  13441. }
  13442. if (is_label.HasValue())
  13443. {
  13444. //以上小计:28500元(美金汇率:7.5)
  13445. string label = string.Format("以上小计:{0}{1}({2}汇率:{3})", inviteCosts.TotalAmt.TruncDecimals(2), "元", currencyName, rate.TruncDecimals(4));
  13446. is_label.AppendLine(label);
  13447. }
  13448. }
  13449. designer.SetDataSource("InviteCostContent", is_label.ToString());
  13450. #endregion
  13451. #region 邀请函发放时间
  13452. designer.SetDataSource("InviteToTimeTitle", inviteTime?.ItemWrapName ?? "邀请函发放时间");
  13453. designer.SetDataSource("InviteToTimeContent", "拿到团员名单10-15工作日");
  13454. #endregion
  13455. #region 公务活动(含翻译)
  13456. designer.SetDataSource("OfficialActsTitle", officialActs?.ItemWrapName ?? "公务活动(含翻译)");
  13457. var oa_label = new StringBuilder();
  13458. if (officialActs != null && officialActs.Infos.Any())
  13459. {
  13460. string currencyName = string.Empty;
  13461. decimal rate = 1.0000M;
  13462. string label_title = string.Empty, label_content = "超出报价部分需额付费:\r\n";
  13463. foreach (var item in officialActs.Infos)
  13464. {
  13465. //乌兹别克斯坦:1000美金/场
  13466. currencyName = item.Currency;
  13467. rate = rates.FirstOrDefault(x => currencyName.Equals(x.CurrencyCode))?.Rate ?? 1.0000M;
  13468. string label_remark = string.Empty;
  13469. if (!string.IsNullOrEmpty(item.Remark)) label_remark = $"({item.Remark})";
  13470. label_content += string.Format("{0}:{1}{2}/场{3}\r\n", item.FeeName, item.UnitPrice.TruncDecimals(2), currencyName, label_remark);
  13471. }
  13472. label_content += "*总费用中未含超出公务活动价格";
  13473. //8场公务活动(以上小计:60000元)
  13474. var quantity = officialActs.Infos.Sum(x => x.Quantity);
  13475. label_title = string.Format("{0}场公务活动(以上小计:{1}元)", quantity, officialActs.TotalAmt.TruncDecimals(2));
  13476. oa_label.AppendLine(label_title);
  13477. oa_label.AppendLine(label_content);
  13478. }
  13479. designer.SetDataSource("OfficialActsContent", oa_label.ToString());
  13480. #endregion
  13481. #region 签证+保险
  13482. designer.SetDataSource("VisaInsTitle", visaIns?.ItemWrapName ?? "签证+保险\r\n(单位:元)");
  13483. var vi_label = new StringBuilder();
  13484. if (visaIns != null && visaIns.Infos.Any())
  13485. {
  13486. foreach (var item in visaIns.Infos)
  13487. {
  13488. //签证:500元/人
  13489. string label = string.Format("{0}:{1}元/人*{2}人", item.FeeName, item.UnitPrice.TruncDecimals(2), item.PplNum);
  13490. vi_label.AppendLine(label);
  13491. }
  13492. if (vi_label.HasValue())
  13493. {
  13494. //以上小计:6000元
  13495. string label = string.Format("以上小计:{0}元", visaIns.TotalAmt.TruncDecimals(2));
  13496. vi_label.AppendLine(label);
  13497. }
  13498. }
  13499. designer.SetDataSource("VisaInsContent", vi_label.ToString());
  13500. #endregion
  13501. #region 服务费
  13502. designer.SetDataSource("ServiceCostTitle", serviceCosts?.ItemWrapName ?? "服务费");
  13503. designer.SetDataSource("ServiceCostContent", serviceCosts?.TotalAmt.TruncDecimals(2) ?? 0.00M);
  13504. #endregion
  13505. #region 公杂费
  13506. designer.SetDataSource("PubMiscsTitle", pubMiscs?.ItemWrapName ?? "公杂费\r\n(发给团组成员)");
  13507. var pm_label = new StringBuilder();
  13508. if (pubMiscs != null && pubMiscs.Infos.Any())
  13509. {
  13510. string currencyName = string.Empty,
  13511. countryName = string.Empty;
  13512. decimal rate = 1.0000M;
  13513. foreach (var item in pubMiscs.Infos)
  13514. {
  13515. //乌兹别克斯坦:塔什干:32美金 / 天 * 3 * 6人
  13516. string name = string.Empty, thisCountryName = string.Empty;
  13517. if (item.FeeName.Contains('-'))
  13518. {
  13519. var feeName = item.FeeName.Split('-');
  13520. thisCountryName = feeName[0];
  13521. if (!thisCountryName.Equals(countryName)) countryName = feeName[0];
  13522. name = feeName[1];
  13523. }
  13524. else name = item.FeeName;
  13525. string thisFeeName = string.Empty;
  13526. if (!thisCountryName.Equals(countryName)) thisFeeName = $"{countryName}:\r\n{name}:";
  13527. else thisFeeName = $"\r\n{name}:";
  13528. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  13529. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  13530. rate = rateInfo?.Rate ?? 1.0000M;
  13531. string label = string.Format("{0}:{1}{2}/天*{3}*{4}人", thisFeeName, item.UnitPrice.TruncDecimals(2), currencyName, item.Quantity, item.PplNum);
  13532. pm_label.AppendLine(label);
  13533. }
  13534. if (pm_label.HasValue())
  13535. {
  13536. //以上小计:13497.6元\r\n(美金汇率:7.5 )\r\n部分发放成员
  13537. pm_label.AppendLine(string.Format("以上小计:{0}元", pubMiscs.TotalAmt.TruncDecimals(2)));
  13538. pm_label.AppendLine(string.Format("({0}汇率:{1})", currencyName, rate.TruncDecimals(4)));
  13539. pm_label.AppendLine(string.Format("部分发放成员"));
  13540. }
  13541. }
  13542. designer.SetDataSource("PubMiscsContent", pm_label.ToString());
  13543. #endregion
  13544. #region 税费
  13545. designer.SetDataSource("TaxCostTitle", taxCosts?.ItemWrapName ?? "税费");
  13546. designer.SetDataSource("TaxCostContent", taxCosts?.TotalAmt.TruncDecimals(2) ?? 0.00M);
  13547. #endregion
  13548. #region 合计(单位:元)
  13549. designer.SetDataSource("CostTotalTitle", "合计\r\n(单位:元)");
  13550. designer.SetDataSource("CostTotalContent", info.FeeItems.Sum(x => x.TotalAmt).TruncDecimals(2));
  13551. #endregion
  13552. #region 汇率 Remark
  13553. var rate_label = new StringBuilder();
  13554. var rateGroups = rates.GroupBy(x => x.CurrencyName);
  13555. foreach (var item in rateGroups)
  13556. {
  13557. //美元汇率按\r\n1:7.5
  13558. string label = string.Format("{0}汇率按\r\n1:{1}", item.Key, item.FirstOrDefault()?.Rate.TruncDecimals(4) ?? 0.0000M);
  13559. rate_label.AppendLine(label);
  13560. }
  13561. designer.SetDataSource("RateLabel", rate_label.ToString());
  13562. #endregion
  13563. designer.Process();
  13564. //文件名
  13565. string fileName = $"{info.Name}{DateTime.Now:yyyyMMddHHmmss}.xls";
  13566. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + "EnterExitCostQuote/" + fileName);
  13567. string url = AppSettingsHelper.Get("ExcelBaseUrl") + "Office/Excel/EnterExitCostQuote/" + fileName;
  13568. return Ok(JsonView(true, "成功", url));
  13569. }
  13570. #endregion
  13571. #region 签证费用录入
  13572. /// <summary>
  13573. /// 根据diid查询签证费用列表
  13574. /// </summary>
  13575. /// <param name="dto"></param>
  13576. /// <returns></returns>
  13577. [HttpPost]
  13578. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13579. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  13580. {
  13581. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  13582. if (groupData.Code != 0)
  13583. {
  13584. return Ok(JsonView(false, groupData.Msg));
  13585. }
  13586. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  13587. }
  13588. /// <summary>
  13589. /// 根据签证费用Id查询单条数据及c表数据
  13590. /// </summary>
  13591. /// <param name="dto"></param>
  13592. /// <returns></returns>
  13593. [HttpPost]
  13594. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13595. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  13596. {
  13597. Result groupData = await _visaPriceRep.PostVisaById(dto);
  13598. if (groupData.Code != 0)
  13599. {
  13600. return Ok(JsonView(false, groupData.Msg));
  13601. }
  13602. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  13603. }
  13604. /// <summary>
  13605. /// 签证费用删除
  13606. /// </summary>
  13607. /// <param name="dto"></param>
  13608. /// <returns></returns>
  13609. [HttpPost]
  13610. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13611. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  13612. {
  13613. _sqlSugar.BeginTran();
  13614. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  13615. if (!res)
  13616. {
  13617. _sqlSugar.RollbackTran();
  13618. return Ok(JsonView(false, "删除失败"));
  13619. }
  13620. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  13621. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  13622. .SetColumns(a => new Grp_CreditCardPayment()
  13623. {
  13624. IsDel = 1,
  13625. DeleteUserId = dto.DeleteUserId,
  13626. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  13627. })
  13628. .ExecuteCommand();
  13629. if (resSub < 1)
  13630. {
  13631. _sqlSugar.RollbackTran();
  13632. return Ok(JsonView(false, "删除失败"));
  13633. }
  13634. _sqlSugar.CommitTran();
  13635. return Ok(JsonView(true, "删除成功!"));
  13636. }
  13637. /// <summary>
  13638. /// 签证费用录入下拉框初始化
  13639. /// </summary>
  13640. /// <returns></returns>
  13641. [HttpPost]
  13642. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13643. public async Task<IActionResult> VisaPriceAddSelect()
  13644. {
  13645. //支付方式
  13646. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  13647. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  13648. //币种
  13649. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  13650. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  13651. //乘客类型
  13652. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  13653. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  13654. //卡类型
  13655. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  13656. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  13657. //代办费类型
  13658. var agencyFeeTypeData = new List<dynamic>() {
  13659. new { id = 0 , Text = "未选择" },
  13660. new { id = 1 , Text = "小公务" },
  13661. new { id = 2 , Text = "大公务" },
  13662. };
  13663. //签证费用标准国家Data
  13664. var visaSql = string.Format(@"select
  13665. id,
  13666. case
  13667. when FeeType = 0 then Country+'(因公)'
  13668. when FeeType = 1 then Country+'(因私)'
  13669. else Country+'(未设置)'
  13670. end as 'country'
  13671. from Res_VisaFeeStandard where isdel = 0");
  13672. var visaCountryFeeData = _sqlSugar.SqlQueryable<dynamic>(visaSql).ToList();
  13673. var data = new
  13674. {
  13675. Payment = _Payment,
  13676. CurrencyList = _CurrencyList,
  13677. PassengerType = _PassengerType,
  13678. BankCard = _BankCard,
  13679. AgencyFeeType = agencyFeeTypeData,
  13680. CountryFeeData = visaCountryFeeData
  13681. };
  13682. return Ok(JsonView(true, "查询成功!", data));
  13683. }
  13684. /// <summary>
  13685. /// 签证费用录入操作(Status:1.新增,2.修改)
  13686. /// </summary>
  13687. /// <param name="dto"></param>
  13688. /// <returns></returns>
  13689. [HttpPost]
  13690. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13691. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  13692. {
  13693. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  13694. if (groupData.Code != 0)
  13695. {
  13696. return Ok(JsonView(false, groupData.Msg));
  13697. }
  13698. #region 应用推送
  13699. try
  13700. {
  13701. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  13702. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  13703. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  13704. //2024-10-21 新增LZ UID
  13705. var userIds = new List<int>() { 21 };
  13706. string title = $"系统通知";
  13707. string content = "";
  13708. var diId = dto.DiId;
  13709. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  13710. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  13711. if (dto.Status == 1) content = $"[新增-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  13712. else if (dto.Status == 2) content = $"[更新-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  13713. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  13714. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "80" };
  13715. await APNsTools.iOS_PushNotifications1("051", $"签证费用审核", "", content, true, "ExpenseAuditWebView", h5);
  13716. }
  13717. catch (Exception ex)
  13718. {
  13719. }
  13720. #endregion
  13721. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  13722. }
  13723. #endregion
  13724. #region 签证提成录入
  13725. /// <summary>
  13726. /// 签证提成录入
  13727. /// 基础数据
  13728. /// </summary>
  13729. /// <returns></returns>
  13730. [HttpGet]
  13731. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13732. public async Task<IActionResult> VisaCommissionInit()
  13733. {
  13734. return Ok(await _visaCommissionRep.Init());
  13735. }
  13736. /// <summary>
  13737. /// 签证提成录入
  13738. /// Item
  13739. /// </summary>
  13740. /// <param name="_dto"></param>
  13741. /// <returns></returns>
  13742. [HttpPost]
  13743. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13744. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
  13745. {
  13746. var validator = new VisaCommissionItemDtoValidator();
  13747. var validatorRes = await validator.ValidateAsync(_dto);
  13748. if (!validatorRes.IsValid)
  13749. {
  13750. var sb = new StringBuilder();
  13751. foreach (var item in validatorRes.Errors)
  13752. {
  13753. sb.AppendLine(item.ErrorMessage);
  13754. }
  13755. return Ok(JsonView(false, sb.ToString()));
  13756. }
  13757. return Ok(await _visaCommissionRep.Item(_dto));
  13758. }
  13759. /// <summary>
  13760. /// 签证提成录入
  13761. /// Save
  13762. /// </summary>
  13763. /// <param name="_dto"></param>
  13764. /// <returns></returns>
  13765. [HttpPost]
  13766. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13767. public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
  13768. {
  13769. //参数验证
  13770. if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
  13771. foreach (var item in _dto.Items)
  13772. {
  13773. if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
  13774. if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
  13775. if (string.IsNullOrEmpty(item.Country)) return Ok(JsonView(false, "国家为空!"));
  13776. //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
  13777. }
  13778. return Ok(await _visaCommissionRep.Save(_dto));
  13779. }
  13780. /// <summary>
  13781. /// 签证提成录入
  13782. /// Create
  13783. /// </summary>
  13784. /// <param name="_dto"></param>
  13785. /// <returns></returns>
  13786. [HttpPost]
  13787. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13788. public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
  13789. {
  13790. var validator = new VisaCommissionCreateDtoValidator();
  13791. var validatorRes = await validator.ValidateAsync(_dto);
  13792. if (!validatorRes.IsValid)
  13793. {
  13794. var sb = new StringBuilder();
  13795. foreach (var item in validatorRes.Errors)
  13796. {
  13797. sb.AppendLine(item.ErrorMessage);
  13798. }
  13799. return Ok(JsonView(false, sb.ToString()));
  13800. }
  13801. return Ok(await _visaCommissionRep.Create(_dto));
  13802. }
  13803. /// <summary>
  13804. /// 签证提成录入
  13805. /// Put(编辑)
  13806. /// </summary>
  13807. /// <param name="id"></param>
  13808. /// <param name="_dto"></param>
  13809. /// <returns></returns>
  13810. [HttpPut]
  13811. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13812. public async Task<IActionResult> VisaCommissionEdit(int id, VisaCommissionCreateDto _dto)
  13813. {
  13814. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  13815. var validator = new VisaCommissionCreateDtoValidator();
  13816. var validatorRes = await validator.ValidateAsync(_dto);
  13817. if (!validatorRes.IsValid)
  13818. {
  13819. var sb = new StringBuilder();
  13820. foreach (var item in validatorRes.Errors)
  13821. {
  13822. sb.AppendLine(item.ErrorMessage);
  13823. }
  13824. return Ok(JsonView(false, sb.ToString()));
  13825. }
  13826. return Ok(await _visaCommissionRep.Edit(id, _dto));
  13827. }
  13828. /// <summary>
  13829. /// 签证提成录入
  13830. /// Del
  13831. /// </summary>
  13832. /// <param name="id"></param>
  13833. /// <param name="currUserId"></param>
  13834. /// <returns></returns>
  13835. [HttpPost]
  13836. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13837. public async Task<IActionResult> VisaCommissionDel(int id, int currUserId)
  13838. {
  13839. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  13840. if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
  13841. return Ok(await _visaCommissionRep.Del(id, currUserId));
  13842. }
  13843. #endregion
  13844. #region op费用录入
  13845. /// <summary>
  13846. /// 根据diid查询op费用列表
  13847. /// </summary>
  13848. /// <param name="dto"></param>
  13849. /// <returns></returns>
  13850. [HttpPost]
  13851. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13852. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  13853. {
  13854. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  13855. if (groupData.Code != 0)
  13856. {
  13857. return Ok(JsonView(false, groupData.Msg));
  13858. }
  13859. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  13860. }
  13861. /// <summary>
  13862. /// 根据op费用Id查询单条数据及c表数据
  13863. /// </summary>
  13864. /// <param name="dto"></param>
  13865. /// <returns></returns>
  13866. [HttpPost]
  13867. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13868. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  13869. {
  13870. try
  13871. {
  13872. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  13873. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  13874. var data = new
  13875. {
  13876. CarTouristGuideGround = _groupData,
  13877. CreditCardPayment = _creditCardPayment
  13878. };
  13879. return Ok(JsonView(true, "查询成功!", data));
  13880. }
  13881. catch (Exception ex)
  13882. {
  13883. return Ok(JsonView(false, "程序错误!"));
  13884. }
  13885. }
  13886. /// <summary>
  13887. /// op费用删除
  13888. /// </summary>
  13889. /// <param name="dto"></param>
  13890. /// <returns></returns>
  13891. [HttpPost]
  13892. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13893. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  13894. {
  13895. try
  13896. {
  13897. _sqlSugar.BeginTran();
  13898. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  13899. if (!res)
  13900. {
  13901. return Ok(JsonView(false, "删除失败"));
  13902. }
  13903. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  13904. {
  13905. IsDel = 1,
  13906. DeleteUserId = dto.DeleteUserId,
  13907. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  13908. }).ExecuteCommandAsync();
  13909. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  13910. {
  13911. IsDel = 1,
  13912. DeleteUserId = dto.DeleteUserId,
  13913. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  13914. }).ExecuteCommandAsync();
  13915. #region 删除超支相关数据
  13916. //删除导入的超支数据
  13917. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  13918. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  13919. {
  13920. IsDel = 1,
  13921. DeleteUserId = dto.DeleteUserId,
  13922. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  13923. }).ExecuteCommand();
  13924. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  13925. {
  13926. IsDel = 1,
  13927. DeleteUserId = dto.DeleteUserId,
  13928. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  13929. }).ExecuteCommand();
  13930. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  13931. {
  13932. IsDel = 1,
  13933. DeleteUserId = dto.DeleteUserId,
  13934. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  13935. }).ExecuteCommand();
  13936. #endregion
  13937. _sqlSugar.CommitTran();
  13938. return Ok(JsonView(true, "删除成功!"));
  13939. }
  13940. catch (Exception ex)
  13941. {
  13942. _sqlSugar.RollbackTran();
  13943. return Ok(JsonView(false, "程序错误!" + ex.Message));
  13944. }
  13945. }
  13946. /// <summary>
  13947. /// op费用录入操作(Status:1.新增,2.修改)
  13948. /// </summary>
  13949. /// <param name="dto"></param>
  13950. /// <returns></returns>
  13951. [HttpPost]
  13952. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13953. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  13954. {
  13955. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  13956. if (groupData.Code != 0)
  13957. {
  13958. return Ok(JsonView(false, groupData.Msg));
  13959. }
  13960. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  13961. }
  13962. /// <summary>
  13963. /// 填写费用详细页面初始化绑定
  13964. /// </summary>
  13965. /// <param name="dto"></param>
  13966. /// <returns></returns>
  13967. [HttpPost]
  13968. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13969. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  13970. {
  13971. try
  13972. {
  13973. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  13974. if (groupData.Code != 0)
  13975. {
  13976. return Ok(JsonView(false, groupData.Msg));
  13977. }
  13978. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  13979. }
  13980. catch (Exception ex)
  13981. {
  13982. return Ok(JsonView(false, ex.Message));
  13983. }
  13984. }
  13985. /// <summary>
  13986. /// 根据op费用Id查询详细数据
  13987. /// </summary>
  13988. /// <param name="dto"></param>
  13989. /// <returns></returns>
  13990. [HttpPost]
  13991. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13992. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  13993. {
  13994. try
  13995. {
  13996. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  13997. if (groupData.Code != 0)
  13998. {
  13999. return Ok(JsonView(false, groupData.Msg));
  14000. }
  14001. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  14002. }
  14003. catch (Exception ex)
  14004. {
  14005. return Ok(JsonView(false, ex.Message));
  14006. }
  14007. }
  14008. /// <summary>
  14009. /// OP费用录入填写详情
  14010. /// </summary>
  14011. /// <param name="dto"></param>
  14012. /// <returns></returns>
  14013. [HttpPost]
  14014. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14015. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  14016. {
  14017. try
  14018. {
  14019. #region 参数校验
  14020. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  14021. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  14022. if (di == null) return Ok(JsonView(false, "团组错误!"));
  14023. #endregion
  14024. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  14025. if (groupData.Code != 0)
  14026. {
  14027. return Ok(JsonView(false, groupData.Msg));
  14028. }
  14029. //自动审核
  14030. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  14031. #region 尾款自动审核
  14032. var opinfos = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>()
  14033. .First(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Id == dto.CTGGRId);
  14034. if (opinfos.PriceType == 1062)
  14035. {
  14036. var isAuto = false;
  14037. //找对应的首付款
  14038. var firstPrice = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>()
  14039. .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))
  14040. .First(x => x.IsDel == 0 && x.DiId == dto.DiId && x.PriceName == opinfos.PriceName &&
  14041. x.ServiceStartTime == opinfos.ServiceStartTime && x.ServiceEndTime == opinfos.ServiceEndTime && x.Area == opinfos.Area &&
  14042. x.PriceType == 1061 && x.DiId == dto.DiId);
  14043. if (firstPrice != null && !(opinfos.SelectCheck.Contains("超时") || opinfos.SelectCheck.Contains("超支")) && firstPrice.CId == opinfos.CId)
  14044. {
  14045. var cprice = _sqlSugar.Queryable<Grp_CreditCardPayment>().First(x => x.IsDel == 0 && x.CId == firstPrice.Id && x.CTable == 79);
  14046. var balance = firstPrice.ServiceQuotedPrice * (100 - cprice.PayPercentage) / 100;
  14047. //合计中排除城市税
  14048. var cityPrice = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent>()
  14049. .Where(x => x.SId == 1452 && x.IsDel == 0 && x.DiId == dto.DiId && x.CTGGRId == dto.CTGGRId)
  14050. .Sum(x => x.Price * x.Count);
  14051. opinfos.ServiceQuotedPrice = opinfos.ServiceQuotedPrice - cityPrice;
  14052. if (balance >= opinfos.ServiceQuotedPrice)
  14053. {
  14054. isAuto = true;
  14055. }
  14056. }
  14057. if (isAuto)
  14058. {
  14059. var execCount = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  14060. .SetColumns(a => new Grp_CreditCardPayment
  14061. {
  14062. IsAuditGM = 3, //自动审核通过
  14063. AuditGMOperate = 4,
  14064. AuditGMDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  14065. })
  14066. .Where(a => a.CId == dto.CTGGRId && a.CTable == 79 && a.DIId == dto.DiId)
  14067. .ExecuteCommand();
  14068. }
  14069. }
  14070. #endregion
  14071. #region 应用推送
  14072. try
  14073. {
  14074. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  14075. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  14076. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  14077. //2024-10-21 新增LZ UID
  14078. var userIds = new List<int>() { 21 };
  14079. string title = $"系统通知";
  14080. var diId = dto.DiId;
  14081. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  14082. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  14083. string content = $"[更新-OP费用录入填写详情({groupInfo?.TeamName ?? "-"})]一项费用:{(((ccpInfo.PayMoney * ccpInfo.DayRate) / 100) * ccpInfo.PayPercentage):#0.00} CNY;";
  14084. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  14085. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "79" };
  14086. await APNsTools.iOS_PushNotifications1("051", $"OP费用审核", "", content, true, "ExpenseAuditWebView", h5);
  14087. }
  14088. catch (Exception ex)
  14089. {
  14090. }
  14091. #endregion
  14092. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  14093. }
  14094. catch (Exception ex)
  14095. {
  14096. return Ok(JsonView(false, ex.Message));
  14097. }
  14098. }
  14099. /// <summary>
  14100. /// 获取三公详细所有城市
  14101. /// </summary>
  14102. /// <returns></returns>
  14103. [HttpGet]
  14104. public IActionResult OpCarCityResult()
  14105. {
  14106. var jw = JsonView(false);
  14107. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  14108. {
  14109. x.Id,
  14110. x.Country,
  14111. x.City,
  14112. }).ToList();
  14113. if (data.Count > 0)
  14114. {
  14115. jw = JsonView(true, "获取成功!", data);
  14116. }
  14117. else
  14118. {
  14119. jw.Msg = "城市数据为空!";
  14120. jw.Data = Array.Empty<string>();
  14121. }
  14122. return Ok(jw);
  14123. }
  14124. /// <summary>
  14125. /// 导出地接费用明细
  14126. /// </summary>
  14127. /// <param name="dto"></param>
  14128. /// <returns></returns>
  14129. [HttpPost]
  14130. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  14131. {
  14132. var jw = JsonView(false);
  14133. if (dto.Diid < 1)
  14134. {
  14135. jw.Msg = "请输入正确的diid!";
  14136. return Ok(jw);
  14137. }
  14138. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  14139. if (group == null)
  14140. {
  14141. jw.Msg = "未找到团组信息!";
  14142. return Ok(jw);
  14143. }
  14144. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  14145. if (localGuideArr.Count == 0)
  14146. {
  14147. jw.Msg = "该团组暂无地接信息!";
  14148. return Ok(jw);
  14149. }
  14150. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  14151. var overspendSoure = new Dictionary<int, int>
  14152. {
  14153. { 91, 982 }, //车
  14154. { 92 , 1059} ,//导游
  14155. { 994 , 1073}, //翻译
  14156. { 988 , 1074 }, //早餐
  14157. { 93 , 1075 }, //午餐
  14158. { 989 , 1076 }, //晚餐
  14159. };
  14160. var Zips = new Dictionary<string, Stream>();
  14161. foreach (var groupArr in localGroup)
  14162. {
  14163. var keyValue = groupArr.Key;
  14164. if (int.TryParse(keyValue, out int cityid))
  14165. {
  14166. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  14167. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  14168. }
  14169. var contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  14170. foreach (var item in groupArr)
  14171. {
  14172. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  14173. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  14174. new Grp_CarTouristGuideGroundReservationsContentExtend
  14175. {
  14176. Count = a.Count,
  14177. CreateTime = a.CreateTime,
  14178. CreateUserId = a.CreateUserId,
  14179. CTGGRId = a.CTGGRId,
  14180. Currency = a.Currency,
  14181. DatePrice = a.DatePrice,
  14182. DeleteTime = a.DeleteTime,
  14183. DeleteUserId = a.DeleteUserId,
  14184. DiId = a.DiId,
  14185. Id = a.Id,
  14186. IsDel = a.IsDel,
  14187. Price = a.Price,
  14188. PriceContent = a.PriceContent,
  14189. Remark = a.Remark,
  14190. SId = a.SId,
  14191. SidName = b.Name,
  14192. Units = a.Units,
  14193. }
  14194. ).ToList();
  14195. if (content.Count > 0)
  14196. {
  14197. contentArr.Add(content);
  14198. }
  14199. }
  14200. //open excel
  14201. //set excel
  14202. //save excel
  14203. try
  14204. {
  14205. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  14206. IWorkbook workbook;
  14207. if (Path.GetExtension(filePath).ToLower() == ".xls")
  14208. {
  14209. workbook = new NPOI.HSSF.UserModel.HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  14210. }
  14211. else
  14212. {
  14213. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  14214. }
  14215. ISheet sheet = workbook.GetSheetAt(0);
  14216. var rowStartIndex = 2;
  14217. var clounmCount = 10;
  14218. var initStyleRow = sheet.GetRow(2);
  14219. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  14220. //var overspendArrDetail =
  14221. var existsId = new List<CarCompare>();
  14222. var lastElem = arr.Last();
  14223. var thisSid = -1;
  14224. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  14225. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  14226. {
  14227. Name = "未知币种!",
  14228. Remark = "未知币种!",
  14229. };
  14230. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  14231. Action cloneRowFn = () =>
  14232. {
  14233. rowStartIndex++;
  14234. var cloneRow = sheet.CreateRow(rowStartIndex);
  14235. // 复制样式
  14236. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  14237. {
  14238. ICell sourceCell = initStyleRow.GetCell(i);
  14239. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  14240. // 确保单元格存在样式
  14241. if (sourceCell.CellStyle != null)
  14242. {
  14243. targetCell.CellStyle = sourceCell.CellStyle;
  14244. }
  14245. }
  14246. };
  14247. var mergeRow = () =>
  14248. {
  14249. for (int i = 2; i < sheet.LastRowNum; i++)
  14250. {
  14251. var row = sheet.GetRow(i);
  14252. var cellFirst = row.GetCell(0);
  14253. var thisIndex = i + 1;
  14254. while (thisIndex < sheet.LastRowNum)
  14255. {
  14256. var nextRow = sheet.GetRow(thisIndex);
  14257. var nextCellFirst = nextRow.GetCell(0);
  14258. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  14259. {
  14260. thisIndex++;
  14261. }
  14262. else
  14263. {
  14264. break;
  14265. }
  14266. }
  14267. thisIndex--;
  14268. if (thisIndex != i)
  14269. {
  14270. //合并row
  14271. var cellRangeAddress = new CellRangeAddress(
  14272. i, // 起始行索引(0-based)
  14273. thisIndex, // 结束行索引(0-based)
  14274. 0, // 起始列索引(0-based)
  14275. 0 // 结束列索引(0-based)
  14276. );
  14277. sheet.AddMergedRegion(cellRangeAddress);
  14278. i = thisIndex;
  14279. }
  14280. }
  14281. };
  14282. var chaoshiNumber = 0;
  14283. var totalNumber = 0.00M;
  14284. string lastStr = "";
  14285. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  14286. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  14287. {
  14288. b.IsAuditGM,
  14289. x.Id,
  14290. x.Area,
  14291. b.PayPercentage,
  14292. b.PayMoney,
  14293. }).ToList();
  14294. string yesPayment = "", noPayment = "";
  14295. foreach (var item in queryCarArrByCityAndDiid)
  14296. {
  14297. if (item.IsAuditGM == 1)
  14298. {
  14299. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  14300. }
  14301. else
  14302. {
  14303. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  14304. }
  14305. }
  14306. lastStr = yesPayment + noPayment;
  14307. foreach (var item in arr)
  14308. {
  14309. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.ContainsValue(item.SId))
  14310. {
  14311. if (thisSid != item.SId)
  14312. {
  14313. if (thisSid == -1)
  14314. {
  14315. thisSid = item.SId;
  14316. }
  14317. else
  14318. {
  14319. //合并小计行
  14320. //创建合并区域的实例
  14321. var cellRangeAddress = new CellRangeAddress(
  14322. rowStartIndex, // 起始行索引(0-based)
  14323. rowStartIndex, // 结束行索引(0-based)
  14324. 0, // 起始列索引(0-based)
  14325. 3 // 结束列索引(0-based)
  14326. );
  14327. sheet.AddMergedRegion(cellRangeAddress);
  14328. var CellStyle = workbook.CreateCellStyle();
  14329. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  14330. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  14331. CellStyle.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground; // 填充方式
  14332. for (int i = 0; i <= clounmCount; i++)
  14333. {
  14334. if (i > 6)
  14335. {
  14336. var CellStyle1 = workbook.CreateCellStyle();
  14337. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  14338. IFont Font = workbook.CreateFont(); // 创建字体
  14339. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  14340. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  14341. CellStyle1.SetFont(Font);
  14342. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  14343. }
  14344. else
  14345. {
  14346. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  14347. }
  14348. }
  14349. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  14350. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  14351. //超时合计
  14352. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  14353. //超时数
  14354. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  14355. //超时合计费用
  14356. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  14357. thisSid = item.SId;
  14358. cloneRowFn();
  14359. chaoshiNumber = 0;
  14360. totalNumber = 0;
  14361. }
  14362. }
  14363. IRow row = sheet.GetRow(rowStartIndex);
  14364. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  14365. var isOpenOverspendSoure = overspendSoure.ContainsKey(item.SId);
  14366. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  14367. if (isOpenOverspendSoure)
  14368. {
  14369. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  14370. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  14371. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  14372. }
  14373. for (int i = 0; i <= clounmCount; i++)
  14374. {
  14375. var cell = row.GetCell(i);
  14376. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  14377. if (cell == null)
  14378. {
  14379. cell = row.CreateCell(i);
  14380. }
  14381. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  14382. fontRed.CloneStyleFrom(cell.CellStyle);
  14383. IFont Font = workbook.CreateFont(); // 创建字体
  14384. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  14385. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  14386. fontRed.SetFont(Font);
  14387. byte[] rgb = new byte[3] { 255, 242, 204 };
  14388. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  14389. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  14390. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  14391. if (workbook is XSSFWorkbook)
  14392. {
  14393. BackgroundColor255_242_204.FillForegroundColor = 0;
  14394. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  14395. BackgroundColor255_242_204.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground;
  14396. }
  14397. else
  14398. {
  14399. BackgroundColor255_242_204.FillForegroundColor = (((NPOI.HSSF.UserModel.HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  14400. }
  14401. if (i == 1 || i > 6)
  14402. {
  14403. if (i > 6)
  14404. {
  14405. fontRed.FillForegroundColor = 0;
  14406. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  14407. fontRed.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground;
  14408. }
  14409. cell.CellStyle = fontRed;
  14410. }
  14411. if (i > 2 && i < 7)
  14412. {
  14413. cell.CellStyle = BackgroundColor255_242_204;
  14414. }
  14415. cell.SetCellValue(setCellValue); //写入单元格
  14416. }
  14417. if (overspendSoure.ContainsKey(thisSid))
  14418. {
  14419. var overspendId = overspendSoure[thisSid];
  14420. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  14421. }
  14422. cloneRowFn();
  14423. existsId.Add(new CarCompare
  14424. {
  14425. DataPrice = item.DatePrice.ObjToDate(),
  14426. Sid = item.SId
  14427. });
  14428. }
  14429. if (item.Equals(lastElem))
  14430. {
  14431. //合并小计行
  14432. //创建合并区域的实例
  14433. var cellRangeAddress = new CellRangeAddress(
  14434. rowStartIndex, // 起始行索引(0-based)
  14435. rowStartIndex, // 结束行索引(0-based)
  14436. 0, // 起始列索引(0-based)
  14437. 3 // 结束列索引(0-based)
  14438. );
  14439. sheet.AddMergedRegion(cellRangeAddress);
  14440. var CellStyle = workbook.CreateCellStyle();
  14441. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  14442. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  14443. CellStyle.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground; // 填充方式
  14444. for (int i = 0; i <= clounmCount; i++)
  14445. {
  14446. if (i > 6)
  14447. {
  14448. var CellStyle1 = workbook.CreateCellStyle();
  14449. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  14450. IFont Font = workbook.CreateFont(); // 创建字体
  14451. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  14452. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  14453. CellStyle1.SetFont(Font);
  14454. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  14455. }
  14456. else
  14457. {
  14458. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  14459. }
  14460. }
  14461. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  14462. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  14463. //超时合计
  14464. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  14465. //超时数
  14466. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  14467. //超时合计费用
  14468. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  14469. cloneRowFn();
  14470. // 创建合并区域的实例
  14471. cellRangeAddress = new CellRangeAddress(
  14472. rowStartIndex, // 起始行索引(0-based)
  14473. rowStartIndex, // 结束行索引(0-based)
  14474. 0, // 起始列索引(0-based)
  14475. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  14476. );
  14477. // 添加合并区域
  14478. sheet.AddMergedRegion(cellRangeAddress);
  14479. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  14480. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  14481. }
  14482. }
  14483. mergeRow();
  14484. // 保存修改后的Excel文件到新文件
  14485. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  14486. // new FileStream(newFilePath, FileMode.CreateNew)
  14487. using (var stream = new MemoryStream())
  14488. {
  14489. workbook.Write(stream, true);
  14490. stream.Flush();
  14491. stream.Seek(0, SeekOrigin.Begin);
  14492. var memoryStream = new MemoryStream();
  14493. stream.CopyTo(memoryStream);
  14494. memoryStream.Seek(0, SeekOrigin.Begin);
  14495. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  14496. }
  14497. workbook.Close();
  14498. workbook.Dispose();
  14499. }
  14500. catch (Exception ex)
  14501. {
  14502. jw.Msg = "出现异常!" + ex.Message;
  14503. return Ok(jw);
  14504. }
  14505. }
  14506. if (Zips.Count > 0)
  14507. {
  14508. var io = new IOOperatorHelper();
  14509. var byts = io.ConvertZipStream(Zips);
  14510. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  14511. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  14512. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  14513. }
  14514. else
  14515. {
  14516. jw.Msg = "暂无生成文件!";
  14517. }
  14518. return Ok(jw);
  14519. }
  14520. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  14521. {
  14522. string outStr = string.Empty;
  14523. switch (i)
  14524. {
  14525. case 0:
  14526. outStr = arr[0].SidName;
  14527. break;
  14528. case 1:
  14529. outStr = arr[0].DataPriceStr;
  14530. break;
  14531. case 2:
  14532. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  14533. break;
  14534. case 4:
  14535. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  14536. break;
  14537. case 7:
  14538. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  14539. {
  14540. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  14541. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  14542. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  14543. }
  14544. break;
  14545. case 8:
  14546. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  14547. {
  14548. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  14549. }
  14550. break;
  14551. case 9:
  14552. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  14553. {
  14554. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  14555. }
  14556. break;
  14557. case 10:
  14558. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  14559. {
  14560. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  14561. }
  14562. break;
  14563. }
  14564. return outStr;
  14565. }
  14566. #region OP行程单
  14567. /// <summary>
  14568. /// OP行程单初始化
  14569. /// </summary>
  14570. /// <param name="dto"></param>
  14571. /// <returns></returns>
  14572. [HttpPost]
  14573. public IActionResult InitOpTravel(InitOpTravelDto dto)
  14574. {
  14575. var jw = JsonView(false);
  14576. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  14577. var group = groupList.First();
  14578. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  14579. if (group == null)
  14580. {
  14581. jw.Msg = "暂无团组!";
  14582. return Ok(jw);
  14583. }
  14584. group = groupList.Find(x => x.Id == diid);
  14585. if (group == null)
  14586. {
  14587. jw.Msg = "请输入正确的团组ID!";
  14588. return Ok(jw);
  14589. }
  14590. string city = string.Empty;
  14591. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  14592. if (blackCode.Count > 0)
  14593. {
  14594. var black = blackCode.First();
  14595. black.BlackCode = black.BlackCode ?? "";
  14596. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  14597. if (blackSp.Length > 0)
  14598. {
  14599. try
  14600. {
  14601. var cityArrCode = new List<string>(20);
  14602. foreach (var item in blackSp)
  14603. {
  14604. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  14605. var IndexSelect = itemSp[2];
  14606. var cityArrCodeLength = cityArrCode.Count - 1;
  14607. var startCity = IndexSelect.Substring(0, 3);
  14608. if (cityArrCodeLength > 0)
  14609. {
  14610. var arrEndCity = cityArrCode[cityArrCodeLength];
  14611. if (arrEndCity != startCity)
  14612. {
  14613. cityArrCode.Add(startCity.ToUpper());
  14614. }
  14615. }
  14616. else
  14617. {
  14618. cityArrCode.Add(startCity.ToUpper());
  14619. }
  14620. var endCity = IndexSelect.Substring(3, 3);
  14621. cityArrCode.Add(endCity.ToUpper());
  14622. }
  14623. var cityThree = string.Empty;
  14624. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  14625. cityThree = cityThree.TrimEnd(',');
  14626. if (string.IsNullOrWhiteSpace(cityThree))
  14627. {
  14628. throw new
  14629. Exception("error");
  14630. }
  14631. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  14632. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  14633. foreach (var item in cityArrCode)
  14634. {
  14635. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  14636. if (find != null)
  14637. {
  14638. city += find.City + "/";
  14639. }
  14640. else
  14641. {
  14642. city += item + "三字码未收入/";
  14643. }
  14644. }
  14645. city = city.TrimEnd('/');
  14646. }
  14647. catch (Exception e)
  14648. {
  14649. city = "黑屏代码格式不正确!";
  14650. }
  14651. }
  14652. }
  14653. else
  14654. {
  14655. city = "未录入黑屏代码";
  14656. }
  14657. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  14658. {
  14659. Date = x.Date,
  14660. Days = x.Days,
  14661. Diffgroup = x.Diffgroup,
  14662. Diid = x.Diid,
  14663. Traffic_First = x.Traffic_First,
  14664. Traffic_Second = x.Traffic_Second,
  14665. Trip = x.Trip,
  14666. WeekDay = x.WeekDay,
  14667. Id = x.Id
  14668. }).ToList();
  14669. jw.Data = new
  14670. {
  14671. groupList = groupList.Select(x => new
  14672. {
  14673. x.Id,
  14674. x.TeamName,
  14675. x.TourCode
  14676. }).ToList(),
  14677. groupInfo = new
  14678. {
  14679. group.VisitDays,
  14680. group.TourCode,
  14681. group.VisitPNumber,
  14682. group.TeamName,
  14683. city
  14684. },
  14685. OpTravelList
  14686. };
  14687. jw.Code = 200;
  14688. jw.Msg = "操作成功!";
  14689. return Ok(jw);
  14690. }
  14691. /// <summary>
  14692. /// 删除团组行程单
  14693. /// </summary>
  14694. /// <returns></returns>
  14695. [HttpPost]
  14696. public IActionResult DelTravel(DelOpTravelDto dto)
  14697. {
  14698. var jw = JsonView(false);
  14699. if (dto.UserId <= 0 || dto.Diid <= 0)
  14700. {
  14701. jw.Msg = "请输入正确的参数!";
  14702. return Ok(jw);
  14703. }
  14704. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  14705. .SetColumns(x => new Grp_TravelList
  14706. {
  14707. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  14708. DeleteUserId = dto.UserId,
  14709. IsDel = 1,
  14710. }).ExecuteCommand();
  14711. jw = JsonView(true);
  14712. return Ok(jw);
  14713. }
  14714. /// <summary>
  14715. /// 行程单保存
  14716. /// </summary>
  14717. /// <returns></returns>
  14718. [HttpPost]
  14719. public IActionResult TravelSave(TravelSaveDto dto)
  14720. {
  14721. var jw = JsonView(false);
  14722. if (dto.Arr.Count > 0)
  14723. {
  14724. try
  14725. {
  14726. var travelList_DB = _sqlSugar.Queryable<Grp_TravelList>()
  14727. .Where(x => dto.Arr.Select(x => x.Id).Contains(x.Id))
  14728. .ToList();
  14729. _sqlSugar.BeginTran();
  14730. foreach (var item in dto.Arr)
  14731. {
  14732. if (item.Id == 0)
  14733. {
  14734. throw new Exception("请传入正确的Id");
  14735. }
  14736. //比较上一次的差异
  14737. var findTravel = travelList_DB.Find(x => x.Id == item.Id);
  14738. if (findTravel != null)
  14739. {
  14740. item.Trip = item.Trip.Replace("[++]", string.Empty);
  14741. findTravel.Trip = findTravel.Trip.Replace("[++]", string.Empty);
  14742. item.Trip = CheckStr(findTravel.Trip, item.Trip);
  14743. }
  14744. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  14745. .SetColumns(x => new Grp_TravelList
  14746. {
  14747. Trip = item.Trip
  14748. }).ExecuteCommand();
  14749. }
  14750. _sqlSugar.CommitTran();
  14751. jw = JsonView(true);
  14752. }
  14753. catch (Exception ex)
  14754. {
  14755. _sqlSugar.RollbackTran();
  14756. jw.Msg = "程序异常!" + ex.Message;
  14757. }
  14758. }
  14759. else
  14760. {
  14761. jw.Msg = "请传入正确的参数!";
  14762. }
  14763. return Ok(jw);
  14764. }
  14765. private static string CheckStr(string original, string changed)
  14766. {
  14767. // 创建diff_match_patch对象
  14768. var dmp = new diff_match_patch();
  14769. // 计算差异
  14770. List<Diff> diffs = dmp.diff_main(original, changed);
  14771. // 清理和合并差异
  14772. dmp.diff_cleanupSemantic(diffs);
  14773. // 使用StringBuilder构建最终的字符串
  14774. var finalString = new StringBuilder();
  14775. // 输出差异结果,并构建变动后的字符串
  14776. foreach (Diff diff in diffs)
  14777. {
  14778. switch (diff.operation)
  14779. {
  14780. case Operation.EQUAL:
  14781. // 相等的部分,直接添加到最终字符串
  14782. finalString.Append(diff.text);
  14783. break;
  14784. case Operation.INSERT:
  14785. // 插入的部分,添加标记并添加到最终字符串
  14786. finalString.Append("[++]" + diff.text + "[++]");
  14787. break;
  14788. case Operation.DELETE:
  14789. // 删除的部分,不添加到最终字符串
  14790. //finalString.Append("[++]" + diff.text + "[++]");
  14791. break;
  14792. }
  14793. }
  14794. // 输出变动后的字符串
  14795. return finalString.ToString();
  14796. }
  14797. private class tagContent
  14798. {
  14799. public DateTime Date { get; set; }
  14800. public string StartTag { get; set; }
  14801. public string EndTag { get; set; }
  14802. public string Content { get; set; }
  14803. public static int tagLength { get { return 3; } }
  14804. public static Tuple<string, string> TagFormat { get { return new Tuple<string, string>("【#", "#】"); } }
  14805. public string QueryTag { get { return this.StartTag + this.EndTag; } }
  14806. public bool IsFinally { get; set; }
  14807. }
  14808. private static List<string> ExtractContentBetweenTags(string input, string tag)
  14809. {
  14810. var results = new List<string>();
  14811. // 构造正则表达式,匹配形如 [++]内容[++] 的部分
  14812. string pattern = $@"{Regex.Escape(tag)}(.*?){Regex.Escape(tag)}";
  14813. // 添加 RegexOptions.Singleline 选项使 . 匹配包括换行符在内的所有字符
  14814. MatchCollection matches = Regex.Matches(input, pattern, RegexOptions.Singleline);
  14815. string[] strValueArr = new string[1];
  14816. foreach (System.Text.RegularExpressions.Match match in matches)
  14817. {
  14818. var strValue = match.Groups[1].Value;
  14819. strValueArr = Regex.Split(strValue, @"\r\n|\n");
  14820. }
  14821. results.AddRange(strValueArr.Where(x => !string.IsNullOrWhiteSpace(x)));
  14822. return results;
  14823. }
  14824. /// <summary>
  14825. /// 导出行程单
  14826. /// </summary>
  14827. /// <param name="dto"></param>
  14828. /// <returns></returns>
  14829. [HttpPost]
  14830. public IActionResult ExportTravel(ExportTravelDto dto)
  14831. {
  14832. var jw = JsonView(false);
  14833. jw.Data = "";
  14834. int diid = 0;
  14835. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  14836. if (Find == null)
  14837. {
  14838. jw.Msg = "请选择正确的团组!";
  14839. return Ok(jw);
  14840. }
  14841. else
  14842. {
  14843. diid = Find.Id;
  14844. }
  14845. //数据源
  14846. var _travelList = new List<Grp_TravelList>();
  14847. DataTable dtBlack = null;
  14848. try
  14849. {
  14850. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  14851. }
  14852. catch (Exception)
  14853. {
  14854. jw.Msg = "机票黑屏代码有误!";
  14855. return Ok(jw);
  14856. }
  14857. string CityStr = string.Empty;
  14858. if (dtBlack.Rows.Count == 0)
  14859. {
  14860. jw.Msg = "机票黑屏代码有误!";
  14861. return Ok(jw);
  14862. }
  14863. else
  14864. {
  14865. foreach (DataRow row in dtBlack.Rows)
  14866. {
  14867. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  14868. {
  14869. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  14870. return Ok(jw);
  14871. }
  14872. }
  14873. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  14874. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  14875. }
  14876. // 指定的文字
  14877. var targetTextDic = new Dictionary<string, List<string>>();
  14878. //创建数据源Table
  14879. var dtSource = new DataTable();
  14880. dtSource.Columns.Add("Days", typeof(string));
  14881. dtSource.Columns.Add("Date", typeof(string));
  14882. dtSource.Columns.Add("Week", typeof(string));
  14883. dtSource.Columns.Add("Traffic", typeof(string));
  14884. dtSource.Columns.Add("Trip", typeof(string));
  14885. //获取数据,放到datatable
  14886. foreach (var item in _travelList)
  14887. {
  14888. targetTextDic.Add(item.Date, ExtractContentBetweenTags(item.Trip, "[++]"));
  14889. item.Trip = item.Trip.Replace(tagContent.TagFormat.Item1, string.Empty)
  14890. .Replace(tagContent.TagFormat.Item2, string.Empty)
  14891. .Replace("[++]", string.Empty);
  14892. DataRow dr = dtSource.NewRow();
  14893. dr["Days"] = item.Days;
  14894. dr["Date"] = item.Date;
  14895. dr["Week"] = item.WeekDay;
  14896. dr["Traffic"] = item.Traffic_First
  14897. + "\r\n"
  14898. + item.Traffic_Second;
  14899. dr["Trip"] = item.Trip;
  14900. dtSource.Rows.Add(dr);
  14901. }
  14902. var dic = new Dictionary<string, string>
  14903. {
  14904. { "Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()) },
  14905. { "City", CityStr },
  14906. { "Days", Find.VisitDays.ToString() },
  14907. { "DeleCode", Find.TourCode },
  14908. { "Pnum", Find.VisitPNumber.ToString() }
  14909. };
  14910. //模板路径
  14911. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  14912. //载入模板
  14913. Document doc = null;
  14914. DocumentBuilder builder = null;
  14915. try
  14916. {
  14917. //载入模板
  14918. doc = new Document(tempPath);
  14919. builder = new DocumentBuilder(doc);
  14920. }
  14921. catch (Exception)
  14922. {
  14923. jw.Msg = "模板位置不存在!";
  14924. return Ok(jw);
  14925. }
  14926. foreach (var key in dic.Keys)
  14927. {
  14928. Bookmark bookmark = doc.Range.Bookmarks[key];
  14929. if (bookmark != null)
  14930. {
  14931. builder.MoveToBookmark(key);
  14932. builder.Write(dic[key]);
  14933. }
  14934. }
  14935. //获取word里所有表格
  14936. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  14937. //获取所填表格的序数
  14938. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  14939. try
  14940. {
  14941. //循环赋值
  14942. for (int i = 0; i < dtSource.Rows.Count; i++)
  14943. {
  14944. builder.MoveToCell(0, i + 1, 0, 0);
  14945. builder.Write(dtSource.Rows[i]["Days"].ToString());
  14946. builder.MoveToCell(0, i + 1, 1, 0);
  14947. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  14948. builder.MoveToCell(0, i + 1, 2, 0);
  14949. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  14950. var trip = dtSource.Rows[i]["Trip"].ToString();
  14951. builder.MoveToCell(0, i + 1, 3, 0);
  14952. builder.Write(trip);
  14953. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  14954. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  14955. // 获取特定索引的段落
  14956. Paragraph paragraph = (Paragraph)paragraphs[0];
  14957. Run run = paragraph.Runs[0];
  14958. Aspose.Words.Font font = run.Font;
  14959. font.Name = "黑体";
  14960. //设置双休红色
  14961. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  14962. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  14963. paragraph = (Paragraph)paragraphs[1];
  14964. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  14965. {
  14966. run = paragraph.Runs[0];
  14967. font = run.Font;
  14968. font.Color = Color.Red;
  14969. }
  14970. }
  14971. }
  14972. catch (Exception ex)
  14973. {
  14974. }
  14975. //删除多余行
  14976. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  14977. {
  14978. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  14979. }
  14980. var targetTextList = new List<string>();
  14981. // 遍历文档中的表格
  14982. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  14983. {
  14984. foreach (Aspose.Words.Tables.Row row in table.Rows)
  14985. {
  14986. var cellIndex = 0;
  14987. foreach (Cell cell in row.Cells)
  14988. {
  14989. if (cellIndex == 1 && row.Cells.Count == 4)
  14990. {
  14991. foreach (var target in targetTextDic.Keys)
  14992. {
  14993. if (cell.GetText().Contains(target))
  14994. {
  14995. targetTextList = targetTextDic[target];
  14996. break;
  14997. }
  14998. }
  14999. }
  15000. // 遍历单元格中的所有段落
  15001. foreach (Paragraph paragraph in cell.Paragraphs)
  15002. {
  15003. // 使用临时列表存储原始 Runs,避免修改时影响遍历
  15004. var runs = new List<Run>();
  15005. foreach (Run run in paragraph.Runs)
  15006. {
  15007. runs.Add(run);
  15008. }
  15009. foreach (Run run in runs)
  15010. {
  15011. foreach (var targetText in targetTextList)
  15012. {
  15013. // 检查文字是否包含指定文字
  15014. if (run.Text.Contains(targetText))
  15015. {
  15016. // 将包含的部分设置为红色
  15017. HighlightText(run, targetText, Color.Red);
  15018. }
  15019. }
  15020. }
  15021. }
  15022. cellIndex++;
  15023. }
  15024. }
  15025. }
  15026. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  15027. if (!Directory.Exists(savePath))
  15028. {
  15029. try
  15030. {
  15031. Directory.CreateDirectory(savePath);
  15032. }
  15033. catch
  15034. {
  15035. }
  15036. }
  15037. string path = savePath + Find.TeamName + "出访日程";
  15038. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  15039. try
  15040. {
  15041. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  15042. string postfix = ".docx";
  15043. if (dto.IsPDF == 1)
  15044. {
  15045. saveFormat = Aspose.Words.SaveFormat.Pdf;
  15046. postfix = ".pdf";
  15047. }
  15048. doc.Save(path + postfix, saveFormat);
  15049. jw = JsonView(true, "导出成功", ftpPath + postfix);
  15050. }
  15051. catch (Exception)
  15052. {
  15053. jw = JsonView(false);
  15054. }
  15055. return Ok(jw);
  15056. }
  15057. /// <summary>
  15058. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  15059. /// </summary>
  15060. /// <param name="num"></param>
  15061. /// <returns></returns>
  15062. static string GetNum(string num)
  15063. {
  15064. string str = "";
  15065. switch (num)
  15066. {
  15067. case "1":
  15068. str = "一";
  15069. break;
  15070. case "2":
  15071. str = "二";
  15072. break;
  15073. case "3":
  15074. str = "三";
  15075. break;
  15076. case "4":
  15077. str = "四";
  15078. break;
  15079. case "5":
  15080. str = "五";
  15081. break;
  15082. case "6":
  15083. str = "六";
  15084. break;
  15085. case "7":
  15086. str = "七";
  15087. break;
  15088. case "8":
  15089. str = "八";
  15090. break;
  15091. case "9":
  15092. str = "九";
  15093. break;
  15094. case "10":
  15095. str = "十";
  15096. break;
  15097. case "11":
  15098. str = "十一";
  15099. break;
  15100. case "12":
  15101. str = "十二";
  15102. break;
  15103. case "一":
  15104. str = "1";
  15105. break;
  15106. case "二":
  15107. str = "2";
  15108. break;
  15109. case "三":
  15110. str = "3";
  15111. break;
  15112. case "四":
  15113. str = "4";
  15114. break;
  15115. case "五":
  15116. str = "5";
  15117. break;
  15118. case "六":
  15119. str = "6";
  15120. break;
  15121. case "七":
  15122. str = "7";
  15123. break;
  15124. case "八":
  15125. str = "8";
  15126. break;
  15127. case "九":
  15128. str = "9";
  15129. break;
  15130. case "十":
  15131. str = "10";
  15132. break;
  15133. case "十一":
  15134. str = "11";
  15135. break;
  15136. case "十二":
  15137. str = "12";
  15138. break;
  15139. }
  15140. return str;
  15141. }
  15142. /// <summary>
  15143. /// 高亮包含指定文字的部分
  15144. /// </summary>
  15145. /// <param name="run"></param>
  15146. /// <param name="targetText"></param>
  15147. /// <param name="color"></param>
  15148. static void HighlightText(Run run, string targetText, Color color)
  15149. {
  15150. string text = run.Text;
  15151. int startIndex = text.IndexOf(targetText, StringComparison.Ordinal);
  15152. if (startIndex >= 0)
  15153. {
  15154. Paragraph parentParagraph = (Paragraph)run.ParentNode;
  15155. // 前部分
  15156. if (startIndex > 0)
  15157. {
  15158. Run beforeRun = (Run)run.Clone(true);
  15159. beforeRun.Text = text.Substring(0, startIndex);
  15160. parentParagraph.InsertBefore(beforeRun, run);
  15161. }
  15162. // 匹配部分
  15163. Run matchRun = (Run)run.Clone(true);
  15164. matchRun.Text = text.Substring(startIndex, targetText.Length);
  15165. matchRun.Font.Color = color;
  15166. parentParagraph.InsertBefore(matchRun, run);
  15167. // 后部分
  15168. if (startIndex + targetText.Length < text.Length)
  15169. {
  15170. Run afterRun = (Run)run.Clone(true);
  15171. afterRun.Text = text.Substring(startIndex + targetText.Length);
  15172. parentParagraph.InsertBefore(afterRun, run);
  15173. }
  15174. // 删除原始Run
  15175. run.Remove();
  15176. }
  15177. }
  15178. #endregion
  15179. #endregion
  15180. #region 团组成本
  15181. /// <summary>
  15182. /// 团组成本数据初始化
  15183. /// </summary>
  15184. /// <param name="dto"></param>
  15185. /// <returns></returns>
  15186. [HttpPost]
  15187. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  15188. {
  15189. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  15190. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  15191. WHEN COUNT(*) >= 0 THEN 'True'
  15192. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  15193. Where TeamName != '' And IsDel = 0 Order By a.VisitStartDate Desc
  15194. ").ToList(); //团组列表
  15195. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  15196. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  15197. var visaCountryInfoArr = new ArrayList();
  15198. var groupinfoValue = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == diid && x.IsDel == 0);
  15199. if (groupinfoValue != null)
  15200. {
  15201. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  15202. var dicity = _sqlSugar.Queryable<Sys_Cities>().First(x => x.IsDel == 0 && x.Id == groupinfoValue.CityId);
  15203. dicity ??= new Sys_Cities()
  15204. {
  15205. ParentId = 122
  15206. };
  15207. var diparent = _sqlSugar.Queryable<Sys_Cities>().First(x => x.IsDel == 0 && x.Id == dicity.ParentId);
  15208. var spArr = new string[1] { countryArr };
  15209. if (countryArr.Contains("|"))
  15210. {
  15211. spArr = countryArr.Split("|");
  15212. }
  15213. else if (countryArr.Contains("、"))
  15214. {
  15215. spArr = countryArr.Split("、");
  15216. }
  15217. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  15218. {
  15219. try
  15220. {
  15221. var visa = _sqlSugar.Queryable<Res_VisaFeeStandard>()
  15222. .Where(x => x.IsDel == 0 && x.Country == item)
  15223. .ToList();
  15224. if (visa.Any())
  15225. {
  15226. var visainfo = _sqlSugar.Queryable<Res_VisaFeeStandardDetails>()
  15227. .Where(x => x.IsDel == 0 && visa.Select(x => x.Id).Contains(x.ParentId))
  15228. .ToList();
  15229. var visaMain = visainfo.FirstOrDefault(x => x.ProvinceId == diparent.Id);
  15230. var visayinsiValue = visainfo.FirstOrDefault(x => x.ParentId == visa.FirstOrDefault(x => x.FeeType == 1)?.Id);
  15231. visaCountryInfoArr.Add(new
  15232. {
  15233. country = item,
  15234. yinsi = new
  15235. {
  15236. Id = visayinsiValue.Id,
  15237. value = visayinsiValue.SmallVisaPrice
  15238. },
  15239. visaMain = new
  15240. {
  15241. Id = visaMain.Id,
  15242. IsVisaOnArrival = visaMain.IsVisaOnArrival ? "是" : "否",
  15243. IsElectronicSign = visaMain.IsElectronicSign ? "是" : "否",
  15244. VisaTime = visaMain.VisaTime,
  15245. IsVisaExemptionLarge = visaMain.IsVisaExemptionLarge ? "是" : "否",
  15246. LargeVisaPrice = visaMain.LargeVisaPrice,
  15247. LargeAgencyFee = visaMain.LargeAgencyFee,
  15248. IsVisaExemptionSmall = visaMain.IsVisaExemptionSmall ? "是" : "否",
  15249. SmallVisaPrice = visaMain.SmallVisaPrice,
  15250. SmallAgencyFee = visaMain.SmallAgencyFee,
  15251. NormExtFee = visaMain.NormExtFee,
  15252. UrgExtFee = visaMain.UrgExtFee,
  15253. IsUrgent = visaMain.IsUrgent ? "是" : "否",
  15254. UrgentTime = visaMain.UrgentTime,
  15255. UrgentPrice = visaMain.UrgentPrice,
  15256. UrgentPriceDesc = visaMain.UrgentPriceDesc,
  15257. Remark = visaMain.Remark,
  15258. }
  15259. });
  15260. }
  15261. }
  15262. catch (Exception ex)
  15263. {
  15264. //写入日志
  15265. _logger.LogError(ex, "团组成本解析签证异常!");
  15266. }
  15267. }
  15268. }
  15269. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  15270. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  15271. #region 屏蔽黑屏代码生成
  15272. //var create = _GroupCostRepository.
  15273. // CreateGroupCostByBlackCode(dto.Diid);
  15274. //if (groupCost.Count == 0 && create.Code == 0)
  15275. //{
  15276. // groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  15277. //}
  15278. #endregion
  15279. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  15280. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  15281. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  15282. groupCostMap = groupCostMap.Select(x =>
  15283. {
  15284. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  15285. {
  15286. x.Date = dataForamt.ToString("yyyy-MM-dd");
  15287. }
  15288. return x;
  15289. }).ToList();
  15290. //GroupCostParameter.Add(new
  15291. // Grp_GroupCostParameter());
  15292. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  15293. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == diid && x.IsDel == 0).Count() > 0;
  15294. var groupModuleOperators = GeneralMethod.GetGroupModuleOperators(diid);
  15295. return Ok(JsonView(new
  15296. {
  15297. groupList,
  15298. groupInfo,
  15299. groupChecks,
  15300. groupCost = groupCostMap,
  15301. hotelNumber,
  15302. GroupCostParameter = GroupCostParameterMap,
  15303. visaCountryInfoArr = visaCountryInfoArr,
  15304. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  15305. blackCodeIsTrue = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).Any(), //create.Code == 0 ? true : false,
  15306. hotelIsTrue,
  15307. groupModuleOperators
  15308. }));
  15309. }
  15310. /// <summary>
  15311. /// 团组成本信息保存
  15312. /// </summary>
  15313. /// <param name="dto"></param>
  15314. /// <returns></returns>
  15315. [HttpPost]
  15316. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  15317. {
  15318. if (dto.Diid <= 0 || dto.Userid <= 0)
  15319. {
  15320. return Ok(JsonView(false));
  15321. }
  15322. JsonView jw = null;
  15323. bool isTrue = false;
  15324. #region 复制团组成本
  15325. //if (dto.Diid == 2581)
  15326. //{
  15327. // dto.Diid = 2599;
  15328. // dto.CheckBoxs.ForEach(x =>
  15329. // {
  15330. // x.Diid = 2599;
  15331. // });
  15332. // dto.GroupCosts.ForEach(x =>
  15333. // {
  15334. // x.Diid = 2599;
  15335. // });
  15336. // dto.CostTypeHotelNumbers.ForEach(x =>
  15337. // {
  15338. // x.Diid = 2599;
  15339. // });
  15340. // dto.GroupCostParameters.ForEach(x =>
  15341. // {
  15342. // x.DiId = 2599;
  15343. // });
  15344. //}
  15345. #endregion
  15346. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  15347. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  15348. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  15349. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  15350. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  15351. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  15352. try
  15353. {
  15354. _sqlSugar.BeginTran();
  15355. isTrue = await _GroupCostRepository.
  15356. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  15357. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  15358. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  15359. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  15360. _sqlSugar.CommitTran();
  15361. jw = JsonView(true, "保存成功!", isTrue);
  15362. }
  15363. catch (Exception)
  15364. {
  15365. _sqlSugar.RollbackTran();
  15366. jw = JsonView(false);
  15367. }
  15368. return Ok(jw);
  15369. }
  15370. /// <summary>
  15371. /// 复制团组成本信息
  15372. /// </summary>
  15373. /// <param name="dto"></param>
  15374. /// <returns></returns>
  15375. [HttpPost]
  15376. public async Task<IActionResult> CopyGroupCost(CopyGroupCostDto dto)
  15377. {
  15378. if (dto.Diid <= 0 || dto.Userid <= 0 || dto.ToGroupId <= 0)
  15379. {
  15380. return Ok(JsonView(false, "参数有误!"));
  15381. }
  15382. #region 复制团组成本
  15383. dto.Diid = dto.ToGroupId;
  15384. dto.CheckBoxs.ForEach(x =>
  15385. {
  15386. x.Diid = dto.ToGroupId;
  15387. });
  15388. dto.GroupCosts.ForEach(x =>
  15389. {
  15390. x.Diid = dto.ToGroupId;
  15391. });
  15392. dto.CostTypeHotelNumbers.ForEach(x =>
  15393. {
  15394. x.Diid = dto.ToGroupId;
  15395. });
  15396. dto.GroupCostParameters.ForEach(x =>
  15397. {
  15398. x.DiId = dto.ToGroupId;
  15399. });
  15400. #endregion
  15401. JsonView jw = null;
  15402. bool isTrue = false;
  15403. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  15404. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  15405. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  15406. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  15407. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  15408. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  15409. try
  15410. {
  15411. _sqlSugar.BeginTran();
  15412. isTrue = await _GroupCostRepository.
  15413. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  15414. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  15415. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  15416. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  15417. _sqlSugar.CommitTran();
  15418. jw = JsonView(true, "保存成功!", isTrue);
  15419. }
  15420. catch (Exception)
  15421. {
  15422. _sqlSugar.RollbackTran();
  15423. jw = JsonView(false);
  15424. }
  15425. return Ok(jw);
  15426. }
  15427. /// <summary>
  15428. /// 司兼导数据
  15429. /// </summary>
  15430. /// <param name="dto"></param>
  15431. /// <returns></returns>
  15432. [HttpPost]
  15433. public IActionResult GetCarGuides(CarGuidesDto dto)
  15434. {
  15435. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  15436. return Ok(JsonView(true, "获取成功!", Data));
  15437. }
  15438. /// <summary>
  15439. /// 导游数据
  15440. /// </summary>
  15441. /// <param name="dto"></param>
  15442. /// <returns></returns>
  15443. [HttpPost]
  15444. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  15445. {
  15446. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  15447. // 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
  15448. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  15449. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  15450. return Ok(JsonView(true, "获取成功!", Data));
  15451. }
  15452. /// <summary>
  15453. /// 成本车数据
  15454. /// </summary>
  15455. /// <param name="dto"></param>
  15456. /// <returns></returns>
  15457. [HttpPost]
  15458. public IActionResult GetCarInfo(CarGuidesDto dto)
  15459. {
  15460. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  15461. return Ok(JsonView(true, "获取成功!", Data));
  15462. }
  15463. /// <summary>
  15464. /// 景点数据
  15465. /// </summary>
  15466. /// <param name="dto"></param>
  15467. /// <returns></returns>
  15468. [HttpPost]
  15469. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  15470. {
  15471. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  15472. return Ok(JsonView(true, "获取成功!", Data));
  15473. }
  15474. /// <summary>
  15475. /// 成本通知
  15476. /// </summary>
  15477. /// <param name="dto"></param>
  15478. /// <returns></returns>
  15479. [HttpPost]
  15480. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  15481. {
  15482. if (dto.Diid < 0)
  15483. {
  15484. return Ok(JsonView(false));
  15485. }
  15486. JsonView jw;
  15487. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  15488. if (GroupCostParameter != null)
  15489. {
  15490. int IsShare = 0;
  15491. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  15492. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  15493. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  15494. string msg = string.Empty;
  15495. if (isTrue)
  15496. {
  15497. if (IsShare == 0)
  15498. {
  15499. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  15500. }
  15501. else
  15502. {
  15503. #region 企微通知对应岗位用户
  15504. try
  15505. {
  15506. await AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  15507. }
  15508. catch (Exception)
  15509. {
  15510. }
  15511. #endregion
  15512. msg = "通知成功,其他模块操作人员可见此成本信息!";
  15513. }
  15514. jw = JsonView(isTrue, msg, new { IsShare });
  15515. }
  15516. else
  15517. {
  15518. msg = "修改失败!";
  15519. jw = JsonView(isTrue, msg);
  15520. }
  15521. }
  15522. else
  15523. {
  15524. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  15525. }
  15526. return Ok(jw);
  15527. }
  15528. /// <summary>
  15529. /// 导出报价单
  15530. /// </summary>
  15531. /// <param name="dto"></param>
  15532. /// <returns></returns>
  15533. [HttpPost]
  15534. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  15535. {
  15536. if (dto.Diid == 0)
  15537. {
  15538. return Ok(JsonView(false, "请传递团组id"));
  15539. }
  15540. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  15541. if (deleInfo.Code != 0)
  15542. {
  15543. return Ok(JsonView(false, "团组信息查询失败!"));
  15544. }
  15545. var di = deleInfo.Data as DelegationInfoWebView;
  15546. if (di != null)
  15547. {
  15548. di.TeamName = di.TeamName.Replace("|", "、");
  15549. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  15550. //文件名
  15551. string strFileName = di.TeamName + "-收款账单.doc";
  15552. //获取模板
  15553. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  15554. //载入模板
  15555. Document doc = new Document(tmppath);
  15556. decimal TotalPrice = 0.00M;
  15557. string itemStr = string.Empty;
  15558. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  15559. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  15560. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  15561. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  15562. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  15563. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  15564. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  15565. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  15566. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  15567. foreach (var cost in groupCostType)
  15568. {
  15569. var List = cost.ToList();
  15570. if (cost.Key == "A")
  15571. {
  15572. foreach (var ListItem in List)
  15573. {
  15574. if (ListItem.number > 0)
  15575. {
  15576. if (ListItem.code.Contains("TBR"))
  15577. {
  15578. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  15579. }
  15580. else
  15581. {
  15582. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  15583. }
  15584. TotalPrice += (ListItem.number * ListItem.price);
  15585. }
  15586. }
  15587. }
  15588. else
  15589. {
  15590. itemStr = itemStr.Insert(0, "A段\r\n");
  15591. itemStr += "B段\r\n";
  15592. foreach (var ListItem in List)
  15593. {
  15594. if (ListItem.number > 0)
  15595. {
  15596. if (ListItem.code.Contains("TBR"))
  15597. {
  15598. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  15599. }
  15600. else
  15601. {
  15602. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  15603. }
  15604. TotalPrice += (ListItem.number * ListItem.price);
  15605. }
  15606. }
  15607. }
  15608. }
  15609. #region 替换Word模板书签内容
  15610. Dictionary<string, string> marks = new Dictionary<string, string>();
  15611. marks.Add("To", di.ClientUnit);//付款方
  15612. marks.Add("ToTel", di.TellPhone);//付款方电话
  15613. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  15614. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  15615. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  15616. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  15617. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  15618. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  15619. marks.Add("PayItemContent", itemStr);//详细信息
  15620. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  15621. #endregion
  15622. ////注
  15623. //if (doc.Range.Bookmarks["Attention"] != null)
  15624. //{
  15625. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  15626. // mark.Text = frList[0].Attention;
  15627. //}
  15628. foreach (var item in marks.Keys)
  15629. {
  15630. if (doc.Range.Bookmarks[item] != null)
  15631. {
  15632. Bookmark mark = doc.Range.Bookmarks[item];
  15633. mark.Text = marks[item];
  15634. }
  15635. }
  15636. byte[] bytes = null;
  15637. using (MemoryStream stream = new MemoryStream())
  15638. {
  15639. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  15640. bytes = stream.ToArray();
  15641. }
  15642. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  15643. return Ok(JsonView(true, "", new
  15644. {
  15645. Data = bytes,
  15646. strFileName,
  15647. }));
  15648. }
  15649. else
  15650. {
  15651. return Ok(JsonView(false, "团组信息不存在!"));
  15652. }
  15653. }
  15654. /// <summary>
  15655. /// 导出团组成本
  15656. /// </summary>
  15657. /// <param name="dto"></param>
  15658. /// <returns></returns>
  15659. [HttpPost]
  15660. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  15661. {
  15662. var jw = JsonView(false);
  15663. if (dto.Diid == 0)
  15664. {
  15665. return Ok(JsonView(false, "请传递团组id"));
  15666. }
  15667. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  15668. if (deleInfo.Code != 0)
  15669. {
  15670. return Ok(JsonView(false, "团组信息查询失败!"));
  15671. }
  15672. var di = deleInfo.Data as DelegationInfoWebView;
  15673. if (di == null)
  15674. {
  15675. return Ok(JsonView(false, "团组信息查询失败!"));
  15676. }
  15677. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  15678. WorkbookDesigner designer = new WorkbookDesigner();
  15679. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  15680. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  15681. List<int> hideColumnList = new List<int>();
  15682. var ColumnSetting = new[]
  15683. {
  15684. new { tag = "VF", Index = 4, P = "CarCost" },
  15685. new { tag = "VN", Index = 5, P = "CarNumber" },
  15686. new { tag = "VRD", Index = 6, P = "CarTiming" },
  15687. new { tag = "T/G S", Index = 7, P = "TGS" },
  15688. new { tag = "TGWH", Index = 8, P = "TGWH" },
  15689. new { tag = "T/G OF", Index = 9, P = "TGOF" },
  15690. new { tag = "T/G M", Index = 10, P = "TGM" },
  15691. new { tag = "T/G A", Index = 11, P = "TGA" },
  15692. new { tag = "T/G TF", Index = 12, P = "TGTF" },
  15693. new { tag = "T/G EF", Index = 13, P = "TGEF" },
  15694. new { tag = "C/F S", Index = 14, P = "CFS" },
  15695. new { tag = "C/F M", Index = 15, P = "CFM" },
  15696. new { tag = "C/F OF", Index = 16, P = "CFOF" },
  15697. new { tag = "B", Index = 17, P = "B" },
  15698. new { tag = "L", Index = 18, P = "L" },
  15699. new { tag = "D", Index = 19, P = "D" },
  15700. new { tag = "TBR", Index = 20, P = "TBR" },
  15701. new { tag = "SGR", Index = 21, P = "SGR" },
  15702. new { tag = "JS/ES", Index = 22, P = "JS_ES" },
  15703. new { tag = "Suite", Index = 23, P = "Suite" },
  15704. new { tag = "ACCO N", Index = 24, P = "ACCON" },
  15705. new { tag = "T/V", Index = 25, P = "TV" },
  15706. new { tag = "1/L", Index = 26, P = "iL" },
  15707. new { tag = "I/F", Index = 27, P = "IF" },
  15708. new { tag = "EF", Index = 28, P = "EF" },
  15709. new { tag = "B/R/F", Index = 29, P = "B_R_F" },
  15710. new { tag = "TE", Index = 30, P = "TE" },
  15711. new { tag = "T/G T", Index = 31, P = "TGTips" },
  15712. new { tag = "DRV T", Index = 32, P = "DRVTips" },
  15713. new { tag = "P/C", Index = 33, P = "PC" },
  15714. new { tag = "T/L F", Index = 34, P = "TLF" },
  15715. new { tag = "E/C T", Index = 35, P = "ECT" }
  15716. };
  15717. Func<string, bool> isEmpty = (str) =>
  15718. {
  15719. if (decimal.TryParse(str, out decimal str_De) && str_De == 0)
  15720. {
  15721. return true;
  15722. }
  15723. if (string.IsNullOrWhiteSpace(str))
  15724. {
  15725. return true;
  15726. }
  15727. return false;
  15728. };
  15729. for (int i = 0; i < List_GC.Count; i++)
  15730. {
  15731. GroupCost_Excel gc = new GroupCost_Excel();
  15732. gc.Id = List_GC[i].Id;
  15733. gc.Diid = List_GC[i].Diid.ToString();
  15734. gc.DAY = List_GC[i].DAY;
  15735. string week = "";
  15736. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  15737. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  15738. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  15739. gc.ITIN = List_GC[i].ITIN;
  15740. gc.CarType = List_GC[i].CarType;
  15741. gc.CarTiming = isEmpty(List_GC[i].CarTiming.ToString()) ? "" : List_GC[i].CarTiming.ToString();
  15742. gc.CarCost = isEmpty(List_GC[i].CarCost.ToString()) ? "" : List_GC[i].CarCost.ToString();
  15743. gc.CarNumber = isEmpty(List_GC[i].CarNumber.ToString()) ? "" : List_GC[i].CarNumber.ToString();
  15744. gc.TGS = isEmpty(List_GC[i].TGS.ToString()) ? "" : List_GC[i].TGS.ToString();
  15745. gc.TGWH = isEmpty(List_GC[i].TGWH.ToString()) ? "" : List_GC[i].TGWH.ToString();
  15746. gc.TGN = isEmpty(List_GC[i].TGN.ToString()) ? "" : List_GC[i].TGN.ToString();
  15747. gc.TGOF = isEmpty(List_GC[i].TGOF.ToString()) ? "" : List_GC[i].TGOF.ToString();
  15748. gc.TGM = isEmpty(List_GC[i].TGM.ToString()) ? "" : List_GC[i].TGM.ToString();
  15749. gc.TGA = isEmpty(List_GC[i].TGA.ToString()) ? "" : List_GC[i].TGA.ToString();
  15750. gc.TGTF = isEmpty(List_GC[i].TGTF.ToString()) ? "" : List_GC[i].TGTF.ToString();
  15751. gc.TGEF = isEmpty(List_GC[i].TGEF.ToString()) ? "" : List_GC[i].TGEF.ToString();
  15752. gc.CFS = isEmpty(List_GC[i].CFS.ToString()) ? "" : List_GC[i].CFS.ToString();
  15753. gc.CFM = isEmpty(List_GC[i].CFM.ToString()) ? "" : List_GC[i].CFM.ToString();
  15754. gc.CFOF = isEmpty(List_GC[i].CFOF.ToString()) ? "" : List_GC[i].CFOF.ToString();
  15755. gc.B = isEmpty(List_GC[i].B.ToString()) ? "" : List_GC[i].B.ToString();
  15756. gc.L = isEmpty(List_GC[i].L.ToString()) ? "" : List_GC[i].L.ToString();
  15757. gc.D = isEmpty(List_GC[i].D.ToString()) ? "" : List_GC[i].D.ToString();
  15758. gc.TBR = isEmpty(List_GC[i].TBR.ToString()) ? "" : List_GC[i].TBR.ToString();
  15759. gc.SGR = isEmpty(List_GC[i].SGR.ToString()) ? "" : List_GC[i].SGR.ToString();
  15760. gc.JS_ES = isEmpty(List_GC[i].JS_ES.ToString()) ? "" : List_GC[i].JS_ES.ToString();
  15761. gc.Suite = isEmpty(List_GC[i].Suite.ToString()) ? "" : List_GC[i].Suite.ToString();
  15762. gc.ACCON = isEmpty(List_GC[i].ACCON.ToString()) ? "" : List_GC[i].ACCON.ToString();
  15763. gc.TV = isEmpty(List_GC[i].TV.ToString()) ? "" : List_GC[i].TV.ToString();
  15764. gc.iL = isEmpty(List_GC[i].iL.ToString()) ? "" : List_GC[i].iL.ToString();
  15765. gc.IF = isEmpty(List_GC[i].IF.ToString()) ? "" : List_GC[i].IF.ToString();
  15766. gc.EF = isEmpty(List_GC[i].EF.ToString()) ? "" : List_GC[i].EF.ToString();
  15767. gc.B_R_F = isEmpty(List_GC[i].B_R_F.ToString()) ? "" : List_GC[i].B_R_F.ToString();
  15768. gc.TE = isEmpty(List_GC[i].TE.ToString()) ? "" : List_GC[i].TE.ToString();
  15769. gc.TGTips = isEmpty(List_GC[i].TGTips.ToString()) ? "" : List_GC[i].TGTips.ToString();
  15770. gc.DRVTips = isEmpty(List_GC[i].DRVTips.ToString()) ? "" : List_GC[i].DRVTips.ToString();
  15771. gc.PC = isEmpty(List_GC[i].PC.ToString()) ? "" : List_GC[i].PC.ToString();
  15772. gc.TLF = isEmpty(List_GC[i].TLF.ToString()) ? "" : List_GC[i].TLF.ToString();
  15773. gc.ECT = isEmpty(List_GC[i].ECT.ToString()) ? "" : List_GC[i].ECT.ToString();
  15774. gc.EFR = List_GC[i].EFR;
  15775. List_GC1.Add(gc);
  15776. }
  15777. if (List_GC1.Count > 0)
  15778. {
  15779. var p = List_GC1[0];
  15780. var prs = p.GetType().GetProperties();
  15781. foreach (var item in prs)
  15782. {
  15783. var tp = item.PropertyType;
  15784. if (tp == typeof(int))
  15785. {
  15786. var val = List_GC1.Sum(x => (int)x.GetType().GetProperty(item.Name).GetValue(x));
  15787. if (val == 0)
  15788. {
  15789. var columnSetting = ColumnSetting.FirstOrDefault(x => x.P == item.Name);
  15790. if (columnSetting != null)
  15791. {
  15792. hideColumnList.Add(columnSetting.Index);
  15793. }
  15794. }
  15795. }
  15796. if (tp == typeof(decimal))
  15797. {
  15798. var val = List_GC1.Sum(x => (decimal)x.GetType().GetProperty(item.Name).GetValue(x));
  15799. if (val == 0)
  15800. {
  15801. var columnSetting = ColumnSetting.FirstOrDefault(x => x.P == item.Name);
  15802. if (columnSetting != null)
  15803. {
  15804. hideColumnList.Add(columnSetting.Index);
  15805. }
  15806. }
  15807. }
  15808. if (tp == typeof(string))
  15809. {
  15810. var val = List_GC1.Sum(x =>
  15811. {
  15812. var str = (string)x.GetType().GetProperty(item.Name).GetValue(x);
  15813. if (decimal.TryParse(str, out decimal str_De))
  15814. {
  15815. return str_De;
  15816. }
  15817. else
  15818. {
  15819. return string.IsNullOrEmpty((string)x.GetType().GetProperty(item.Name).GetValue(x)) ? 0 : 1;
  15820. }
  15821. });
  15822. if (val == 0)
  15823. {
  15824. var columnSetting = ColumnSetting.FirstOrDefault(x => x.P == item.Name);
  15825. if (columnSetting != null)
  15826. {
  15827. hideColumnList.Add(columnSetting.Index);
  15828. }
  15829. }
  15830. }
  15831. }
  15832. }
  15833. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  15834. dt.TableName = "TB";
  15835. //报表标题等不用dt的值
  15836. designer.SetDataSource("TeamName", dto.title.TeamName);
  15837. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  15838. designer.SetDataSource("Tax", dto.title.Tax);
  15839. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  15840. designer.SetDataSource("Currency", dto.title.Currency);
  15841. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  15842. designer.SetDataSource("Rate", dto.title.Rate);
  15843. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  15844. var Aparams = hotels.Find(x => x.Type == "Default");
  15845. if (Aparams == null)
  15846. {
  15847. return Ok(jw);
  15848. }
  15849. //酒店数量
  15850. var txtSGRNumber = Aparams.SGR.ToString();
  15851. var txtTBRNumber = Aparams.TBR.ToString();
  15852. var txtJSESNumber = Aparams.JSES.ToString();
  15853. var txtSUITENumbe = Aparams.SUITE.ToString();
  15854. if (dto.costType == "B")
  15855. {
  15856. Aparams = hotels.Find(x => x.Type == "A");
  15857. var Bparams = hotels.Find(x => x.Type == "B");
  15858. if (Aparams == null || Bparams == null)
  15859. {
  15860. return Ok(jw);
  15861. }
  15862. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  15863. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  15864. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  15865. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  15866. }
  15867. designer.SetDataSource("SGRNumber", txtSGRNumber);
  15868. designer.SetDataSource("TBRNumber", txtTBRNumber);
  15869. designer.SetDataSource("JSESNumber", txtJSESNumber);
  15870. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  15871. var ws = designer.Workbook.Worksheets[1];
  15872. int Row = List_GC.Count;
  15873. int startIndex = 0;
  15874. int HideRows = 0;
  15875. Row = 0;
  15876. List<int> hideRowsList = new List<int>();
  15877. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  15878. #region A段left数据
  15879. var left = dto.leftInfo.Find(x => x.Type == "A");
  15880. if (left == null)
  15881. {
  15882. return Ok(jw);
  15883. }
  15884. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  15885. if (leftBindData != null)
  15886. {
  15887. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  15888. designer.SetDataSource("VisaRS", leftBindData.rs);
  15889. designer.SetDataSource("VisaXS", leftBindData.xs);
  15890. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15891. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15892. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15893. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15894. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15895. }
  15896. else
  15897. {
  15898. hideRowsList.Add(Row + startIndex + HideRows);
  15899. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15900. }
  15901. HideRows += 2;
  15902. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  15903. if (leftBindData != null)
  15904. {
  15905. designer.SetDataSource("BXDRCB", leftBindData.cb);
  15906. designer.SetDataSource("BXRS", leftBindData.rs);
  15907. designer.SetDataSource("BXXS", leftBindData.xs);
  15908. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15909. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15910. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15911. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15912. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15913. }
  15914. else
  15915. {
  15916. hideRowsList.Add(Row + startIndex + HideRows);
  15917. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15918. }
  15919. HideRows += 2;
  15920. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  15921. if (leftBindData != null)
  15922. {
  15923. designer.SetDataSource("HSDRCB", leftBindData.cb);
  15924. designer.SetDataSource("HSRS", leftBindData.rs);
  15925. designer.SetDataSource("HSXS", leftBindData.xs);
  15926. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15927. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15928. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15929. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15930. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15931. }
  15932. else
  15933. {
  15934. hideRowsList.Add(Row + startIndex + HideRows);
  15935. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15936. }
  15937. HideRows += 2;
  15938. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  15939. if (leftBindData != null)
  15940. {
  15941. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  15942. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  15943. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  15944. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15945. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15946. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15947. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15948. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15949. }
  15950. else
  15951. {
  15952. hideRowsList.Add(Row + startIndex + HideRows);
  15953. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15954. }
  15955. HideRows += 2;
  15956. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  15957. if (leftBindData != null)
  15958. {
  15959. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  15960. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  15961. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  15962. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15963. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15964. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15965. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15966. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15967. }
  15968. else
  15969. {
  15970. hideRowsList.Add(Row + startIndex + HideRows);
  15971. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15972. }
  15973. HideRows += 2;
  15974. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  15975. if (leftBindData != null)
  15976. {
  15977. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  15978. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  15979. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  15980. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15981. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15982. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15983. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15984. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15985. }
  15986. else
  15987. {
  15988. hideRowsList.Add(Row + startIndex + HideRows);
  15989. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15990. }
  15991. HideRows += 2;
  15992. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  15993. if (leftBindData != null)
  15994. {
  15995. ////TBR
  15996. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  15997. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  15998. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  15999. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16000. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16001. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16002. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16003. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16004. }
  16005. else
  16006. {
  16007. hideRowsList.Add(Row + startIndex + HideRows);
  16008. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  16009. }
  16010. HideRows += 2;
  16011. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  16012. if (leftBindData != null)
  16013. {
  16014. ////SGR
  16015. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  16016. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  16017. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  16018. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16019. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16020. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16021. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16022. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16023. }
  16024. else
  16025. {
  16026. hideRowsList.Add(Row + startIndex + HideRows);
  16027. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  16028. }
  16029. HideRows += 2;
  16030. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  16031. if (leftBindData != null)
  16032. {
  16033. ////JS/ES
  16034. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  16035. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  16036. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  16037. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16038. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16039. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16040. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16041. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16042. }
  16043. else
  16044. {
  16045. hideRowsList.Add(Row + startIndex + HideRows);
  16046. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  16047. }
  16048. HideRows += 2;
  16049. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  16050. if (leftBindData != null)
  16051. {
  16052. ////SUITE
  16053. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  16054. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  16055. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  16056. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16057. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16058. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16059. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16060. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16061. }
  16062. else
  16063. {
  16064. hideRowsList.Add(Row + startIndex + HideRows);
  16065. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  16066. }
  16067. HideRows += 2;
  16068. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  16069. if (leftBindData != null)
  16070. {
  16071. designer.SetDataSource("DJDRCB", leftBindData.cb);
  16072. designer.SetDataSource("DJRS", leftBindData.rs);
  16073. designer.SetDataSource("DJXS", leftBindData.xs);
  16074. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16075. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16076. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16077. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16078. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16079. }
  16080. else
  16081. {
  16082. hideRowsList.Add(Row + startIndex + HideRows);
  16083. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  16084. }
  16085. HideRows += 2;
  16086. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  16087. if (leftBindData != null)
  16088. {
  16089. designer.SetDataSource("HCPCB", leftBindData.cb);
  16090. designer.SetDataSource("HCPRS", leftBindData.rs);
  16091. designer.SetDataSource("HCPXS", leftBindData.xs);
  16092. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16093. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16094. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16095. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16096. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16097. }
  16098. else
  16099. {
  16100. hideRowsList.Add(Row + startIndex + HideRows);
  16101. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  16102. }
  16103. HideRows += 2;
  16104. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  16105. if (leftBindData != null)
  16106. {
  16107. designer.SetDataSource("CPCB", leftBindData.cb);
  16108. designer.SetDataSource("CPRS", leftBindData.rs);
  16109. designer.SetDataSource("CPXS", leftBindData.xs);
  16110. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16111. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16112. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16113. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16114. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16115. }
  16116. else
  16117. {
  16118. hideRowsList.Add(Row + startIndex + HideRows);
  16119. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  16120. }
  16121. HideRows += 2;
  16122. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  16123. if (leftBindData != null)
  16124. {
  16125. designer.SetDataSource("GWDRCD", leftBindData.cb);
  16126. designer.SetDataSource("GWRS", leftBindData.rs);
  16127. designer.SetDataSource("GWXS", leftBindData.xs);
  16128. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16129. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16130. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16131. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16132. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16133. }
  16134. else
  16135. {
  16136. hideRowsList.Add(Row + startIndex + HideRows);
  16137. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  16138. }
  16139. HideRows += 2;
  16140. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  16141. if (leftBindData != null)
  16142. {
  16143. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  16144. designer.SetDataSource("LYJRS", leftBindData.rs);
  16145. designer.SetDataSource("LYJXS", leftBindData.xs);
  16146. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16147. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16148. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16149. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16150. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16151. }
  16152. else
  16153. {
  16154. hideRowsList.Add(Row + startIndex + HideRows);
  16155. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  16156. }
  16157. #endregion
  16158. #region A段Right信息
  16159. var right = dto.rightInfo.Find(x => x.Type == "A");
  16160. if (right == null)
  16161. {
  16162. return Ok(jw);
  16163. }
  16164. HideRows += 4;
  16165. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  16166. if (rightBindData != null)
  16167. {
  16168. //经济舱 + 双人间 TBR
  16169. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  16170. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  16171. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16172. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  16173. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16174. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16175. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16176. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16177. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16178. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16179. }
  16180. else
  16181. {
  16182. hideRowsList.Add(Row + startIndex + HideRows);
  16183. }
  16184. HideRows += 2;
  16185. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  16186. if (rightBindData != null)
  16187. {
  16188. //经济舱 + 单人间 SGR
  16189. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  16190. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  16191. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16192. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  16193. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16194. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16195. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16196. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16197. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16198. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16199. }
  16200. else
  16201. {
  16202. hideRowsList.Add(Row + startIndex + HideRows);
  16203. }
  16204. HideRows += 2;
  16205. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  16206. if (rightBindData != null)
  16207. {
  16208. //公务舱 + 单人间 SGR
  16209. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  16210. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  16211. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16212. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  16213. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16214. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16215. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16216. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16217. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16218. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16219. }
  16220. else
  16221. {
  16222. hideRowsList.Add(Row + startIndex + HideRows);
  16223. }
  16224. HideRows += 2;
  16225. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  16226. if (rightBindData != null)
  16227. {
  16228. //公务舱 + 小套房 JSES
  16229. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  16230. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  16231. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16232. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  16233. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16234. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16235. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16236. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16237. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16238. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16239. }
  16240. else
  16241. {
  16242. hideRowsList.Add(Row + startIndex + HideRows);
  16243. }
  16244. HideRows += 2;
  16245. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  16246. if (rightBindData != null)
  16247. {
  16248. //公务舱 + 小套房 JSES
  16249. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  16250. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  16251. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16252. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  16253. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16254. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16255. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16256. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16257. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16258. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16259. }
  16260. else
  16261. {
  16262. hideRowsList.Add(Row + startIndex + HideRows);
  16263. }
  16264. HideRows += 2;
  16265. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  16266. if (rightBindData != null)
  16267. {
  16268. //经济舱 + 大套房
  16269. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  16270. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  16271. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16272. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  16273. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16274. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16275. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16276. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16277. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16278. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16279. }
  16280. else
  16281. {
  16282. hideRowsList.Add(Row + startIndex + HideRows);
  16283. }
  16284. HideRows += 2;
  16285. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  16286. if (rightBindData != null)
  16287. {
  16288. //头等舱 + 小套房 JSES
  16289. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  16290. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  16291. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16292. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  16293. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16294. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16295. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16296. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16297. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16298. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16299. }
  16300. else
  16301. {
  16302. hideRowsList.Add(Row + startIndex + HideRows);
  16303. }
  16304. HideRows += 2;
  16305. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  16306. if (rightBindData != null)
  16307. {
  16308. //头等舱 + 大套房
  16309. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  16310. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  16311. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16312. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  16313. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16314. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16315. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16316. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16317. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16318. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16319. }
  16320. else
  16321. {
  16322. hideRowsList.Add(Row + startIndex + HideRows);
  16323. }
  16324. #endregion
  16325. #region B段标题清空
  16326. designer.SetDataSource("CostBDRCB", "");
  16327. designer.SetDataSource("CostBRS", "");
  16328. designer.SetDataSource("CostBXS", "");
  16329. designer.SetDataSource("CostBZCB", "");
  16330. designer.SetDataSource("CostBDRBJ", "");
  16331. designer.SetDataSource("CostBZBJ", "");
  16332. designer.SetDataSource("CostBDRLR", "");
  16333. designer.SetDataSource("CostBZLR", "");
  16334. designer.SetDataSource("CostBDRCBOM", "");
  16335. designer.SetDataSource("CostBRSOM", "");
  16336. designer.SetDataSource("CostBZCBOM", "");
  16337. designer.SetDataSource("CostBDRBJOM", "");
  16338. designer.SetDataSource("CostBZBJOM", "");
  16339. designer.SetDataSource("CostBDRLROM", "");
  16340. designer.SetDataSource("CostBZLROM", "");
  16341. #endregion
  16342. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  16343. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  16344. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  16345. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  16346. designer.SetDataSource("DJName", "地接(CNY)");
  16347. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  16348. designer.SetDataSource("CPName", "地接-船票(CNY)");
  16349. designer.SetDataSource("GWName", "公务(CNY)");
  16350. designer.SetDataSource("YQHName", "邀请函(CNY)");
  16351. designer.SetDataSource("LYJName", "零用金(CNY)");
  16352. designer.SetDataSource("HSName", "核酸检测(CNY)");
  16353. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  16354. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  16355. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  16356. designer.SetDataSource("BXName", "保险(CNY)");
  16357. designer.SetDataSource("VisaName", "签证(CNY)");
  16358. #region B段基本数据
  16359. if (dto.costType == "B")
  16360. {
  16361. left = dto.leftInfo.Find(x => x.Type == "B");
  16362. if (left == null)
  16363. {
  16364. return Ok(jw);
  16365. }
  16366. #region B段left数据
  16367. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  16368. if (leftBindData != null)
  16369. {
  16370. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  16371. designer.SetDataSource("BHSRS", leftBindData.rs);
  16372. designer.SetDataSource("BHSXS", leftBindData.xs);
  16373. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16374. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16375. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16376. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16377. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16378. }
  16379. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  16380. if (leftBindData != null)
  16381. {
  16382. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  16383. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  16384. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  16385. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16386. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16387. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16388. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16389. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16390. }
  16391. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  16392. if (leftBindData != null)
  16393. {
  16394. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  16395. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  16396. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  16397. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16398. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16399. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16400. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16401. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16402. }
  16403. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  16404. if (leftBindData != null)
  16405. {
  16406. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  16407. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  16408. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  16409. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16410. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16411. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16412. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16413. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16414. }
  16415. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  16416. if (leftBindData != null)
  16417. {
  16418. designer.SetDataSource("BHCPCB", leftBindData.cb);
  16419. designer.SetDataSource("BHCPRS", leftBindData.rs);
  16420. designer.SetDataSource("BHCPXS", leftBindData.xs);
  16421. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16422. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16423. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16424. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16425. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16426. }
  16427. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  16428. if (leftBindData != null)
  16429. {
  16430. designer.SetDataSource("BCPCB", leftBindData.cb);
  16431. designer.SetDataSource("BCPRS", leftBindData.rs);
  16432. designer.SetDataSource("BCPXS", leftBindData.xs);
  16433. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16434. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16435. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16436. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16437. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16438. }
  16439. //TBR
  16440. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  16441. if (leftBindData != null)
  16442. {
  16443. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  16444. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  16445. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  16446. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16447. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16448. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16449. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16450. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16451. }
  16452. //SGR
  16453. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  16454. if (leftBindData != null)
  16455. {
  16456. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  16457. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  16458. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  16459. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16460. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16461. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16462. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16463. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16464. }
  16465. //JS/ES
  16466. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  16467. if (leftBindData != null)
  16468. {
  16469. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  16470. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  16471. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  16472. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16473. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16474. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16475. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16476. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16477. }
  16478. //SUITE
  16479. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  16480. if (leftBindData != null)
  16481. {
  16482. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  16483. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  16484. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  16485. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16486. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16487. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16488. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16489. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16490. }
  16491. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  16492. if (leftBindData != null)
  16493. {
  16494. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  16495. designer.SetDataSource("BDJRS", leftBindData.rs);
  16496. designer.SetDataSource("BDJXS", leftBindData.xs);
  16497. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16498. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16499. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16500. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16501. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16502. }
  16503. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  16504. if (leftBindData != null)
  16505. {
  16506. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  16507. designer.SetDataSource("BGWRS", leftBindData.rs);
  16508. designer.SetDataSource("BGWXS", leftBindData.xs);
  16509. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16510. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16511. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16512. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16513. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16514. }
  16515. #region 优化方案
  16516. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  16517. //excelBind.Add("零用金", new {
  16518. //cb="",
  16519. //rs="",
  16520. //xs ="",
  16521. //zcb = "",
  16522. //});
  16523. #endregion
  16524. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  16525. if (leftBindData != null)
  16526. {
  16527. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  16528. designer.SetDataSource("BLYJRS", leftBindData.rs);
  16529. designer.SetDataSource("BLYJXS", leftBindData.xs);
  16530. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16531. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16532. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16533. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16534. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16535. }
  16536. #endregion
  16537. #region B段Right信息
  16538. right = dto.rightInfo.Find(x => x.Type == "B");
  16539. if (right == null)
  16540. {
  16541. return Ok(jw);
  16542. }
  16543. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  16544. if (rightBindData != null)
  16545. {
  16546. //经济舱 + 双人间 TBR
  16547. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  16548. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  16549. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16550. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  16551. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16552. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16553. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16554. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16555. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16556. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16557. }
  16558. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  16559. if (rightBindData != null)
  16560. {
  16561. //经济舱 + 单人间 SGR
  16562. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  16563. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  16564. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16565. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  16566. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16567. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16568. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16569. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16570. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16571. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16572. }
  16573. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  16574. if (rightBindData != null)
  16575. {
  16576. //公务舱 + 单人间 SGR
  16577. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  16578. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  16579. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16580. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  16581. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16582. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16583. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16584. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16585. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16586. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16587. }
  16588. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  16589. if (rightBindData != null)
  16590. {
  16591. //公务舱 + 小套房 JSES
  16592. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  16593. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  16594. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16595. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  16596. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16597. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16598. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16599. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16600. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16601. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16602. }
  16603. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  16604. if (rightBindData != null)
  16605. {
  16606. //公务舱 + 小套房 JSES
  16607. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  16608. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  16609. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16610. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  16611. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16612. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16613. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16614. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16615. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16616. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16617. }
  16618. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  16619. if (rightBindData != null)
  16620. {
  16621. //经济舱 + 大套房
  16622. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  16623. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  16624. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16625. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  16626. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16627. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16628. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16629. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16630. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16631. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16632. }
  16633. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  16634. if (rightBindData != null)
  16635. {
  16636. //头等舱 + 小套房 JSES
  16637. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  16638. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  16639. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16640. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  16641. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16642. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16643. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16644. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16645. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16646. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16647. }
  16648. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  16649. if (rightBindData != null)
  16650. {
  16651. //头等舱 + 大套房
  16652. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  16653. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  16654. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16655. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  16656. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16657. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16658. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16659. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16660. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16661. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16662. }
  16663. #endregion
  16664. #region 标题
  16665. designer.SetDataSource("CostBDRCB", "单人成本");
  16666. designer.SetDataSource("CostBRS", "人数");
  16667. designer.SetDataSource("CostBXS", "系数");
  16668. designer.SetDataSource("CostBZCB", "总成本");
  16669. designer.SetDataSource("CostBDRBJ", "单人报价");
  16670. designer.SetDataSource("CostBZBJ", "总报价");
  16671. designer.SetDataSource("CostBDRLR", "单人利润");
  16672. designer.SetDataSource("CostBZLR", "总利润");
  16673. designer.SetDataSource("CostBDRCBOM", "单人成本");
  16674. designer.SetDataSource("CostBRSOM", "人数");
  16675. designer.SetDataSource("CostBZCBOM", "总成本");
  16676. designer.SetDataSource("CostBDRBJOM", "单人报价");
  16677. designer.SetDataSource("CostBZBJOM", "总报价");
  16678. designer.SetDataSource("CostBDRLROM", "单人利润");
  16679. designer.SetDataSource("CostBZLROM", "总利润");
  16680. #endregion
  16681. }
  16682. #endregion
  16683. designer.SetDataSource("TzZCB2", TzZCB2);
  16684. designer.SetDataSource("TzZBJ2", TzZBJ2);
  16685. designer.SetDataSource("TzZLR2", TzZLR2);
  16686. string[] dataSourceKeys = new string[]
  16687. {
  16688. "VF",
  16689. "TGS",
  16690. "TGOF",
  16691. "TGM",
  16692. "TGA",
  16693. "TGTF",
  16694. "TGEF",
  16695. "CFM",
  16696. "CFOF",
  16697. "B",
  16698. "L",
  16699. "D",
  16700. "TBR",
  16701. "SGR",
  16702. "JSES",
  16703. "Suite",
  16704. "TV",
  16705. "1L",
  16706. "IF",
  16707. "EF",
  16708. "BRF",
  16709. "TE",
  16710. "TGT",
  16711. "DRVT",
  16712. "PC",
  16713. "TLF",
  16714. "ECT"
  16715. };
  16716. foreach (var item in dataSourceKeys)
  16717. {
  16718. Func<TitleModel, bool> expr = x => x.label.Replace(" ", "").Replace("/", "") == item
  16719. || x.label.Replace(" ", "").Replace("/", "").ToUpper() == item.ToUpper();
  16720. var find = dto.titleModel.FirstOrDefault(expr);
  16721. if (find != null)
  16722. {
  16723. designer.SetDataSource(item, find.text);
  16724. }
  16725. else
  16726. {
  16727. designer.SetDataSource(item, 0);
  16728. }
  16729. }
  16730. designer.SetDataSource(dt);
  16731. //根据数据源处理生成报表内容
  16732. designer.Process();
  16733. designer.Workbook.Worksheets[0].Name = "费用明细";
  16734. designer.Workbook.Worksheets[1].Name = "费用总核算";
  16735. Worksheet sheet = designer.Workbook.Worksheets[0];
  16736. #region 隐藏舱位
  16737. var settingAir = new[]
  16738. {
  16739. new { key = "经济舱", index = 7 },
  16740. new { key = "公务舱", index = 19 },
  16741. new { key = "头等舱", index = 11 }
  16742. };
  16743. var airType = _sqlSugar.Queryable<Grp_TourClientList>()
  16744. .LeftJoin<Sys_SetData>((c, s) => s.IsDel == 0 && c.ShippingSpaceTypeId == s.Id)
  16745. .Where((c, s) => c.IsDel == 0 && c.DiId == di.Id)
  16746. .Select((c, s) => s.Name)
  16747. .ToList()
  16748. .GroupBy(x => x)
  16749. .Select(x => x.Key);
  16750. foreach (var item in settingAir)
  16751. {
  16752. if (!airType.Contains(item.key))
  16753. {
  16754. hideRowsList.Add(item.index);
  16755. }
  16756. }
  16757. #endregion
  16758. foreach (var Rowindex in hideRowsList)
  16759. {
  16760. ws.Cells.HideRows(Rowindex, 2);
  16761. }
  16762. ws = designer.Workbook.Worksheets[0];
  16763. foreach (var Column in hideColumnList)
  16764. {
  16765. ws.Cells.HideColumns(Column, 1);
  16766. }
  16767. byte[] bytes = null;
  16768. string strFileName = di.TeamName + "-团组-成本.xls";
  16769. using (MemoryStream stream = new MemoryStream())
  16770. {
  16771. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  16772. bytes = stream.ToArray();
  16773. }
  16774. return Ok(JsonView(true, "", new
  16775. {
  16776. Data = bytes,
  16777. strFileName,
  16778. }));
  16779. }
  16780. /// <summary>
  16781. /// 导出客户报表
  16782. /// </summary>
  16783. /// <returns></returns>
  16784. [HttpPost]
  16785. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  16786. {
  16787. var jw = JsonView(false);
  16788. if (dto.Diid == 0)
  16789. {
  16790. return Ok(JsonView(false, "请传递团组id"));
  16791. }
  16792. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  16793. if (deleInfo.Code != 0)
  16794. {
  16795. return Ok(JsonView(false, "团组信息查询失败!"));
  16796. }
  16797. var di = deleInfo.Data as DelegationInfoWebView;
  16798. if (di == null)
  16799. {
  16800. return Ok(JsonView(false, "团组信息查询失败!"));
  16801. }
  16802. //文件名
  16803. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  16804. //获取模板
  16805. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  16806. //载入模板
  16807. Document doc = new Document(tmppath);
  16808. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  16809. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  16810. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  16811. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  16812. var AParameter = ParameterList.Find(x => x.CostType == "A");
  16813. var BParameter = ParameterList.Find(x => x.CostType == "B");
  16814. if (AParameter == null)
  16815. {
  16816. return Ok(JsonView(false, "系数不存在!"));
  16817. }
  16818. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  16819. , TzAirDesc, TzZCost;
  16820. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  16821. = TzAirDesc = TzZCost = string.Empty;
  16822. TzNumber = AParameter.CostTypenumber.ToString();
  16823. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  16824. CarGuides1 = dto.CarGuides1;
  16825. Meal = dto.Meal;
  16826. SubsidizedMeals = dto.SubsidizedMeals;
  16827. NightRepair = dto.NightRepair;
  16828. AttractionsTickets = dto.AttractionsTickets;
  16829. MiscellaneousFees = dto.MiscellaneousFees;
  16830. ATip = dto.ATip;
  16831. TzHotelDesc = "";
  16832. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  16833. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  16834. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  16835. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  16836. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  16837. TzAirDesc = "";
  16838. TzZCost = dto.TzZCost;
  16839. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  16840. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  16841. var index = 1;
  16842. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  16843. foreach (var item in TzHotelDescArr)
  16844. {
  16845. if (AinfoArr != null)
  16846. {
  16847. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  16848. if (Ainfo != null)
  16849. {
  16850. if (int.Parse(Ainfo.rs) <= 0)
  16851. {
  16852. continue;
  16853. }
  16854. var hotelText = string.Empty;
  16855. switch (item)
  16856. {
  16857. case "SGR":
  16858. hotelText = "单人间";
  16859. break;
  16860. case "JSES":
  16861. hotelText = "小套房";
  16862. break;
  16863. case "SUITE":
  16864. hotelText = "套房";
  16865. break;
  16866. case "TBR":
  16867. hotelText = "双人间";
  16868. break;
  16869. }
  16870. if (item != "TBR")
  16871. {
  16872. 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";
  16873. }
  16874. else
  16875. {
  16876. 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";
  16877. }
  16878. index++;
  16879. }
  16880. }
  16881. }
  16882. index = 1;
  16883. foreach (var item in TzAirDescArr)
  16884. {
  16885. if (AinfoArr != null)
  16886. {
  16887. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  16888. if (Ainfo != null)
  16889. {
  16890. if (int.Parse(Ainfo.rs) <= 0)
  16891. {
  16892. continue;
  16893. }
  16894. 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";
  16895. index++;
  16896. }
  16897. }
  16898. }
  16899. if (dto.costType == "B")
  16900. {
  16901. if (BParameter == null)
  16902. {
  16903. return Ok(JsonView(false, "B段系数不存在!"));
  16904. }
  16905. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  16906. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  16907. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  16908. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  16909. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  16910. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  16911. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  16912. foreach (var item in TzHotelDescArr)
  16913. {
  16914. if (AinfoArr != null)
  16915. {
  16916. TzHotelDesc += "B段信息 \r\n";
  16917. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  16918. if (Ainfo != null)
  16919. {
  16920. if (int.Parse(Ainfo.rs) <= 0)
  16921. {
  16922. continue;
  16923. }
  16924. var hotelText = string.Empty;
  16925. switch (item)
  16926. {
  16927. case "SGR":
  16928. hotelText = "单人间";
  16929. break;
  16930. case "JSES":
  16931. hotelText = "小套房";
  16932. break;
  16933. case "SUITE":
  16934. hotelText = "套房";
  16935. break;
  16936. case "TBR":
  16937. hotelText = "双人间";
  16938. break;
  16939. }
  16940. if (item != "TBR")
  16941. {
  16942. 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";
  16943. }
  16944. else
  16945. {
  16946. 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";
  16947. }
  16948. index++;
  16949. }
  16950. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  16951. }
  16952. }
  16953. index = 1;
  16954. foreach (var item in TzAirDescArr)
  16955. {
  16956. if (AinfoArr != null)
  16957. {
  16958. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  16959. if (Ainfo != null)
  16960. {
  16961. if (int.Parse(Ainfo.rs) <= 0)
  16962. {
  16963. continue;
  16964. }
  16965. 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";
  16966. index++;
  16967. }
  16968. }
  16969. }
  16970. }
  16971. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  16972. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  16973. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  16974. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  16975. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  16976. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  16977. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  16978. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  16979. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  16980. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  16981. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  16982. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  16983. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  16984. DickeyValue.Add("Visa", Visa); // 签证单人报价
  16985. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  16986. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  16987. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  16988. DickeyValue.Add("TzZCost", TzZCost);
  16989. foreach (var key in DickeyValue.Keys)
  16990. {
  16991. if (doc.Range.Bookmarks[key] != null)
  16992. {
  16993. Bookmark mark = doc.Range.Bookmarks[key];
  16994. mark.Text = DickeyValue[key];
  16995. }
  16996. }
  16997. byte[] bytes = null;
  16998. string strFileName = di.TeamName + "-客户报价.doc";
  16999. using (MemoryStream stream = new MemoryStream())
  17000. {
  17001. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  17002. bytes = stream.ToArray();
  17003. }
  17004. return Ok(JsonView(true, "", new
  17005. {
  17006. Data = bytes,
  17007. strFileName,
  17008. }));
  17009. }
  17010. /// <summary>
  17011. /// 团组成本 各模块(酒店,地接,机票)成本提示
  17012. /// </summary>
  17013. /// <param name="dto"></param>
  17014. /// <returns></returns>
  17015. [HttpPost]
  17016. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17017. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  17018. {
  17019. try
  17020. {
  17021. #region 参数验证
  17022. if (dto.DiId < 0)
  17023. {
  17024. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  17025. }
  17026. List<int> cTableIds = new List<int>() {
  17027. 76 ,//酒店预订
  17028. 77 ,//行程
  17029. 79 ,//车/导游地接
  17030. 80 ,//签证
  17031. 81 ,//邀请/公务活
  17032. 82 ,//团组客户保险
  17033. 85 ,//机票预订
  17034. 98 ,//其他款项
  17035. 285 ,//收款退还
  17036. 751 ,//酒店早餐
  17037. 1015 // 超支费用
  17038. };
  17039. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  17040. {
  17041. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  17042. }
  17043. #endregion
  17044. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  17045. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  17046. if (_GroupCostParameters.Count <= 0)
  17047. {
  17048. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  17049. }
  17050. if (_GroupCostParameters[0].IsShare == 0)
  17051. {
  17052. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  17053. }
  17054. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  17055. //处理date为空问题
  17056. if (_GroupCosts.Count > 0)
  17057. {
  17058. for (int i = 0; i < _GroupCosts.Count; i++)
  17059. {
  17060. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  17061. {
  17062. if (i > 0)
  17063. {
  17064. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  17065. }
  17066. }
  17067. }
  17068. }
  17069. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  17070. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  17071. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  17072. string currCode = "";
  17073. #region currCode 验证
  17074. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  17075. if (isInt)
  17076. {
  17077. var currData = currDatas.Find(it => it.Id == intCurrency);
  17078. if (currData != null)
  17079. {
  17080. currCode = currData.Name;
  17081. }
  17082. }
  17083. else
  17084. {
  17085. currCode = _GroupCostParameters[0].Currency.Trim();
  17086. }
  17087. #endregion
  17088. //op,酒店单段模式存储
  17089. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  17090. {
  17091. CurrencyCode = currCode,
  17092. Rate = _GroupCostParameters[0].Rate,
  17093. CostType = _GroupCostParameters[0].CostType,
  17094. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  17095. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  17096. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  17097. };
  17098. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  17099. if (_GroupCostParameters.Count == 2)
  17100. {
  17101. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  17102. }
  17103. foreach (var item in _GroupCostParameters)
  17104. {
  17105. decimal _rate = 1;
  17106. decimal _rate1 = item.Rate;
  17107. decimal _scale = 1;
  17108. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  17109. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  17110. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  17111. //if (userInfo != null)
  17112. //{
  17113. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  17114. // {
  17115. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  17116. // {
  17117. // _scale = 1.00M;
  17118. // }
  17119. // }
  17120. //}
  17121. #endregion
  17122. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  17123. {
  17124. CurrencyCode = currCode,
  17125. Rate = _rate1,
  17126. CostType = item.CostType,
  17127. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  17128. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  17129. CostTypeNumber = item.CostTypenumber
  17130. };
  17131. if (_GroupCostParameters.Count > 1)
  17132. {
  17133. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  17134. }
  17135. else
  17136. {
  17137. modulePromptInfo.CostTypeNumber = item.LYJRS;
  17138. }
  17139. if (dto.CTable == 79)//
  17140. {
  17141. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  17142. modulePromptInfo.TotalCost = item.DJCB;
  17143. }
  17144. List<string> costTypes = new List<string>() { "A", "B" };
  17145. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  17146. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  17147. if (_GroupCostsDuplicates.Count() == 1)
  17148. {
  17149. _GroupCostsTypeData = _GroupCosts;
  17150. }
  17151. else
  17152. {
  17153. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  17154. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  17155. }
  17156. /*
  17157. * 76 酒店预订
  17158. * 77 行程
  17159. * 79 车/导游地接
  17160. * 80 签证
  17161. * 81 邀请/公务活动
  17162. * 82 团组客户保险
  17163. * 85 机票预订
  17164. * 98 其他款项
  17165. * 285 收款退还
  17166. * 751 酒店早餐
  17167. * 1015 超支费用
  17168. */
  17169. switch (dto.CTable)
  17170. {
  17171. case 76: // 酒店预订
  17172. _ModuleSubPromptInfo.AddRange(
  17173. _GroupCostsTypeData.Select(it => new
  17174. {
  17175. it.DAY,
  17176. it.Date,
  17177. it.ACCON,
  17178. it.ITIN,
  17179. it.SGR,
  17180. it.TBR,
  17181. it.JS_ES,
  17182. it.Suite
  17183. })
  17184. );
  17185. break;
  17186. case 79: // 车/导游地接
  17187. _ModuleSubPromptInfo.AddRange(
  17188. _GroupCostsTypeData.Select(it => new
  17189. {
  17190. Date = it.Date, //日期
  17191. CarFee = it.CarCost * _rate * _scale, //车费用
  17192. CarType = it.CarType, //车型
  17193. DriverFee = it.CFS * _rate * _scale, //司机工资
  17194. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  17195. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  17196. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  17197. GuideFee = it.TGS * _rate * _scale, //导游费用
  17198. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  17199. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  17200. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  17201. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  17202. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  17203. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  17204. Breakfast = it.B * _rate * _scale, //早餐费
  17205. Lunch = it.L * _rate * _scale, //午餐费
  17206. Dinner = it.D * _rate * _scale, //晚餐费
  17207. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  17208. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  17209. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  17210. TicketFee = it.EF * _rate * _scale, //门票费
  17211. TicketRemark = it.EFR, //门票费描述
  17212. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  17213. TravelSupplies = it.TE * _rate * _scale, //出行物资
  17214. SpentCash = it.PC * _rate * _scale, //零用金
  17215. LeadersFee = it.TLF * _rate * _scale, //领队费
  17216. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  17217. })
  17218. );
  17219. break;
  17220. case 85: // 机票
  17221. List<dynamic> datas = new List<dynamic>();
  17222. datas.Add(
  17223. new
  17224. {
  17225. AirType = "经济舱",
  17226. AirNum = item.JJCRS,
  17227. AirDRCB = item.JJCCB,
  17228. AirZCB = (item.JJCRS * item.JJCCB)
  17229. }
  17230. );
  17231. datas.Add(
  17232. new
  17233. {
  17234. AirType = "公务舱",
  17235. AirNum = item.GWCRS,
  17236. AirDRCB = item.GWCCB,
  17237. AirZCB = (item.GWCRS * item.GWCCB)
  17238. }
  17239. );
  17240. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  17241. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  17242. modulePromptInfo.Data = new
  17243. {
  17244. airFeeData = datas,
  17245. airInitData = initDatas
  17246. };
  17247. _ModulePromptInfos.Add(modulePromptInfo);
  17248. break;
  17249. default:
  17250. break;
  17251. }
  17252. }
  17253. if (dto.CTable != 85)
  17254. {
  17255. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  17256. _ModulePromptInfos.Add(_ModulePromptInfo);
  17257. }
  17258. _view.ModulePromptInfos = _ModulePromptInfos;
  17259. return Ok(JsonView(true, "操作成功!", _view));
  17260. }
  17261. catch (Exception ex)
  17262. {
  17263. return Ok(JsonView(false, ex.Message));
  17264. }
  17265. }
  17266. /// <summary>
  17267. /// 根据黑屏代码重新生成行程
  17268. /// </summary>
  17269. /// <param name="dto"></param>
  17270. /// <returns></returns>
  17271. [HttpPost]
  17272. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  17273. {
  17274. var jw = JsonView(false, "Error");
  17275. var Create = _sqlSugar.Queryable<Air_TicketBlackCode>()
  17276. .Where(x => x.IsDel == 0 && x.DiId == dto.Diid)
  17277. .Select(x => new
  17278. {
  17279. x.Id,
  17280. x.Title
  17281. })
  17282. .ToList();
  17283. if (Create.Any())
  17284. {
  17285. jw.Msg = "获取成功!";
  17286. jw.Code = 200;
  17287. jw.Data = new
  17288. {
  17289. BlackCodeListSelect = Create,
  17290. blackCodeIsTrue = true
  17291. };
  17292. }
  17293. else
  17294. {
  17295. jw.Code = 400;
  17296. jw.Data = new
  17297. {
  17298. BlackCodeListSelect = Create,
  17299. blackCodeIsTrue = false,
  17300. };
  17301. }
  17302. return Ok(jw);
  17303. }
  17304. /// <summary>
  17305. /// 根据黑屏代码Id重新生成行程
  17306. /// </summary>
  17307. /// <param name="dto"></param>
  17308. /// <returns></returns>
  17309. [HttpPost]
  17310. public IActionResult CraeteGroupCostTravelById(CraeteGroupCostTravelByIdDto dto)
  17311. {
  17312. var jw = JsonView(false, "Error");
  17313. var result = _GroupCostRepository.CreateGroupCostByBlackCode(dto.DiId, dto.BlackCodeId);
  17314. if (result.Code == 0)
  17315. {
  17316. jw.Msg = "获取成功!";
  17317. jw.Code = 200;
  17318. jw.Data = new
  17319. {
  17320. groupCost = result.Data,
  17321. blackCodeIsTrue = true
  17322. };
  17323. }
  17324. else
  17325. {
  17326. jw.Code = 400;
  17327. jw.Data = new
  17328. {
  17329. groupCost = result.Data,
  17330. blackCodeIsTrue = false,
  17331. };
  17332. }
  17333. return Ok(jw);
  17334. }
  17335. /// <summary>
  17336. /// 成本获取OP历史车费用
  17337. /// </summary>
  17338. /// <param name="dto"></param>
  17339. /// <returns></returns>
  17340. [HttpPost]
  17341. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  17342. {
  17343. var jw = JsonView(false);
  17344. try
  17345. {
  17346. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  17347. //获取现有所有车的数据
  17348. if (!dto.Param.IsNullOrWhiteSpace())
  17349. {
  17350. string sql = $@"
  17351. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  17352. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  17353. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  17354. 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
  17355. AND gctggr.ServiceEndTime is not NULL
  17356. ORDER by gctggrc.id DESC
  17357. ";
  17358. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  17359. var numeberResult = await Task.Run(() =>
  17360. {
  17361. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  17362. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  17363. return numberArr;
  17364. });
  17365. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  17366. foreach (var item in numeberResult)
  17367. {
  17368. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  17369. {
  17370. Country = "数据异常!",
  17371. City = string.Empty,
  17372. };
  17373. item.Area = find.Country + " " + find.City;
  17374. }
  17375. dbResult.AddRange(numeberResult);
  17376. if (dto.Param.Contains("、"))
  17377. {
  17378. var sp = dto.Param.Split("、");
  17379. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  17380. .Where(x =>
  17381. {
  17382. return System.Array.Exists(sp, e =>
  17383. {
  17384. bool where = false;
  17385. if (x.Area != null)
  17386. {
  17387. where = x.Area.Contains(e);
  17388. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  17389. {
  17390. return false;
  17391. }
  17392. }
  17393. if (x.PriceName != null && !where)
  17394. {
  17395. where = x.PriceName.Contains(e);
  17396. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  17397. {
  17398. return false;
  17399. }
  17400. }
  17401. return where;
  17402. });
  17403. }).ToList();
  17404. }
  17405. else
  17406. {
  17407. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  17408. .Where(x =>
  17409. {
  17410. bool where = false;
  17411. if (x.Area != null)
  17412. {
  17413. where = x.Area.Contains(dto.Param);
  17414. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  17415. {
  17416. return false;
  17417. }
  17418. }
  17419. if (x.PriceName != null && !where)
  17420. {
  17421. where = x.PriceName.Contains(dto.Param);
  17422. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  17423. {
  17424. return false;
  17425. }
  17426. }
  17427. return where;
  17428. }
  17429. )
  17430. .ToList();
  17431. }
  17432. }
  17433. var view = dbResult.Select(x =>
  17434. {
  17435. decimal dp = 0.00M;
  17436. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  17437. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  17438. if (string.IsNullOrWhiteSpace(x.DatePrice))
  17439. {
  17440. if (startB && endB)
  17441. {
  17442. var timesp = endD.Subtract(startD);
  17443. if ((timesp.Days + 1) != 0)
  17444. {
  17445. dp = x.Price / (timesp.Days + 1);
  17446. }
  17447. }
  17448. }
  17449. else
  17450. {
  17451. dp = x.Price;
  17452. }
  17453. return new
  17454. {
  17455. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  17456. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  17457. x.Area,
  17458. x.id,
  17459. price = x.Price.ToString("F2"),
  17460. x.PriceName,
  17461. x.PriceContent,
  17462. x.TeamName,
  17463. x.DatePrice,
  17464. dayPrice = dp.ToString("F2"),
  17465. };
  17466. }).OrderByDescending(x => x.id).ToList();
  17467. jw = JsonView(true, "获取成功!", view);
  17468. }
  17469. catch (Exception e)
  17470. {
  17471. jw = JsonView(false, e.Message);
  17472. }
  17473. return Ok(jw);
  17474. }
  17475. [HttpPost]
  17476. public async Task<IActionResult> SearchGroupByKeyword(SearchGroupByKeywordDto dto)
  17477. {
  17478. var jw = JsonView(true);
  17479. List<DelegationInfoAndIsTrueView> matches = new List<DelegationInfoAndIsTrueView>();
  17480. #region SQL语句
  17481. //if (string.IsNullOrWhiteSpace(dto.Keyword))
  17482. //{
  17483. // matches = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  17484. // Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  17485. // WHEN COUNT(*) >= 0 THEN 'True'
  17486. // ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  17487. // Where TeamName != '' And IsDel = 0 Order By a.VisitStartDate Desc
  17488. // ")
  17489. // .ToList();
  17490. //}
  17491. //else
  17492. //{
  17493. // string likeKey = string.Empty;
  17494. // foreach (var item in dto.Keyword)
  17495. // {
  17496. // likeKey += "%" + item;
  17497. // }
  17498. // likeKey += "%";
  17499. // matches = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  17500. // Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  17501. // WHEN COUNT(*) >= 0 THEN 'True'
  17502. // ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  17503. // Where TeamName != '' And IsDel = 0 And TeamName LIKE '{likeKey}' Order By a.VisitStartDate Desc
  17504. // ")
  17505. // .ToList();
  17506. //}
  17507. #endregion
  17508. var table = _sqlSugar.Ado.UseStoredProcedure().GetDataTable("SearchGroupByKeyword", new
  17509. {
  17510. @KeyWord = dto.Keyword
  17511. });
  17512. if (table != null && table.Rows.Count > 0)
  17513. {
  17514. foreach (DataRow row in table.Rows)
  17515. {
  17516. matches.Add(new DelegationInfoAndIsTrueView
  17517. {
  17518. Id = row.Field<int>("Id"),
  17519. GroupName = row.Field<string>("GroupName"),
  17520. isTrue = row.Field<string>("isTrue")
  17521. });
  17522. }
  17523. }
  17524. if (matches.Any())
  17525. {
  17526. jw.Data = matches;
  17527. }
  17528. else
  17529. {
  17530. jw.Code = 201;
  17531. jw.Msg = "empty list";
  17532. jw.Data = new List<string>(1);
  17533. }
  17534. return Ok(jw);
  17535. }
  17536. /// <summary>
  17537. /// 报价Word下载
  17538. /// </summary>
  17539. /// <param name="dto"></param>
  17540. /// <returns></returns>
  17541. [HttpPost]
  17542. public async Task<IActionResult> GroupQuotationsFileDown(GroupQuotationsFileDownDto dto)
  17543. {
  17544. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  17545. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  17546. if (di == null)
  17547. {
  17548. return Ok(JsonView(false, "团组不存在!"));
  17549. }
  17550. var mainPrice = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  17551. if (mainPrice == null || mainPrice.IsShare == 0)
  17552. {
  17553. return Ok(JsonView(false, "团组成本不存在!"));
  17554. }
  17555. var costTypeHotelNumbers = await _sqlSugar.Queryable<Grp_CostTypeHotelNumber>()
  17556. .FirstAsync(x => x.Type == "Default" && x.Diid == dto.Diid && x.IsDel == 0);
  17557. if (costTypeHotelNumbers == null)
  17558. {
  17559. return Ok(JsonView(false, "团组成本不存在!"));
  17560. }
  17561. //文件名
  17562. string strFileName = di.TeamName + "-收款账单.doc";
  17563. //获取模板
  17564. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  17565. //载入模板
  17566. Document doc = new Document(tmppath);
  17567. decimal allPrice = 0.00M;
  17568. string itemStr = string.Empty;
  17569. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  17570. airSouer.Add("经济舱TBR", "经济舱及酒店双人间");
  17571. airSouer.Add("经济舱SGR", "经济舱及酒店单人间");
  17572. airSouer.Add("公务舱SGR", "公务舱及酒店单人间");
  17573. airSouer.Add("公务舱JSES", "公务舱及酒店小套房");
  17574. airSouer.Add("公务舱SUITE", "公务舱及酒店套房");
  17575. airSouer.Add("经济舱SUITE", "经济舱及酒店套房");
  17576. airSouer.Add("头等舱JSES", "头等舱及酒店小套房");
  17577. airSouer.Add("头等舱SUITE", "头等舱及酒店套房");
  17578. airSouer.Add("经济舱JSES", "经济舱及酒店小套房");
  17579. var priceDataList = new List<(string rsName, string cbName, string xsName, string prefix)>
  17580. {
  17581. ("VisaRS", "VisaCB", "VisaXS", "qz"),
  17582. ("BXRS", "BXCB", "BXXS", "bx"),
  17583. ("HCPRS", "HCPCB", "HCPXS", "hcp"),
  17584. ("JJCRS", "JJCCB", "JJCXS", "jjc"),
  17585. ("GWCRS", "GWCCB", "GWCXS", "gwc"),
  17586. ("TDCRS", "TDCCB", "TDCXS", "tdc"),
  17587. ("CPRS", "CPCB", "CPXS", "cp"),
  17588. ("HSRS", "HSCB", "HSXS", "hsjc"),
  17589. ("TBRNumber", "TBRCB", "TBRXS", "tbr"),
  17590. ("SGRNumber", "SGRCB", "SGRXS", "sgr"),
  17591. ("JSESNumber", "JSESCB", "JSESXS", "jses"),
  17592. ("SUITENumber", "SUITECB", "SUITEXS", "suite"),
  17593. ("DJRS", "DJCB", "DJXS", "dj"),
  17594. ("GWRS", "GWCB", "GWXS", "gw"),
  17595. ("LYJRS", "LYJCB", "LYJXS", "lyj"),
  17596. };
  17597. var OtherCostPropertyBJ = new string[] { "qz", "hcp", "cp", "bx", "hsjc", "dj", "gw", "lyj" };
  17598. var rightSum = 0.00M;
  17599. foreach (var (rsName, cbName, xsName, prefix) in priceDataList)
  17600. {
  17601. var rsValue = (int)mainPrice.GetType().GetProperty(rsName).GetValue(mainPrice);
  17602. var cbValue = (decimal)mainPrice.GetType().GetProperty(cbName).GetValue(mainPrice);
  17603. var xsValue = (decimal)mainPrice.GetType().GetProperty(xsName).GetValue(mainPrice);
  17604. if (prefix == "tbr")
  17605. {
  17606. rsValue *= 2;
  17607. cbValue /= 2;
  17608. }
  17609. if (OtherCostPropertyBJ.Contains(prefix))
  17610. {
  17611. rightSum += cbValue * xsValue;
  17612. }
  17613. }
  17614. var hotelRooms = new Dictionary<string, int>
  17615. {
  17616. { "SGR", costTypeHotelNumbers.SGR },
  17617. { "TBR", costTypeHotelNumbers.TBR },
  17618. { "JSES", costTypeHotelNumbers.JSES },
  17619. { "SUITE", costTypeHotelNumbers.SUITE }
  17620. };
  17621. var flights = new Dictionary<string, int>
  17622. {
  17623. { "经济舱", mainPrice.JJCRS },
  17624. { "公务舱", mainPrice.GWCRS },
  17625. { "头等舱", mainPrice.TDCRS }
  17626. };
  17627. var flightRoomMatchingRules = new Dictionary<string, string[]>
  17628. {
  17629. { "经济舱", new[] { "TBR", "SGR", "JSES", "SUITE" } },
  17630. { "公务舱", new[] { "SUITE", "JSES", "SGR" } },
  17631. { "头等舱", new[] { "SUITE", "JSES" } }
  17632. };
  17633. var result = new Dictionary<string, int>();
  17634. List<AirHotelPrice> airHotelPriceList = new List<AirHotelPrice>();
  17635. foreach (var flight in flights.Keys)
  17636. {
  17637. // 获取当前舱位的匹配规则
  17638. if (flightRoomMatchingRules.TryGetValue(flight, out string[] roomTypes))
  17639. {
  17640. MatchRooms(ref hotelRooms, ref flights, roomTypes, flight, ref result);
  17641. }
  17642. }
  17643. #region right计算
  17644. if (result.Keys.Contains("经济舱TBR") && result["经济舱TBR"] > 0)
  17645. {
  17646. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  17647. var hotel = (mainPrice.TBRCB * mainPrice.TBRXS) / 2;
  17648. airHotelPriceList.Add(new
  17649. AirHotelPrice
  17650. {
  17651. Name = "经济舱TBR",
  17652. Price = rightSum + air + hotel,
  17653. Count = result["经济舱TBR"] * 2
  17654. });
  17655. allPrice += (rightSum + air + hotel) * result["经济舱TBR"] * 2;
  17656. }
  17657. if (result.Keys.Contains("经济舱SGR") && result["经济舱SGR"] > 0)
  17658. {
  17659. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  17660. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  17661. airHotelPriceList.Add(new
  17662. AirHotelPrice
  17663. {
  17664. Name = "经济舱SGR",
  17665. Price = rightSum + air + hotel,
  17666. Count = result["经济舱SGR"]
  17667. });
  17668. allPrice += (rightSum + air + hotel) * result["经济舱SGR"];
  17669. }
  17670. if (result.Keys.Contains("公务舱SGR") && result["公务舱SGR"] > 0)
  17671. {
  17672. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  17673. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  17674. airHotelPriceList.Add(new
  17675. AirHotelPrice
  17676. {
  17677. Name = "公务舱SGR",
  17678. Price = rightSum + air + hotel,
  17679. Count = result["公务舱SGR"]
  17680. });
  17681. allPrice += (rightSum + air + hotel) * result["公务舱SGR"];
  17682. }
  17683. if (result.Keys.Contains("公务舱JSES") && result["公务舱JSES"] > 0)
  17684. {
  17685. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  17686. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  17687. airHotelPriceList.Add(new
  17688. AirHotelPrice
  17689. {
  17690. Name = "公务舱JSES",
  17691. Price = rightSum + air + hotel,
  17692. Count = result["公务舱JSES"]
  17693. });
  17694. allPrice += (rightSum + air + hotel) * result["公务舱JSES"];
  17695. }
  17696. if (result.Keys.Contains("公务舱SUITE") && result["公务舱SUITE"] > 0)
  17697. {
  17698. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  17699. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  17700. airHotelPriceList.Add(new
  17701. AirHotelPrice
  17702. {
  17703. Name = "公务舱SUITE",
  17704. Price = rightSum + air + hotel,
  17705. Count = result["公务舱SUITE"]
  17706. });
  17707. allPrice += (rightSum + air + hotel) * result["公务舱SUITE"];
  17708. }
  17709. if (result.Keys.Contains("经济舱SUITE") && result["经济舱SUITE"] > 0)
  17710. {
  17711. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  17712. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  17713. airHotelPriceList.Add(new
  17714. AirHotelPrice
  17715. {
  17716. Name = "经济舱SUITE",
  17717. Price = rightSum + air + hotel,
  17718. Count = result["经济舱SUITE"]
  17719. });
  17720. allPrice += (rightSum + air + hotel) * result["经济舱SUITE"];
  17721. }
  17722. if (result.Keys.Contains("头等舱JSES") && result["头等舱JSES"] > 0)
  17723. {
  17724. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  17725. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  17726. airHotelPriceList.Add(new
  17727. AirHotelPrice
  17728. {
  17729. Name = "头等舱JSES",
  17730. Price = rightSum + air + hotel,
  17731. Count = result["头等舱JSES"]
  17732. });
  17733. allPrice += (rightSum + air + hotel) * result["头等舱JSES"];
  17734. }
  17735. if (result.Keys.Contains("头等舱SUITE") && result["头等舱SUITE"] > 0)
  17736. {
  17737. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  17738. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  17739. airHotelPriceList.Add(new
  17740. AirHotelPrice
  17741. {
  17742. Name = "头等舱SUITE",
  17743. Price = rightSum + air + hotel,
  17744. Count = result["头等舱SUITE"]
  17745. });
  17746. allPrice += (rightSum + air + hotel) * result["头等舱SUITE"];
  17747. }
  17748. if (result.Keys.Contains("经济舱JSES") && result["经济舱JSES"] > 0)
  17749. {
  17750. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  17751. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  17752. airHotelPriceList.Add(new
  17753. AirHotelPrice
  17754. {
  17755. Name = "经济舱JSES",
  17756. Price = rightSum + air + hotel,
  17757. Count = result["经济舱JSES"]
  17758. });
  17759. allPrice += (rightSum + air + hotel) * result["经济舱JSES"];
  17760. }
  17761. #endregion
  17762. foreach (var item in airSouer.Keys)
  17763. {
  17764. var find = airHotelPriceList.FirstOrDefault(x => x.Name == item);
  17765. if (find != null && find.Count > 0)
  17766. {
  17767. if (item.Contains("TBR"))
  17768. {
  17769. itemStr += "团费(" + airSouer[item] + ") RMB " + find.Price.ToString("F2") + "/人*" + find.Count + "(" + (find.Count / 2) + "间) ............合计 RMB " + (find.Count * find.Price).ToString("#0.00") + "\n";
  17770. }
  17771. else
  17772. {
  17773. itemStr += "团费(" + airSouer[item] + ") RMB " + find.Price.ToString("F2") + "/人*" + find.Count + "(" + find.Count + "间) ............合计 RMB " + (find.Count * find.Price).ToString("#0.00") + "\n";
  17774. }
  17775. }
  17776. }
  17777. #region 替换Word模板书签内容
  17778. Dictionary<string, string> marks = new Dictionary<string, string>();
  17779. marks.Add("To", di.ClientUnit);//付款方
  17780. marks.Add("ToTel", di.TellPhone);//付款方电话
  17781. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  17782. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  17783. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  17784. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  17785. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  17786. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  17787. marks.Add("PayItemContent", itemStr);//详细信息
  17788. marks.Add("Total", allPrice.ToString("F2"));//合计
  17789. #endregion
  17790. foreach (var item in marks.Keys)
  17791. {
  17792. if (doc.Range.Bookmarks[item] != null)
  17793. {
  17794. Bookmark mark = doc.Range.Bookmarks[item];
  17795. mark.Text = marks[item];
  17796. }
  17797. }
  17798. string savePaht = $"{AppSettingsHelper.Get("WordBasePath")}GroupCostQuotations/{di.TeamName}_报批费用.doc";
  17799. doc.Save(savePaht);
  17800. var jw = new JsonView();
  17801. jw.Msg = "生成成功!";
  17802. jw.Code = 200;
  17803. jw.Data = new { Url = AppSettingsHelper.Get("WordBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("WordBasePath"), AppSettingsHelper.Get("WordFtpPath")) };
  17804. return Ok(jw);
  17805. }
  17806. /// <summary>
  17807. /// 详细报价费用Excel下载
  17808. /// </summary>
  17809. /// <param name="dto"></param>
  17810. /// <returns></returns>
  17811. [HttpPost]
  17812. public async Task<IActionResult> GroupQuotationsDetailFileDown(GroupQuotationsFileDownDto dto)
  17813. {
  17814. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  17815. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  17816. if (di == null)
  17817. {
  17818. return Ok(JsonView(false, "团组不存在!"));
  17819. }
  17820. var mainPrice = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  17821. if (mainPrice == null || mainPrice.IsShare == 0)
  17822. {
  17823. return Ok(JsonView(false, "团组成本不存在!"));
  17824. }
  17825. var costTypeHotelNumbers = await _sqlSugar.Queryable<Grp_CostTypeHotelNumber>()
  17826. .FirstAsync(x => x.Type == "Default" && x.Diid == dto.Diid && x.IsDel == 0);
  17827. if (costTypeHotelNumbers == null)
  17828. {
  17829. return Ok(JsonView(false, "团组成本不存在!"));
  17830. }
  17831. WorkbookDesigner designer = new WorkbookDesigner();
  17832. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/报价详细表.xls"));
  17833. List<int> hideRowsList = new List<int>();
  17834. int conterStartIndex = 3;
  17835. int rowIndex = conterStartIndex;
  17836. designer.SetDataSource("GroupName", di.TeamName);
  17837. var priceDataList = new List<(string rsName, string cbName, string xsName, string prefix)>
  17838. {
  17839. ("VisaRS", "VisaCB", "VisaXS", "qz"),
  17840. ("BXRS", "BXCB", "BXXS", "bx"),
  17841. ("HCPRS", "HCPCB", "HCPXS", "hcp"),
  17842. ("JJCRS", "JJCCB", "JJCXS", "jjc"),
  17843. ("GWCRS", "GWCCB", "GWCXS", "gwc") ,
  17844. ("TDCRS", "TDCCB", "TDCXS", "tdc") ,
  17845. ("CPRS", "CPCB", "CPXS", "cp") ,
  17846. ("HSRS", "HSCB", "HSXS", "hsjc") ,
  17847. ("TBRNumber", "TBRCB", "TBRXS", "tbr") ,
  17848. ("SGRNumber", "SGRCB", "SGRXS", "sgr") ,
  17849. ("JSESNumber", "JSESCB", "JSESXS", "jses") ,
  17850. ("SUITENumber", "SUITECB", "SUITEXS", "suite") ,
  17851. ("DJRS", "DJCB", "DJXS", "dj") ,
  17852. ("GWRS", "GWCB", "GWXS", "gw") ,
  17853. ("LYJRS", "LYJCB", "LYJXS", "lyj") ,
  17854. };
  17855. var OtherCostPropertyBJ = new string[] { "qz", "hcp", "cp", "bx", "hsjc", "dj", "gw", "lyj" };
  17856. var rightSum = 0.00M;
  17857. foreach (var (rsName, cbName, xsName, prefix) in priceDataList)
  17858. {
  17859. var rsValue = (int)mainPrice.GetType().GetProperty(rsName).GetValue(mainPrice);
  17860. var cbValue = (decimal)mainPrice.GetType().GetProperty(cbName).GetValue(mainPrice);
  17861. var xsValue = (decimal)mainPrice.GetType().GetProperty(xsName).GetValue(mainPrice);
  17862. if (prefix == "tbr")
  17863. {
  17864. rsValue *= 2;
  17865. cbValue /= 2;
  17866. }
  17867. if (OtherCostPropertyBJ.Contains(prefix))
  17868. {
  17869. rightSum += cbValue * xsValue;
  17870. }
  17871. if (rsValue == 0)
  17872. {
  17873. hideRowsList.Add(rowIndex);
  17874. }
  17875. else
  17876. {
  17877. designer.SetDataSource($"{prefix}rs", rsValue);
  17878. designer.SetDataSource($"{prefix}bj", cbValue * xsValue);
  17879. designer.SetDataSource($"{prefix}zbj", cbValue * xsValue * rsValue);
  17880. }
  17881. rowIndex += 2;
  17882. }
  17883. var hotelRooms = new Dictionary<string, int>
  17884. {
  17885. { "SGR", costTypeHotelNumbers.SGR },
  17886. { "TBR", costTypeHotelNumbers.TBR },
  17887. { "JSES", costTypeHotelNumbers.JSES },
  17888. { "SUITE", costTypeHotelNumbers.SUITE }
  17889. };
  17890. var flights = new Dictionary<string, int>
  17891. {
  17892. { "经济舱", mainPrice.JJCRS },
  17893. { "公务舱", mainPrice.GWCRS },
  17894. { "头等舱", mainPrice.TDCRS }
  17895. };
  17896. var flightRoomMatchingRules = new Dictionary<string, string[]>
  17897. {
  17898. { "经济舱", new[] { "TBR", "SGR", "JSES", "SUITE" } },
  17899. { "公务舱", new[] { "SUITE", "JSES", "SGR" } },
  17900. { "头等舱", new[] { "SUITE", "JSES" } }
  17901. };
  17902. var result = new Dictionary<string, int>();
  17903. foreach (var flight in flights.Keys)
  17904. {
  17905. // 获取当前舱位的匹配规则
  17906. if (flightRoomMatchingRules.TryGetValue(flight, out string[] roomTypes))
  17907. {
  17908. MatchRooms(ref hotelRooms, ref flights, roomTypes, flight, ref result);
  17909. }
  17910. }
  17911. var allPrice = 0.00M;
  17912. #region right计算
  17913. int airRowIndex = 35;
  17914. if (result.Keys.Contains("经济舱TBR") && result["经济舱TBR"] > 0)
  17915. {
  17916. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  17917. var hotel = (mainPrice.TBRCB * mainPrice.TBRXS) / 2;
  17918. designer.SetDataSource("jjctbrrs", result["经济舱TBR"] * 2);
  17919. designer.SetDataSource("jjctbrbj", rightSum + air + hotel);
  17920. designer.SetDataSource("jjctbrzbj", (rightSum + air + hotel) * result["经济舱TBR"] * 2);
  17921. allPrice += (rightSum + air + hotel) * result["经济舱TBR"] * 2;
  17922. }
  17923. else
  17924. {
  17925. hideRowsList.Add(airRowIndex);
  17926. }
  17927. airRowIndex += 2;
  17928. if (result.Keys.Contains("经济舱SGR") && result["经济舱SGR"] > 0)
  17929. {
  17930. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  17931. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  17932. designer.SetDataSource("jjcsgrrs", result["经济舱SGR"]);
  17933. designer.SetDataSource("jjcsgrbj", rightSum + air + hotel);
  17934. designer.SetDataSource("jjcsgrzbj", (rightSum + air + hotel) * result["经济舱SGR"]);
  17935. allPrice += (rightSum + air + hotel) * result["经济舱SGR"];
  17936. }
  17937. else
  17938. {
  17939. hideRowsList.Add(airRowIndex);
  17940. }
  17941. airRowIndex += 2;
  17942. if (result.Keys.Contains("公务舱SGR") && result["公务舱SGR"] > 0)
  17943. {
  17944. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  17945. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  17946. designer.SetDataSource("gwcsgrrs", result["公务舱SGR"]);
  17947. designer.SetDataSource("gwcsgrbj", rightSum + air + hotel);
  17948. designer.SetDataSource("gwcsgrzbj", (rightSum + air + hotel) * result["公务舱SGR"]);
  17949. allPrice += (rightSum + air + hotel) * result["公务舱SGR"];
  17950. }
  17951. else
  17952. {
  17953. hideRowsList.Add(airRowIndex);
  17954. }
  17955. airRowIndex += 2;
  17956. if (result.Keys.Contains("公务舱JSES") && result["公务舱JSES"] > 0)
  17957. {
  17958. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  17959. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  17960. designer.SetDataSource("gwcjsesrs", result["公务舱JSES"]);
  17961. designer.SetDataSource("gwcjsesbj", rightSum + air + hotel);
  17962. designer.SetDataSource("gwcjseszbj", (rightSum + air + hotel) * result["公务舱JSES"]);
  17963. allPrice += (rightSum + air + hotel) * result["公务舱JSES"];
  17964. }
  17965. else
  17966. {
  17967. hideRowsList.Add(airRowIndex);
  17968. }
  17969. airRowIndex += 2;
  17970. if (result.Keys.Contains("公务舱SUITE") && result["公务舱SUITE"] > 0)
  17971. {
  17972. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  17973. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  17974. designer.SetDataSource("gwcsuiters", result["公务舱SUITE"]);
  17975. designer.SetDataSource("gwcsuitebj", rightSum + air + hotel);
  17976. designer.SetDataSource("gwcsuitezbj", (rightSum + air + hotel) * result["公务舱SUITE"]);
  17977. allPrice += (rightSum + air + hotel) * result["公务舱SUITE"];
  17978. }
  17979. else
  17980. {
  17981. hideRowsList.Add(airRowIndex);
  17982. }
  17983. airRowIndex += 2;
  17984. if (result.Keys.Contains("经济舱SUITE") && result["经济舱SUITE"] > 0)
  17985. {
  17986. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  17987. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  17988. designer.SetDataSource("jjcsuiters", result["经济舱SUITE"]);
  17989. designer.SetDataSource("jjcsuitebj", rightSum + air + hotel);
  17990. designer.SetDataSource("jjcsuitezbj", (rightSum + air + hotel) * result["经济舱SUITE"]);
  17991. allPrice += (rightSum + air + hotel) * result["经济舱SUITE"];
  17992. }
  17993. else
  17994. {
  17995. hideRowsList.Add(airRowIndex);
  17996. }
  17997. airRowIndex += 2;
  17998. if (result.Keys.Contains("头等舱JSES") && result["头等舱JSES"] > 0)
  17999. {
  18000. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  18001. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  18002. designer.SetDataSource("tdcjsesrs", result["头等舱JSES"]);
  18003. designer.SetDataSource("tdcjsesbj", rightSum + air + hotel);
  18004. designer.SetDataSource("tdcjseszbj", (rightSum + air + hotel) * result["头等舱JSES"]);
  18005. allPrice += (rightSum + air + hotel) * result["头等舱JSES"];
  18006. }
  18007. else
  18008. {
  18009. hideRowsList.Add(airRowIndex);
  18010. }
  18011. airRowIndex += 2;
  18012. if (result.Keys.Contains("头等舱SUITE") && result["头等舱SUITE"] > 0)
  18013. {
  18014. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  18015. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  18016. designer.SetDataSource("tdcsuiters", result["头等舱SUITE"]);
  18017. designer.SetDataSource("tdcsuitebj", rightSum + air + hotel);
  18018. designer.SetDataSource("tdcsuitezbj", (rightSum + air + hotel) * result["头等舱SUITE"]);
  18019. allPrice += (rightSum + air + hotel) * result["头等舱SUITE"];
  18020. }
  18021. else
  18022. {
  18023. hideRowsList.Add(airRowIndex);
  18024. }
  18025. airRowIndex += 2;
  18026. if (result.Keys.Contains("经济舱JSES") && result["经济舱JSES"] > 0)
  18027. {
  18028. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  18029. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  18030. designer.SetDataSource("jjcjsesrs", result["经济舱JSES"]);
  18031. designer.SetDataSource("jjcjsesbj", rightSum + air + hotel);
  18032. designer.SetDataSource("jjcjseszbj", (rightSum + air + hotel) * result["经济舱JSES"]);
  18033. allPrice += (rightSum + air + hotel) * result["经济舱JSES"];
  18034. }
  18035. else
  18036. {
  18037. hideRowsList.Add(airRowIndex);
  18038. }
  18039. #endregion
  18040. designer.SetDataSource("AllPrice", "总金额:" + allPrice.ToString("#0.00"));
  18041. string savePaht = AppSettingsHelper.Get("ExcelBasePath") + "GroupCostQuotations/" + di.TeamName + "_详细报批费用.xls";
  18042. var ws = designer.Workbook.Worksheets[0];
  18043. foreach (var Rowindex in hideRowsList)
  18044. {
  18045. ws.Cells.HideRows(Rowindex, 2);
  18046. }
  18047. designer.Process();
  18048. designer.Workbook.Save(savePaht);
  18049. return Ok(JsonView(true, "生成成功!", new
  18050. {
  18051. Url = AppSettingsHelper.Get("ExcelBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("ExcelBasePath"), AppSettingsHelper.Get("ExcelFtpPath"))
  18052. }));
  18053. }
  18054. private void MatchRooms(ref Dictionary<string, int> hotelRooms, ref Dictionary<string, int> flights, string[] roomTypes, string flightType, ref Dictionary<string, int> result)
  18055. {
  18056. foreach (var roomType in roomTypes)
  18057. {
  18058. while (hotelRooms[roomType] > 0 && flights[flightType] > 0)
  18059. {
  18060. hotelRooms[roomType]--;
  18061. flights[flightType]--;
  18062. if (roomType == "TBR")
  18063. {
  18064. flights[flightType]--; // 双人间在减少1
  18065. }
  18066. string key = flightType + roomType;
  18067. if (result.Keys.Contains(key))
  18068. {
  18069. result[key]++;
  18070. }
  18071. else
  18072. {
  18073. result.Add(key, 1);
  18074. }
  18075. }
  18076. }
  18077. }
  18078. private class AirHotelPrice
  18079. {
  18080. public string Name { get; set; }
  18081. public decimal Price { get; set; }
  18082. public int Count { get; set; }
  18083. }
  18084. /// <summary>
  18085. /// 团组系数设置
  18086. /// </summary>
  18087. /// <param name="dto"></param>
  18088. /// <returns></returns>
  18089. [HttpPost]
  18090. public async Task<IActionResult> QueryGroupCostCoefficient(QueryGroupCostCoefficientDto dto)
  18091. {
  18092. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  18093. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  18094. if (di == null)
  18095. {
  18096. return Ok(JsonView(false, "团组不存在!"));
  18097. }
  18098. //var firstExpression = Expressionable.Create<Grp_GroupCostParameter>()
  18099. // .And(x => x.CostType == "A" && x.DiId == di.Id && x.IsDel == 0);
  18100. //var groupCostMainPrice = await _sqlSugar.Queryable<Grp_GroupCostParameter>().
  18101. // FirstAsync(firstExpression.ToExpression());
  18102. #region JSON
  18103. string hcpJson = @"
  18104. [
  18105. {
  18106. ""min"": 1,
  18107. ""max"": 500,
  18108. ""value"": 1.50
  18109. },
  18110. {
  18111. ""min"": 501,
  18112. ""max"": 1000,
  18113. ""value"": 1.40
  18114. },
  18115. {
  18116. ""min"": 1001,
  18117. ""max"": 2000,
  18118. ""value"": 1.35
  18119. }
  18120. ]";
  18121. #endregion
  18122. var hcpPriceRange = Newtonsoft.Json.JsonConvert.DeserializeObject<List<PriceRange>>(hcpJson);
  18123. List<(Predicate<decimal>, decimal)> hcpSwitchDictionary = hcpPriceRange
  18124. .Select(pr => (new Predicate<decimal>(x => x >= pr.Min && x <= pr.Max), pr.Value))
  18125. .ToList();
  18126. List<(Predicate<decimal>, List<(Predicate<decimal>, decimal)>)> jjcSwitchDictionary =
  18127. new List<(Predicate<decimal>, List<(Predicate<decimal>, decimal)>)>();
  18128. //jjcSwitchDictionary.Add((new Predicate<decimal>(x => x >= 1 && x <= 3),
  18129. // new List<(Predicate<decimal>, decimal)>()
  18130. // {
  18131. // (new Predicate<decimal>(y => y >= 1000 && y <= 3000), 2.6M),
  18132. // (new Predicate<decimal>(y => y > 3000), 2.5M)
  18133. // }
  18134. // ));
  18135. #region 签证系数
  18136. var visaXS = 0.00M;
  18137. switch (dto.VisaCB)
  18138. {
  18139. case decimal n when (n > 1 && n < 500):
  18140. switch (dto.VisaRS)
  18141. {
  18142. case 2 or 3:
  18143. visaXS = 1.35M;
  18144. break;
  18145. case 4 or 5:
  18146. visaXS = 1.30M;
  18147. break;
  18148. case 6 or 7:
  18149. visaXS = 1.25M;
  18150. break;
  18151. case 8 or 9 or 10:
  18152. visaXS = 1.20M;
  18153. break;
  18154. case > 10:
  18155. visaXS = 1.15M;
  18156. break;
  18157. default:
  18158. visaXS = 0.00M;
  18159. break;
  18160. }
  18161. break;
  18162. case decimal n when (n >= 500 && n < 1000):
  18163. switch (dto.VisaRS)
  18164. {
  18165. case 2 or 3 or 4:
  18166. visaXS = 1.30M;
  18167. break;
  18168. case 5 or 6 or 7 or 8:
  18169. visaXS = 1.25M;
  18170. break;
  18171. case 9 or 10:
  18172. visaXS = 1.20M;
  18173. break;
  18174. case > 10:
  18175. visaXS = 1.15M;
  18176. break;
  18177. default:
  18178. visaXS = 0.00M;
  18179. break;
  18180. }
  18181. break;
  18182. default:
  18183. switch (dto.VisaRS)
  18184. {
  18185. case 2 or 3 or 4:
  18186. visaXS = 1.30M;
  18187. break;
  18188. case 5 or 6 or 7 or 8:
  18189. visaXS = 1.25M;
  18190. break;
  18191. case 9 or 10:
  18192. visaXS = 1.20M;
  18193. break;
  18194. case > 10:
  18195. visaXS = 1.15M;
  18196. break;
  18197. default:
  18198. visaXS = 0.00M;
  18199. break;
  18200. }
  18201. break;
  18202. }
  18203. #endregion
  18204. #region 火车系数
  18205. var hcpXS = 0.00M;
  18206. foreach (var (condition, result) in hcpSwitchDictionary)
  18207. {
  18208. if (condition(dto.HCPCB))
  18209. {
  18210. hcpXS = result;
  18211. break;
  18212. }
  18213. }
  18214. #endregion
  18215. #region 机票系数
  18216. #region 经济舱系数
  18217. var jjcXS = 0.00M;
  18218. switch (dto.JJCCB)
  18219. {
  18220. case decimal x when (x >= 1000 && x <= 3000):
  18221. jjcXS = 2.6M;
  18222. break;
  18223. case decimal x when (x >= 3001 && x <= 8000):
  18224. jjcXS = 2.3M;
  18225. break;
  18226. case decimal x when (x >= 8001 && x <= 15000):
  18227. jjcXS = 2.1M;
  18228. break;
  18229. case decimal x when (x >= 15001 && x <= 30000):
  18230. jjcXS = 1.95M;
  18231. break;
  18232. case > 30000:
  18233. jjcXS = 1.8M;
  18234. break;
  18235. default:
  18236. break;
  18237. }
  18238. #endregion
  18239. #region 公务舱系数
  18240. var gwcXS = 0.00M;
  18241. switch (dto.GWCCB)
  18242. {
  18243. case decimal x when (x >= 1000 && x <= 3000):
  18244. gwcXS = 2.5M;
  18245. break;
  18246. case decimal x when (x >= 3001 && x <= 8000):
  18247. gwcXS = 2.2M;
  18248. break;
  18249. case decimal x when (x >= 8001 && x <= 15000):
  18250. gwcXS = 2.0M;
  18251. break;
  18252. case decimal x when (x >= 15001 && x <= 30000):
  18253. gwcXS = 1.85M;
  18254. break;
  18255. case > 30000:
  18256. gwcXS = 1.7M;
  18257. break;
  18258. default:
  18259. break;
  18260. }
  18261. #endregion
  18262. #region 头等舱系数
  18263. var tdcXS = 0.00M;
  18264. switch (dto.TDCCB)
  18265. {
  18266. case > 70000:
  18267. tdcXS = 1.5M;
  18268. break;
  18269. default:
  18270. tdcXS = 1.9M;
  18271. break;
  18272. }
  18273. #endregion
  18274. #endregion
  18275. #region 酒店系数
  18276. Dictionary<decimal, List<string>> dic = new Dictionary<decimal, List<string>>()
  18277. {
  18278. {1.6M, new List<string>(){"新西兰","澳大利亚" }},
  18279. {1.5M, new List<string>(){"越南社会主义共和国",
  18280. "老挝",
  18281. "柬埔寨",
  18282. "泰国",
  18283. "缅甸",
  18284. "马来西亚",
  18285. //"新加坡",
  18286. "文莱达鲁萨兰",
  18287. "印度尼西亚",
  18288. "东帝汶"}},
  18289. {1.2M, new List<string>(){ "日本","新加坡","法国","意大利","荷兰"}},
  18290. };
  18291. #region SGR
  18292. var sgrXS = 1.25M;
  18293. #endregion
  18294. #region TBR
  18295. var tbrXS = 1.25M;
  18296. #endregion
  18297. #region JSES
  18298. var jsesXS = 1.25M;
  18299. #endregion
  18300. #region SUITE
  18301. var suiteXS = 1.25M;
  18302. #endregion
  18303. var countryArr = di.VisitCountry.Split("|");
  18304. foreach (var item in dic)
  18305. {
  18306. var extsisCount = item.Value.Where(x => countryArr.Contains(x))
  18307. .Count();
  18308. if (extsisCount > 0)
  18309. {
  18310. jsesXS = item.Key;
  18311. sgrXS = item.Key;
  18312. tbrXS = item.Key;
  18313. suiteXS = item.Key;
  18314. }
  18315. }
  18316. #endregion
  18317. #region 地接系数
  18318. var djXS = 0.00M;
  18319. switch (dto.DJRS)
  18320. {
  18321. case 2 or 3:
  18322. djXS = 2.65M;
  18323. break;
  18324. case 4:
  18325. djXS = 2.6M;
  18326. break;
  18327. case 5 or 6:
  18328. djXS = 2.5M;
  18329. break;
  18330. case 7 or 8:
  18331. djXS = 2.4M;
  18332. break;
  18333. case 9 or 10:
  18334. djXS = 2.3M;
  18335. break;
  18336. case 11:
  18337. djXS = 2.2M;
  18338. break;
  18339. case 12:
  18340. djXS = 2.1M;
  18341. break;
  18342. case 13 or 14:
  18343. djXS = 2M;
  18344. break;
  18345. case 15:
  18346. djXS = 1.9M;
  18347. break;
  18348. case 16 or 17 or 18:
  18349. djXS = 1.8M;
  18350. break;
  18351. case 19 or 20:
  18352. djXS = 1.7M;
  18353. break;
  18354. }
  18355. #endregion
  18356. #region 零用金系数
  18357. var lyjXS = 0.00M;
  18358. switch (dto.LYJRS)
  18359. {
  18360. case 2:
  18361. lyjXS = 1.25M;
  18362. break;
  18363. case 3 or 4 or 5:
  18364. lyjXS = 1.2M;
  18365. break;
  18366. case int number when (number > 5 && number < 10):
  18367. lyjXS = 1.15M;
  18368. break;
  18369. case > 10:
  18370. lyjXS = 1.1M;
  18371. break;
  18372. default:
  18373. break;
  18374. }
  18375. #endregion
  18376. return Ok(JsonView(true, "查询成功", new ArrayList()
  18377. {
  18378. new { label = "火车票系数", value = hcpXS, key = "hcpXS" },
  18379. new { label = "经济舱系数", value = jjcXS, key = "jjcXS" },
  18380. new { label = "公务舱系数", value = gwcXS, key = "gwcXS" },
  18381. new { label = "头等舱系数", value = tdcXS, key = "tdcXS" },
  18382. new { label = "SGR系数", value = sgrXS, key = "sgrXS" },
  18383. new { label = "TBR系数", value = tbrXS, key = "tbrXS" },
  18384. new { label = "JSES系数", value = jsesXS, key = "jsesXS" },
  18385. new { label = "SUITE系数", value = suiteXS, key = "suiteXS" },
  18386. new { label = "地接系数", value = djXS, key = "djXS" },
  18387. new { label = "零用金系数", value = lyjXS, key = "lyjXS" },
  18388. new { label = "公务系数", value = 2M, key = "gwXS" }
  18389. }));
  18390. }
  18391. #endregion
  18392. #region 酒店预订 New 2023-12-28 17:45
  18393. /// <summary>
  18394. /// 酒店预订
  18395. /// 酒店费用列表 根据团组Id查询
  18396. /// </summary>
  18397. /// <param name="_dto"></param>
  18398. /// <returns></returns>
  18399. [HttpPost]
  18400. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18401. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  18402. {
  18403. #region 参数验证
  18404. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  18405. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  18406. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  18407. #region 团组操作权限验证 76 酒店预定模块
  18408. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18409. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  18410. #endregion
  18411. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18412. #region 页面操作权限验证
  18413. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18414. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  18415. #endregion
  18416. #endregion
  18417. return Ok(await _hotelPriceRep.ItemsByDiId(_dto.PortType, _dto.DiId));
  18418. }
  18419. /// <summary>
  18420. /// 酒店预订
  18421. /// 基础数据
  18422. /// </summary>
  18423. /// <param name="_dto"></param>
  18424. /// <returns></returns>
  18425. [HttpPost]
  18426. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18427. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  18428. {
  18429. #region 参数验证
  18430. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  18431. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  18432. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  18433. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18434. #region 页面操作权限验证
  18435. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18436. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  18437. #endregion
  18438. #region 团组操作权限验证 76 酒店预定模块
  18439. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18440. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  18441. #endregion
  18442. #endregion
  18443. return Ok(await _hotelPriceRep.BasicsDataInit(_dto.PortType, _dto.DiId));
  18444. }
  18445. /// <summary>
  18446. /// 酒店预订
  18447. /// 创建 入住卷号码
  18448. /// </summary>
  18449. /// <param name="_dto"></param>
  18450. /// <returns></returns>
  18451. [HttpPost]
  18452. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18453. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  18454. {
  18455. #region 参数验证
  18456. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  18457. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  18458. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  18459. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18460. #region 页面操作权限验证
  18461. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18462. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  18463. #endregion
  18464. #region 团组操作权限验证 76 酒店预定模块
  18465. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18466. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  18467. #endregion
  18468. #endregion
  18469. Result data = await _hotelPriceRep.CreateCheckVolumeNo(_dto.DiId);
  18470. if (data.Code != 0)
  18471. {
  18472. return Ok(JsonView(false, data.Msg));
  18473. }
  18474. return Ok(JsonView(true, data.Msg, data.Data));
  18475. }
  18476. /// <summary>
  18477. /// 酒店预订
  18478. /// 详情
  18479. /// </summary>
  18480. /// <param name="_dto"></param>
  18481. /// <returns></returns>
  18482. [HttpPost]
  18483. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18484. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  18485. {
  18486. #region 参数验证
  18487. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  18488. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  18489. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  18490. #region 团组操作权限验证 76 酒店预定模块
  18491. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18492. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  18493. #endregion
  18494. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18495. #region 页面操作权限验证
  18496. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18497. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  18498. #endregion
  18499. #endregion
  18500. return Ok(await _hotelPriceRep.Details(_dto.PortType, _dto.Id));
  18501. }
  18502. /// <summary>
  18503. /// 酒店预订
  18504. /// Add Or Edit
  18505. /// </summary>
  18506. /// <param name="_dto"></param>
  18507. /// <returns></returns>
  18508. [HttpPost]
  18509. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18510. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  18511. {
  18512. #region 参数验证
  18513. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  18514. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  18515. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  18516. #region 团组操作权限验证 76 酒店预定模块
  18517. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18518. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  18519. #endregion
  18520. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18521. #region 页面操作权限验证
  18522. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18523. if (_dto.Id == 0) // Add
  18524. {
  18525. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  18526. }
  18527. else if (_dto.Id > 1) // Edit
  18528. {
  18529. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  18530. }
  18531. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  18532. #endregion
  18533. #endregion
  18534. JsonView _view = await _hotelPriceRep.AddOrEdit(_dto);
  18535. if (_view.Code != 200)
  18536. {
  18537. return Ok(_view);
  18538. }
  18539. #region 成本无酒店价格数据进入超支
  18540. _sqlSugar.BeginTran();
  18541. var start_Bool = DateTime.TryParse(_dto.CheckInDate, out DateTime start_Time);
  18542. var end_Bool = DateTime.TryParse(_dto.CheckOutDate, out DateTime end_Time);
  18543. var groupCost = _sqlSugar.Queryable<Grp_GroupCost>().Where(x => x.Diid == _dto.DiId && x.IsDel == 0).ToList();
  18544. for (int i = 0; i < groupCost.Count; i++)
  18545. {
  18546. if (groupCost[i].Date.IsNullOrWhiteSpace() && i != 0)
  18547. {
  18548. groupCost[i].Date = groupCost[i - 1].Date;
  18549. }
  18550. }
  18551. var groupCost_Grp = groupCost.GroupBy(x => x.Date).ToList();
  18552. List<Fin_GroupExtraCostDto_OP> extraCostList = new
  18553. List<Fin_GroupExtraCostDto_OP>();
  18554. if (start_Bool && end_Bool)
  18555. {
  18556. while (start_Time < end_Time)
  18557. {
  18558. foreach (var item in groupCost_Grp)
  18559. {
  18560. if (DateTime.TryParse(item.Key, out DateTime cost_Time))
  18561. {
  18562. if (DateTime.Compare(start_Time, cost_Time) == 0 && item.Sum(x => x.SGR + x.Suite + x.TBR + x.JS_ES) == 0)
  18563. {
  18564. extraCostList.Add(new
  18565. Fin_GroupExtraCostDto_OP
  18566. {
  18567. Area = _dto.AreaId,
  18568. coefficient = 1.5M,
  18569. createUser = _dto.UserId,
  18570. currency = _dto.CardPriceCurrency,
  18571. diId = _dto.DiId,
  18572. ManagerConfirm = 0,
  18573. SupervisorConfirm = 0,
  18574. SYsupervisorConfirm = 0,
  18575. editType = 1,
  18576. PortType = 1,
  18577. price = _dto.CardPrice,
  18578. PriceCount = 1,
  18579. priceType = 1027,
  18580. priceDetailType = 1044,
  18581. PriceDt = start_Time.ToString("yyyy-MM-dd"),
  18582. priceName = $"酒店超支费用-酒店导入-({start_Time.ToString("yyyy/MM/dd")})",
  18583. });
  18584. }
  18585. }
  18586. }
  18587. start_Time = start_Time.AddDays(1);
  18588. }
  18589. }
  18590. if (extraCostList.Any())
  18591. {
  18592. await _carTouristGuideGroundRep.GroupExtraCost_OperatorList(extraCostList);
  18593. }
  18594. _sqlSugar.CommitTran();
  18595. #endregion
  18596. #region 应用推送
  18597. try
  18598. {
  18599. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  18600. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  18601. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  18602. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  18603. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  18604. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  18605. var diId = _dto.DiId;
  18606. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  18607. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  18608. #region 操作记录
  18609. var opInfo = new Crm_TableOperationRecord()
  18610. {
  18611. TableName = "Grp_HotelReservations",
  18612. PortType = _dto.PortType,
  18613. DataId = hotelId,
  18614. CreateUserId = _dto.UserId
  18615. };
  18616. //var opStatus = OperationEnum.NoOperation;
  18617. if (_dto.Id < 1) //添加操作
  18618. {
  18619. opInfo.OperationItem = OperationEnum.Add;
  18620. }
  18621. else if (_dto.Id > 0)
  18622. {
  18623. opInfo.OperationItem = OperationEnum.Edit;
  18624. }
  18625. string opRemark = string.Empty;
  18626. if (ccpInfo != null)
  18627. {
  18628. // USD 1211.86、 CNY 8761.75、汇率:7.2300
  18629. var currency = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.Id == ccpInfo.PaymentCurrency).First()?.Name;
  18630. var cnyPrice = ccpInfo.PayMoney * ccpInfo.DayRate;
  18631. opRemark = $"{currency} {ccpInfo.PayMoney.ToString("#0.00")}、CNY {cnyPrice.ToString("#0.00")}、汇率:{ccpInfo.DayRate.ToString("#0.0000")}";
  18632. }
  18633. opInfo.Remark = opRemark;
  18634. await _tableorRep.AddAsync(opInfo);
  18635. #endregion
  18636. _logger.LogInformation($"【iOS推送通知Exception】Begin");
  18637. //2024-10-21 新增LZ UID
  18638. var userIds = new List<int>() { 21 };
  18639. string title = $"费用审核";
  18640. string content = "";
  18641. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  18642. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  18643. try
  18644. {
  18645. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "76" };
  18646. await APNsTools.iOS_PushNotifications1("051", title, "", content, true, "ExpenseAuditWebView", h5);
  18647. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】Start");
  18648. //var iosRes = await APNsTools.iOS_PushNotifications("051", title, "", content);
  18649. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】End Response:[{JsonConvert.SerializeObject(iosRes)}]");
  18650. }
  18651. catch (Exception ex)
  18652. {
  18653. Logs($"【iOS推送通知-PostHotelReservationsAddOrEdit-Exception】[{ex.Message}]");
  18654. }
  18655. }
  18656. catch (Exception ex)
  18657. {
  18658. Logs($"【iOS推送通知Exception】【{ex.Message}】");
  18659. }
  18660. try
  18661. {
  18662. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  18663. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  18664. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  18665. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  18666. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  18667. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  18668. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  18669. //自动审核
  18670. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  18671. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  18672. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  18673. //2024-10-21 新增LZ UID
  18674. var userIds = new List<int>() { 21 };
  18675. string title = $"系统通知";
  18676. var diId = _dto.DiId;
  18677. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  18678. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  18679. string content = "";
  18680. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  18681. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  18682. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  18683. }
  18684. catch (Exception ex)
  18685. {
  18686. }
  18687. #endregion
  18688. return Ok(_view);
  18689. }
  18690. /// <summary>
  18691. /// 酒店自动审核测试
  18692. /// Add Or Edit
  18693. /// </summary>
  18694. /// <param name="diid"></param>
  18695. /// <param name="dataId"></param>
  18696. /// <returns></returns>
  18697. [HttpPost]
  18698. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18699. public async Task<IActionResult> PostHotelAutoAuditTest(int diid, int dataId)
  18700. {
  18701. #region 应用推送
  18702. try
  18703. {
  18704. //自动审核
  18705. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  18706. }
  18707. catch (Exception ex)
  18708. {
  18709. return Ok(JsonView(false, ex.Message));
  18710. }
  18711. #endregion
  18712. return Ok(JsonView(false, "操作成功"));
  18713. }
  18714. /// <summary>
  18715. /// 酒店预订
  18716. /// Del
  18717. /// </summary>
  18718. /// <param name="_dto"></param>
  18719. /// <returns></returns>
  18720. [HttpPost]
  18721. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18722. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  18723. {
  18724. #region 参数验证
  18725. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  18726. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  18727. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  18728. #region 团组操作权限验证 76 酒店预定模块
  18729. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18730. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  18731. #endregion
  18732. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18733. #region 页面操作权限验证
  18734. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18735. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  18736. #endregion
  18737. #endregion
  18738. var data = await _hotelPriceRep.Del(_dto.Id, _dto.UserId);
  18739. #region 操作记录
  18740. await _tableorRep.AddAsync(new Crm_TableOperationRecord()
  18741. {
  18742. TableName = "Grp_HotelReservations",
  18743. PortType = _dto.PortType,
  18744. OperationItem = OperationEnum.Del,
  18745. DataId = _dto.Id,
  18746. CreateUserId = _dto.UserId
  18747. });
  18748. #endregion
  18749. return Ok(data);
  18750. }
  18751. /// <summary>
  18752. /// 酒店预订
  18753. /// 生成VOUCHER
  18754. /// 2024.05.06 之前版本
  18755. /// </summary>
  18756. /// <param name="_dto"></param>
  18757. /// <returns></returns>
  18758. [HttpPost]
  18759. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18760. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  18761. {
  18762. try
  18763. {
  18764. #region 参数验证
  18765. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  18766. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  18767. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  18768. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  18769. #region 团组操作权限验证 76 酒店预定模块
  18770. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18771. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  18772. #endregion
  18773. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18774. #region 页面操作权限验证
  18775. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18776. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  18777. #endregion
  18778. #endregion
  18779. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  18780. //判断数据是否完整
  18781. if (hr != null)
  18782. {
  18783. if (!string.IsNullOrEmpty(hr.DetermineNo))
  18784. {
  18785. string strFileName = "HotelStatement/";
  18786. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  18787. if (dele != null)
  18788. strFileName += dele.TourCode;
  18789. //载入模板
  18790. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  18791. Document doc = new Document(sss);
  18792. DocumentBuilder builder = new DocumentBuilder(doc);
  18793. #region 替换Word模板书签内容
  18794. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  18795. //入住卷预定号码
  18796. if (doc.Range.Bookmarks["VNO"] != null)
  18797. {
  18798. Bookmark mark = doc.Range.Bookmarks["VNO"];
  18799. mark.Text = hr.CheckNumber;
  18800. }
  18801. //酒店时间
  18802. if (doc.Range.Bookmarks["Date"] != null)
  18803. {
  18804. Bookmark mark = doc.Range.Bookmarks["Date"];
  18805. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  18806. }
  18807. //团号
  18808. if (doc.Range.Bookmarks["TNo"] != null)
  18809. {
  18810. Bookmark mark = doc.Range.Bookmarks["TNo"];
  18811. mark.Text = dele.TourCode;
  18812. }
  18813. //预定号码
  18814. if (doc.Range.Bookmarks["BookingId"] != null)
  18815. {
  18816. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  18817. mark.Text = hr.ReservationsNo;
  18818. }
  18819. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  18820. {
  18821. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  18822. mark.Text = hr.DetermineNo;
  18823. }
  18824. //酒店城市
  18825. if (doc.Range.Bookmarks["City"] != null)
  18826. {
  18827. Bookmark mark = doc.Range.Bookmarks["City"];
  18828. mark.Text = hr.City;
  18829. }
  18830. //酒店名称
  18831. if (doc.Range.Bookmarks["HName"] != null)
  18832. {
  18833. Bookmark mark = doc.Range.Bookmarks["HName"];
  18834. mark.Text = hr.HotelName;
  18835. }
  18836. //酒店地址
  18837. if (doc.Range.Bookmarks["Address"] != null)
  18838. {
  18839. Bookmark mark = doc.Range.Bookmarks["Address"];
  18840. mark.Text = hr.HotelAddress;
  18841. }
  18842. //酒店电话
  18843. if (doc.Range.Bookmarks["Tel"] != null)
  18844. {
  18845. Bookmark mark = doc.Range.Bookmarks["Tel"];
  18846. mark.Text = hr.HotelTel;
  18847. }
  18848. //酒店传真
  18849. if (doc.Range.Bookmarks["Fax"] != null)
  18850. {
  18851. Bookmark mark = doc.Range.Bookmarks["Fax"];
  18852. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  18853. {
  18854. mark.Text = hr.HotelFax;
  18855. }
  18856. }
  18857. //入住时间
  18858. if (doc.Range.Bookmarks["CIn"] != null)
  18859. {
  18860. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  18861. Bookmark mark = doc.Range.Bookmarks["CIn"];
  18862. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  18863. }
  18864. //退房时间
  18865. if (doc.Range.Bookmarks["COut"] != null)
  18866. {
  18867. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  18868. Bookmark mark = doc.Range.Bookmarks["COut"];
  18869. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  18870. }
  18871. //客户名称
  18872. if (doc.Range.Bookmarks["GName"] != null)
  18873. {
  18874. string guestName = "";
  18875. string[] clients = Array.Empty<string>();
  18876. if (hr.GuestName.Contains(","))
  18877. {
  18878. clients = hr.GuestName.Split(",");
  18879. }
  18880. else
  18881. {
  18882. clients = new string[] { hr.GuestName };
  18883. }
  18884. List<int> clientIds_int = new List<int>();
  18885. if (clients.Length > 0)
  18886. {
  18887. foreach (var item in clients)
  18888. {
  18889. if (item.IsNumeric())
  18890. {
  18891. clientIds_int.Add(int.Parse(item));
  18892. }
  18893. }
  18894. }
  18895. if (clientIds_int.Count > 0)
  18896. {
  18897. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  18898. foreach (var client in _clientDatas)
  18899. {
  18900. //男
  18901. if (client.Sex == 0) guestName += $"Mr.";
  18902. //女
  18903. else if (client.Sex == 1) guestName += $"Ms.";
  18904. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  18905. {
  18906. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  18907. }
  18908. //guestName += $"{client.Pinyin},";
  18909. }
  18910. if (guestName.Length > 0)
  18911. {
  18912. guestName = guestName.Substring(0, guestName.Length - 1);
  18913. }
  18914. }
  18915. else
  18916. {
  18917. guestName = hr.GuestName;
  18918. }
  18919. Bookmark mark = doc.Range.Bookmarks["GName"];
  18920. mark.Text = guestName;
  18921. }
  18922. //房间介绍
  18923. if (doc.Range.Bookmarks["ROOM"] != null)
  18924. {
  18925. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  18926. mark.Text = hr.RoomExplanation;
  18927. }
  18928. //报价描述
  18929. if (doc.Range.Bookmarks["NOTE"] != null)
  18930. {
  18931. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  18932. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  18933. if (ss != null)
  18934. mark.Text = ss.Name;
  18935. }
  18936. //入住时间
  18937. if (doc.Range.Bookmarks["CheckIn"] != null)
  18938. {
  18939. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  18940. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  18941. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  18942. }
  18943. //退房时间
  18944. if (doc.Range.Bookmarks["CheckOut"] != null)
  18945. {
  18946. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  18947. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  18948. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  18949. }
  18950. //日期
  18951. if (doc.Range.Bookmarks["DT"] != null)
  18952. {
  18953. Bookmark mark = doc.Range.Bookmarks["DT"];
  18954. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  18955. }
  18956. //名称
  18957. if (doc.Range.Bookmarks["VName"] != null)
  18958. {
  18959. Bookmark mark = doc.Range.Bookmarks["VName"];
  18960. mark.Text = hr.HotelName;
  18961. }
  18962. //号码
  18963. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  18964. {
  18965. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  18966. mark.Text = hr.CheckNumber;
  18967. }
  18968. #endregion
  18969. strFileName += "VOUCHER.doc";
  18970. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  18971. doc.Save(fileDir);
  18972. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  18973. return Ok(JsonView(true, "操作成功!", Url));
  18974. }
  18975. else
  18976. {
  18977. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  18978. }
  18979. }
  18980. else
  18981. {
  18982. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  18983. }
  18984. }
  18985. catch (Exception ex)
  18986. {
  18987. return Ok(JsonView(false, ex.Message));
  18988. }
  18989. }
  18990. /// <summary>
  18991. /// 酒店预订
  18992. /// 生成VOUCHER
  18993. /// 2024.05.06 之后版本
  18994. /// </summary>
  18995. /// <param name="_dto"></param>
  18996. /// <returns></returns>
  18997. [HttpPost]
  18998. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18999. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  19000. {
  19001. #region 参数验证
  19002. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  19003. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  19004. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  19005. #region 团组操作权限验证 76 酒店预定模块
  19006. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  19007. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  19008. #endregion
  19009. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19010. #region 页面操作权限验证
  19011. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19012. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  19013. #endregion
  19014. #endregion
  19015. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  19016. //判断数据是否完整
  19017. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  19018. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  19019. string strFileName = "HotelStatement/";
  19020. string guestNames = ""; //格式Mr.xxx Ms.xxx
  19021. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  19022. #region 数据处理
  19023. List<int> guestIds = new List<int>();
  19024. //int index = 0;
  19025. foreach (var item in hrDtas)
  19026. {
  19027. if (item.GuestName.Contains(","))
  19028. {
  19029. string[] guestIdArr = item.GuestName.Split(',');
  19030. foreach (var guestIdStr in guestIdArr)
  19031. {
  19032. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  19033. if (guestBool)
  19034. {
  19035. guestIds.Add(guestId);
  19036. }
  19037. }
  19038. }
  19039. else guestNames += item.GuestName;
  19040. var voucherInfo = new HotelVoucherInfoView()
  19041. {
  19042. HotelName = item.HotelName,
  19043. CheckInDate = item.CheckInDate,
  19044. CheckOutDate = item.CheckOutDate,
  19045. ConfirmationNumber = item.DetermineNo.Trim(),
  19046. RoomType = item.RoomExplanation
  19047. };
  19048. vouchers.Add(voucherInfo);
  19049. }
  19050. if (guestIds.Count > 0)
  19051. {
  19052. guestIds = guestIds.Distinct().ToList();
  19053. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  19054. if (guestDatas.Count > 0)
  19055. {
  19056. guestNames = "";
  19057. foreach (var guest in guestDatas)
  19058. {
  19059. string guestName = "";
  19060. if (guest.Sex == 0) guestName += @"MR.";
  19061. else if (guest.Sex == 1) guestName += @"MS.";
  19062. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  19063. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  19064. guestNames += @$"{guestName.Trim()}、";
  19065. }
  19066. if (guestNames.Length > 0)
  19067. {
  19068. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  19069. }
  19070. }
  19071. }
  19072. #endregion
  19073. //载入模板
  19074. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  19075. Document doc = new Document(sss);
  19076. DocumentBuilder builder = new DocumentBuilder(doc);
  19077. if (doc.Range.Bookmarks["GuestName"] != null)
  19078. {
  19079. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  19080. mark.Text = guestNames;
  19081. }
  19082. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  19083. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  19084. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  19085. for (int i = 1; i <= vouchers.Count; i++)
  19086. {
  19087. HotelVoucherInfoView hviv = vouchers[i - 1];
  19088. builder.MoveToCell(0, i, 0, 0);
  19089. builder.Write(hviv.HotelName);
  19090. builder.MoveToCell(0, i, 1, 0);
  19091. builder.Write(hviv.CheckInDate);
  19092. builder.MoveToCell(0, i, 2, 0);
  19093. builder.Write(hviv.CheckOutDate);
  19094. builder.MoveToCell(0, i, 3, 0);
  19095. builder.Write(hviv.RoomType);
  19096. builder.MoveToCell(0, i, 4, 0);
  19097. builder.Write(hviv.ConfirmationNumber);
  19098. }
  19099. //删除多余行
  19100. int currRowIndex = vouchers.Count + 1;
  19101. int delRows = 21 - currRowIndex;
  19102. if (delRows > 0)
  19103. {
  19104. for (int i = 0; i < delRows; i++)
  19105. {
  19106. table.Rows.RemoveAt(currRowIndex);
  19107. //cultivateRowIndex++;
  19108. }
  19109. }
  19110. strFileName += "VOUCHER.docx";
  19111. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  19112. doc.Save(fileDir);
  19113. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  19114. return Ok(JsonView(true, "操作成功!", Url));
  19115. }
  19116. /// <summary>
  19117. /// 酒店预订
  19118. /// 生成VOUCHER 批量生成
  19119. /// New
  19120. /// </summary>
  19121. /// <param name="_dto"></param>
  19122. /// <returns></returns>
  19123. [HttpPost]
  19124. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19125. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  19126. {
  19127. #region 参数验证
  19128. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  19129. if (_dto.PageId < 1) _dto.PageId = 28;
  19130. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  19131. #region 团组操作权限验证 76 酒店预定模块
  19132. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  19133. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  19134. #endregion
  19135. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19136. #region 页面操作权限验证
  19137. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19138. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  19139. #endregion
  19140. #endregion
  19141. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  19142. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  19143. .OrderBy(x => x.CheckInDate)
  19144. .ToListAsync();
  19145. //判断数据是否完整
  19146. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  19147. string strFileName = "HotelStatement/";
  19148. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  19149. if (dele != null)
  19150. strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
  19151. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>()
  19152. .Select(x => new Crm_DeleClient { Id = x.Id, FirstName = x.FirstName, LastName = x.LastName, Pinyin = x.Pinyin })
  19153. .Where(it => it.IsDel == 0)
  19154. .ToListAsync();
  19155. foreach (var item in guestDatas) EncryptionProcessor.DecryptProperties(item);
  19156. for (int i = 0; i < hrDtas.Count; i++)
  19157. {
  19158. string guestNames = string.Empty;
  19159. List<int> guestIds = new List<int>();
  19160. var item = hrDtas[i];
  19161. //处理客户姓名
  19162. if (item.GuestName.Contains(","))
  19163. {
  19164. string[] guestIdArr = item.GuestName.Split(',');
  19165. foreach (var guestIdStr in guestIdArr)
  19166. if (int.TryParse(guestIdStr, out int guestId))
  19167. guestIds.Add(guestId);
  19168. }
  19169. else
  19170. {
  19171. bool guestIdBool = int.TryParse(item.GuestName, out int guestId);
  19172. if (guestIdBool)
  19173. {
  19174. guestIds.Add(guestId);
  19175. }
  19176. //NaN
  19177. if (item.GuestName.Contains("NaN"))
  19178. {
  19179. guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
  19180. }
  19181. }
  19182. if (guestIds.Count > 0)
  19183. {
  19184. guestIds = guestIds.Distinct().ToList();
  19185. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  19186. if (guestDatas1.Count > 0)
  19187. {
  19188. guestNames = "";
  19189. foreach (var guest in guestDatas1)
  19190. {
  19191. string guestName = "";
  19192. if (guest.Sex == 0) guestName += @"MR.";
  19193. else if (guest.Sex == 1) guestName += @"MS.";
  19194. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  19195. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  19196. guestNames += @$"{guestName.Trim()}、";
  19197. }
  19198. if (guestNames.Length > 0)
  19199. {
  19200. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  19201. }
  19202. }
  19203. }
  19204. //if (!string.IsNullOrEmpty(guestNames))
  19205. //{
  19206. hrDtas[i].GuestName = guestNames;
  19207. //}
  19208. }
  19209. strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  19210. Document doc = new Document();
  19211. DocumentBuilder builder = new DocumentBuilder(doc);
  19212. try
  19213. {
  19214. builder.MoveToDocumentStart();
  19215. foreach (var item in hrDtas)
  19216. {
  19217. //标题
  19218. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  19219. builder.ParagraphFormat.LineSpacing = 1;
  19220. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19221. builder.ParagraphFormat.Style.Font.Size = 9;
  19222. builder.ParagraphFormat.Style.Font.Bold = true;
  19223. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  19224. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  19225. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  19226. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  19227. builder.ParagraphFormat.LineSpacing = 1;
  19228. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19229. builder.ParagraphFormat.Style.Font.Size = 9;
  19230. builder.ParagraphFormat.Style.Font.Bold = true;
  19231. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  19232. builder.StartTable();
  19233. // 设置边框颜色
  19234. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  19235. //设置边框样式
  19236. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
  19237. //表格
  19238. #region 第一行
  19239. builder.InsertCell();
  19240. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19241. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19242. //builder.CellFormat.AllowAutoFit = false;
  19243. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19244. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19245. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19246. builder.CellFormat.WrapText = true; //自动换行
  19247. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  19248. builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
  19249. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19250. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19251. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19252. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19253. builder.Write("TOUR NO:");
  19254. builder.InsertCell();
  19255. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19256. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19257. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19258. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19259. builder.ParagraphFormat.Style.Font.Bold = false;
  19260. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19261. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  19262. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19263. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19264. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19265. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19266. builder.Write($"{dele?.TourCode ?? "-"}");
  19267. builder.InsertCell();
  19268. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19269. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19270. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19271. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19272. builder.ParagraphFormat.Style.Font.Bold = false;
  19273. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19274. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  19275. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19276. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19277. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19278. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19279. builder.Write($"CITY:");
  19280. builder.InsertCell();
  19281. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19282. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19283. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19284. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19285. builder.ParagraphFormat.Style.Font.Bold = false;
  19286. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19287. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  19288. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19289. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19290. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19291. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19292. builder.Write($"{item.City}");
  19293. builder.EndRow();
  19294. #endregion
  19295. #region 第二行
  19296. builder.InsertCell();
  19297. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19298. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19299. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19300. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19301. builder.ParagraphFormat.Style.Font.Bold = false;
  19302. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19303. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  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.Write("CONFIRMATION NO:");
  19309. builder.InsertCell();
  19310. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19311. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19312. builder.ParagraphFormat.Style.Font.Size = 8;
  19313. builder.ParagraphFormat.Style.Font.Bold = false;
  19314. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19315. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19316. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  19317. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19318. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19319. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19320. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19321. builder.CellFormat.HorizontalMerge = CellMerge.First;
  19322. builder.Write($"{item.DetermineNo}");
  19323. builder.InsertCell();
  19324. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19325. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  19326. builder.InsertCell();
  19327. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19328. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  19329. builder.EndRow();
  19330. #endregion
  19331. #region 第三行
  19332. builder.InsertCell();
  19333. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19334. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19335. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19336. builder.ParagraphFormat.Style.Font.Bold = false;
  19337. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19338. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19339. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  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.Write($"HOTEL NAME:");
  19345. builder.InsertCell();
  19346. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19347. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19348. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19349. builder.ParagraphFormat.Style.Font.Bold = false;
  19350. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19351. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19352. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  19353. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19354. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19355. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19356. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19357. builder.CellFormat.HorizontalMerge = CellMerge.First;
  19358. builder.Write($"{item.HotelName}");
  19359. builder.InsertCell();
  19360. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19361. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  19362. builder.InsertCell();
  19363. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19364. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  19365. builder.EndRow();
  19366. #endregion
  19367. #region 第四行
  19368. builder.InsertCell();
  19369. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  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.Right;//对齐
  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($"HOTEL ADDRESS:");
  19381. builder.InsertCell();
  19382. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19383. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19384. builder.ParagraphFormat.Style.Font.Size = 8;
  19385. builder.ParagraphFormat.Style.Font.Bold = false;
  19386. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19387. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19388. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  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.CellFormat.HorizontalMerge = CellMerge.First;
  19394. builder.Write($"{item.HotelAddress}");
  19395. builder.InsertCell();
  19396. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19397. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  19398. builder.InsertCell();
  19399. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19400. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  19401. builder.EndRow();
  19402. #endregion
  19403. #region 第五行
  19404. builder.InsertCell();
  19405. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19406. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19407. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19408. builder.ParagraphFormat.Style.Font.Bold = false;
  19409. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19410. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19411. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  19412. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19413. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19414. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19415. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19416. builder.Write("TEL:");
  19417. builder.InsertCell();
  19418. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19419. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19420. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19421. builder.ParagraphFormat.Style.Font.Bold = false;
  19422. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19423. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19424. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  19425. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19426. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19427. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19428. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19429. builder.Write($"{item.HotelTel}");
  19430. builder.InsertCell();
  19431. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19432. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19433. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19434. builder.ParagraphFormat.Style.Font.Bold = false;
  19435. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19436. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19437. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  19438. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19439. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19440. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19441. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19442. builder.Write($"FAX:");
  19443. builder.InsertCell();
  19444. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19445. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19446. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19447. builder.ParagraphFormat.Style.Font.Bold = false;
  19448. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19449. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19450. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  19451. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19452. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19453. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19454. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19455. builder.Write($"{item.HotelFax}");
  19456. builder.EndRow();
  19457. #endregion
  19458. #region 第六行
  19459. builder.InsertCell();
  19460. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19461. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19462. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19463. builder.ParagraphFormat.Style.Font.Bold = false;
  19464. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19465. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19466. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  19467. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19468. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19469. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19470. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19471. builder.Write("CHECK IN:");
  19472. builder.InsertCell();
  19473. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19474. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19475. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19476. builder.ParagraphFormat.Style.Font.Bold = false;
  19477. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19478. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19479. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  19480. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19481. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19482. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19483. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19484. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  19485. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  19486. builder.Write($"{checkInStr}");
  19487. builder.InsertCell();
  19488. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19489. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19490. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19491. builder.ParagraphFormat.Style.Font.Bold = false;
  19492. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19493. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19494. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  19495. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19496. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19497. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19498. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19499. builder.Write($"CHECK OUT:");
  19500. builder.InsertCell();
  19501. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19502. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19503. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19504. builder.ParagraphFormat.Style.Font.Bold = false;
  19505. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19506. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19507. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  19508. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19509. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19510. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19511. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19512. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  19513. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  19514. builder.Write($"{checkOutStr}");
  19515. builder.EndRow();
  19516. #endregion
  19517. #region 第七行
  19518. builder.InsertCell();
  19519. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  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.Right;//对齐
  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.Write($"GUEST NAME:");
  19531. builder.InsertCell();
  19532. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19533. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19534. builder.ParagraphFormat.Style.Font.Size = 8;
  19535. builder.ParagraphFormat.Style.Font.Bold = false;
  19536. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19537. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19538. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  19539. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19540. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19541. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19542. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19543. builder.CellFormat.HorizontalMerge = CellMerge.First;
  19544. builder.Write($"{item.GuestName.Trim()}");
  19545. builder.InsertCell();
  19546. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19547. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  19548. builder.InsertCell();
  19549. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19550. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  19551. builder.EndRow();
  19552. #endregion
  19553. #region 第八行
  19554. builder.InsertCell();
  19555. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  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.Right;//对齐
  19562. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19563. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19564. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19565. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19566. builder.Write($"ROOM TYPE:");
  19567. builder.InsertCell();
  19568. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19569. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19570. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19571. builder.ParagraphFormat.Style.Font.Bold = false;
  19572. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19573. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19574. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  19575. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19576. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19577. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19578. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19579. builder.CellFormat.HorizontalMerge = CellMerge.First;
  19580. builder.Write($"{item.RoomExplanation}");
  19581. builder.InsertCell();
  19582. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19583. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  19584. builder.InsertCell();
  19585. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19586. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  19587. builder.EndRow();
  19588. #endregion
  19589. #region 第九行
  19590. builder.InsertCell();
  19591. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19592. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19593. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19594. builder.ParagraphFormat.Style.Font.Bold = false;
  19595. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19596. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19597. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  19598. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19599. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19600. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19601. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19602. builder.Write($"NOTE:");
  19603. builder.InsertCell();
  19604. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19605. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19606. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19607. builder.ParagraphFormat.Style.Font.Bold = false;
  19608. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19609. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19610. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  19611. builder.CellFormat.HorizontalMerge = CellMerge.First;
  19612. 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.");
  19613. builder.InsertCell();
  19614. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19615. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  19616. builder.InsertCell();
  19617. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19618. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  19619. builder.EndRow();
  19620. #endregion
  19621. builder.EndTable();
  19622. //换行
  19623. builder.Writeln("");
  19624. builder.Writeln("");
  19625. }
  19626. #region 获取文档中的所有表格 设置文字自适应
  19627. // 获取文档中的所有表格。
  19628. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  19629. {
  19630. // 遍历表格中的所有行。
  19631. foreach (Aspose.Words.Tables.Row row in table.Rows)
  19632. {
  19633. foreach (Cell cell in row.Cells)
  19634. {
  19635. Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
  19636. cellFormat.Width = 0;
  19637. }
  19638. }
  19639. }
  19640. #endregion
  19641. #region 设置页眉
  19642. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  19643. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  19644. if (System.IO.File.Exists(voucherHeaderPath))
  19645. {
  19646. byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
  19647. //Image image = Image.FromStream(imageBytes, ImageType.Png);
  19648. //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
  19649. Aspose.Words.Drawing.Shape shape = builder.InsertImage(imageBytes);
  19650. // 调整图片位置
  19651. shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
  19652. shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
  19653. shape.Top = 50; // 将图片距离页眉上边缘的距离
  19654. shape.Left = 0; // 将图片距离页面左边缘的距离
  19655. shape.Width = 81; // 设置图片宽度
  19656. shape.Height = 36; // 设置图片高度
  19657. }
  19658. //靠右
  19659. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  19660. //// 设置页脚上下边距
  19661. //builder.PageSetup.HeaderDistance = 42;
  19662. // 添加页眉线
  19663. Aspose.Words.Border borderHeader = null;
  19664. try
  19665. {
  19666. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  19667. }
  19668. catch (Exception e)
  19669. {
  19670. // TODO Auto-generated catch block
  19671. //e.printStackTrace();
  19672. }
  19673. borderHeader.Shadow = true;
  19674. borderHeader.DistanceFromText = 2;
  19675. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  19676. #endregion
  19677. }
  19678. catch (Exception ex)
  19679. {
  19680. }
  19681. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  19682. doc.Save(fileDir);
  19683. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  19684. return Ok(JsonView(true, "操作成功!", Url));
  19685. }
  19686. /// <summary>
  19687. /// 酒店预订
  19688. /// 生成 预定成本 Excel
  19689. /// </summary>
  19690. /// <param name="_dto"></param>
  19691. /// <returns></returns>
  19692. [HttpPost]
  19693. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19694. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  19695. {
  19696. #region 参数验证
  19697. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  19698. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  19699. if (!vadalitorRes.IsValid)
  19700. {
  19701. var errors = new StringBuilder();
  19702. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  19703. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  19704. }
  19705. #region 团组操作权限验证 76 酒店预定模块
  19706. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  19707. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  19708. #endregion
  19709. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19710. #region 页面操作权限验证
  19711. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19712. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  19713. #endregion
  19714. #endregion
  19715. decimal _rate = 1.00M;
  19716. string _currency = string.Empty;
  19717. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  19718. var hrDtas = _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  19719. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  19720. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  19721. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  19722. var _GroupCostParameter = _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).First();
  19723. //if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  19724. if (_GroupCostParameter == null)
  19725. {
  19726. //return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  19727. bool isIntType = int.TryParse(_currency, out int currId);
  19728. if (isIntType)
  19729. {
  19730. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  19731. }
  19732. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  19733. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  19734. if (currInfo == null)
  19735. {
  19736. //return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  19737. }
  19738. else _rate = currInfo.Rate;
  19739. if (!string.IsNullOrEmpty(_currency) && !_currency.ToUpper().Equals("CNY"))
  19740. {
  19741. _rate = _GroupCostParameter.Rate;
  19742. }
  19743. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  19744. //string strFileName = "HotelStatement/";
  19745. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  19746. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  19747. var rateDatas = new List<dynamic>();
  19748. #region 数据处理
  19749. foreach (var item in hrDtas)
  19750. {
  19751. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  19752. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  19753. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  19754. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  19755. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  19756. if (ccpInfo == null || roomInfo == null || breakfastInfo == null || governmentRentInfo == null || cityTaxInfo == null)
  19757. {
  19758. continue;
  19759. }
  19760. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  19761. if (string.IsNullOrEmpty(_currency)) _currency = $"CNY";
  19762. string singleRoomFeeStr = string.Empty,
  19763. doubleRoomFeeStr = string.Empty,
  19764. suiteRoomFeeStr = string.Empty,
  19765. otherRoomFeeStr = string.Empty,
  19766. payMoneyStr = string.Empty,
  19767. cardPriceStr = string.Empty;
  19768. if (roomCurr.Equals("CNY"))
  19769. {
  19770. rateDatas.Add(new { code = "CNY", rate = 1.0000 });
  19771. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  19772. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  19773. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  19774. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  19775. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? ""}";
  19776. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {currDatas.Find(it => it.Id == item.CardPriceCurrency)?.Name ?? ""}";
  19777. }
  19778. else
  19779. {
  19780. //singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  19781. //doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  19782. //suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  19783. //otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  19784. //payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  19785. //cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  19786. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  19787. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  19788. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  19789. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  19790. rateDatas.Add(new { code = roomCurr, rate = roomInfo.Rate });
  19791. var ccpPaymentCurrency = currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? "";
  19792. if (ccpPaymentCurrency.Equals("CNY"))
  19793. {
  19794. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} CNY";
  19795. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  19796. }
  19797. else
  19798. {
  19799. rateDatas.Add(new { code = ccpPaymentCurrency, rate = ccpInfo.DayRate });
  19800. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {ccpPaymentCurrency}\r\n{((ccpInfo.PayMoney * ccpInfo.DayRate) / _rate).ToString("#0.00")} CNY";
  19801. }
  19802. var hotelcardPriceCurrency = currDatas.Find(it => it.Id == item?.CardPriceCurrency)?.Name ?? "";
  19803. if (hotelcardPriceCurrency.Equals("CNY"))
  19804. {
  19805. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  19806. }
  19807. else
  19808. {
  19809. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {hotelcardPriceCurrency}\r\n{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} CNY";
  19810. }
  19811. }
  19812. string breakfastPriceStr = string.Empty,
  19813. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  19814. governmentRentStr = string.Empty,
  19815. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  19816. cityTaxStr = string.Empty,
  19817. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  19818. var breakfastCurrency1 = currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name;
  19819. if (!string.IsNullOrEmpty(breakfastCurrency1))
  19820. {
  19821. if (breakfastCurrency1.Equals("CNY"))
  19822. {
  19823. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  19824. }
  19825. else
  19826. {
  19827. rateDatas.Add(new { code = breakfastCurrency1, rate = breakfastInfo.Rate });
  19828. var breakfastPriceCny = breakfastInfo.Price * breakfastInfo.Rate;
  19829. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}\r\n{breakfastPriceCny.ToString("#0.00")} CNY";
  19830. }
  19831. }
  19832. else breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  19833. var governmentRentCurrency1 = currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name;
  19834. if (!string.IsNullOrEmpty(governmentRentCurrency1))
  19835. {
  19836. if (governmentRentCurrency.Equals("CNY"))
  19837. {
  19838. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  19839. }
  19840. else
  19841. {
  19842. rateDatas.Add(new { code = governmentRentCurrency1, rate = governmentRentInfo.Rate });
  19843. var governmentRentCny = governmentRentInfo.Price * governmentRentInfo.Rate;
  19844. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}\r\n{governmentRentCny.ToString("#0.00")} CNY";
  19845. }
  19846. }
  19847. else governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  19848. var cityTaxStrCurrency1 = currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name;
  19849. if (!string.IsNullOrEmpty(cityTaxStrCurrency1))
  19850. {
  19851. if (cityTaxStrCurrency1.Equals("CNY"))
  19852. {
  19853. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  19854. }
  19855. else
  19856. {
  19857. rateDatas.Add(new { code = cityTaxStrCurrency1, rate = cityTaxInfo.Rate });
  19858. var cityTaxCny = cityTaxInfo.Price * cityTaxInfo.Rate;
  19859. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}\r\n{cityTaxCny.ToString("#0.00")} CNY";
  19860. }
  19861. }
  19862. else cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  19863. int payDId = roomInfo?.PayDId ?? 0;
  19864. pcfds.Add(new HotelReservations_PCFD_View()
  19865. {
  19866. City = item.City,
  19867. HotelName = item.HotelName,
  19868. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  19869. // SingleRoomCount = item.SingleRoomCount,
  19870. SingleRoomPrice = singleRoomFeeStr,
  19871. // DoubleRoomCount = item.DoubleRoomCount,
  19872. DoubleRoomPrice = doubleRoomFeeStr,
  19873. //SuiteRoomCount = item.SuiteRoomCount,
  19874. SuiteRoomPrice = suiteRoomFeeStr,
  19875. OtherRoomPrice = otherRoomFeeStr,
  19876. //OtherRoomCount = item.OtherRoomCount,
  19877. BreakfastPrice = breakfastPriceStr,
  19878. GovernmentRent = governmentRentStr,
  19879. CityTax = cityTaxStr,
  19880. RoomExplanation = item.RoomExplanation,
  19881. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  19882. PayTime = roomInfo?.ConsumptionDate,
  19883. BankNo = roomInfo?.BankNo,
  19884. PayMoney = payMoneyStr,
  19885. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  19886. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  19887. CardPrice = cardPriceStr,
  19888. Remark = ccpInfo.Remark
  19889. });
  19890. }
  19891. #endregion
  19892. //载入模板
  19893. WorkbookDesigner designer = new WorkbookDesigner();
  19894. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  19895. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  19896. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  19897. designer.SetDataSource("TourNo", groupInfo.TourCode);
  19898. var rateDatas1 = rateDatas.Distinct();
  19899. var rateStr = string.Empty;
  19900. foreach (var item in rateDatas1)
  19901. {
  19902. rateStr += $"{item.code} {item.rate.ToString("#0.0000")} \t\t";
  19903. }
  19904. designer.SetDataSource("TeamName", $"酒店模块汇率:{rateStr}");
  19905. designer.SetDataSource("Opertor", userInfo.CnName);
  19906. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  19907. dt.TableName = "ViewMyHotelReservations";
  19908. designer.SetDataSource(dt);
  19909. designer.Process();
  19910. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  19911. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  19912. designer.Workbook.Save(serverPath);
  19913. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  19914. #region 删除指定行
  19915. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  19916. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  19917. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  19918. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  19919. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  19920. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  19921. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  19922. cssIndex = dt.Columns["CityTax"].Ordinal,
  19923. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  19924. remarkIndex = dt.Columns["Remark"].Ordinal;
  19925. //删除指定列
  19926. foreach (DataRow item in dt.Rows)
  19927. {
  19928. string singleStr = item["SingleRoomPrice"].ToString();
  19929. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  19930. if (containsDigitButNotZero1) singleDel = false;
  19931. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  19932. string doubleStr = item["DoubleRoomPrice"].ToString();
  19933. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  19934. if (containsDigitButNotZero2) doubleDel = false;
  19935. string suiteStr = item["SuiteRoomPrice"].ToString();
  19936. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  19937. if (containsDigitButNotZero3) suiteDel = false;
  19938. string otherStr = item["OtherRoomPrice"].ToString();
  19939. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  19940. if (containsDigitButNotZero4) otherDel = false;
  19941. string zcStr = item["BreakfastPrice"].ToString();
  19942. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  19943. if (containsDigitButNotZero5) zcDel = false;
  19944. string dsStr = item["GovernmentRent"].ToString();
  19945. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  19946. if (containsDigitButNotZero6) dsDel = false;
  19947. string cssStr = item["CityTax"].ToString();
  19948. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  19949. if (containsDigitButNotZero7) cssDel = false;
  19950. string cpStr = item["ConsumptionPatterns"].ToString();
  19951. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  19952. string remarkStr = item["Remark"].ToString();
  19953. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  19954. }
  19955. DeleteColumn(serverPath, remarkIndex, remarkDel);
  19956. DeleteColumn(serverPath, cpIndex, cpDel);
  19957. DeleteColumn(serverPath, dsIndex, dsDel);
  19958. DeleteColumn(serverPath, cssIndex, cssDel);
  19959. DeleteColumn(serverPath, zcIndex, zcDel);
  19960. DeleteColumn(serverPath, otherIndex, otherDel);
  19961. DeleteColumn(serverPath, suiteIndex, suiteDel);
  19962. DeleteColumn(serverPath, doubleIndex, doubleDel);
  19963. DeleteColumn(serverPath, singleIndex, singleDel);
  19964. #endregion
  19965. //只保留第一个表格
  19966. DeleteSheet(serverPath);
  19967. return Ok(JsonView(true, "操作成功", url = rst));
  19968. }
  19969. else
  19970. {
  19971. _currency = _GroupCostParameter.Currency;
  19972. bool isIntType = int.TryParse(_currency, out int currId);
  19973. if (isIntType)
  19974. {
  19975. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  19976. }
  19977. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  19978. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  19979. if (currInfo == null)
  19980. {
  19981. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  19982. }
  19983. if (!_currency.ToUpper().Equals("CNY"))
  19984. {
  19985. _rate = _GroupCostParameter.Rate;
  19986. }
  19987. _rate = currInfo.Rate;
  19988. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  19989. //string strFileName = "HotelStatement/";
  19990. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  19991. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  19992. #region 数据处理
  19993. foreach (var item in hrDtas)
  19994. {
  19995. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  19996. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  19997. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  19998. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  19999. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  20000. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  20001. string singleRoomFeeStr = string.Empty,
  20002. doubleRoomFeeStr = string.Empty,
  20003. suiteRoomFeeStr = string.Empty,
  20004. otherRoomFeeStr = string.Empty,
  20005. payMoneyStr = string.Empty,
  20006. cardPriceStr = string.Empty;
  20007. if (roomCurr.Equals(_currency))
  20008. {
  20009. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  20010. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  20011. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  20012. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  20013. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  20014. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  20015. }
  20016. else
  20017. {
  20018. singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  20019. doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  20020. suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  20021. otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  20022. payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  20023. cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  20024. }
  20025. string breakfastPriceStr = string.Empty,
  20026. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  20027. governmentRentStr = string.Empty,
  20028. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  20029. cityTaxStrStr = string.Empty,
  20030. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  20031. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  20032. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  20033. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  20034. int payDId = roomInfo?.PayDId ?? 0;
  20035. pcfds.Add(new HotelReservations_PCFD_View()
  20036. {
  20037. City = item.City,
  20038. HotelName = item.HotelName,
  20039. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  20040. // SingleRoomCount = item.SingleRoomCount,
  20041. SingleRoomPrice = singleRoomFeeStr,
  20042. // DoubleRoomCount = item.DoubleRoomCount,
  20043. DoubleRoomPrice = doubleRoomFeeStr,
  20044. //SuiteRoomCount = item.SuiteRoomCount,
  20045. SuiteRoomPrice = suiteRoomFeeStr,
  20046. OtherRoomPrice = otherRoomFeeStr,
  20047. //OtherRoomCount = item.OtherRoomCount,
  20048. BreakfastPrice = breakfastPriceStr,
  20049. GovernmentRent = governmentRentStr,
  20050. CityTax = cityTaxStrStr,
  20051. RoomExplanation = item.RoomExplanation,
  20052. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  20053. PayTime = roomInfo?.ConsumptionDate,
  20054. BankNo = roomInfo?.BankNo,
  20055. PayMoney = payMoneyStr,
  20056. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  20057. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  20058. CardPrice = cardPriceStr,
  20059. Remark = ccpInfo.Remark
  20060. });
  20061. }
  20062. #endregion
  20063. //载入模板
  20064. WorkbookDesigner designer = new WorkbookDesigner();
  20065. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  20066. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  20067. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  20068. designer.SetDataSource("TourNo", groupInfo.TourCode);
  20069. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  20070. designer.SetDataSource("Opertor", userInfo.CnName);
  20071. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  20072. dt.TableName = "ViewMyHotelReservations";
  20073. designer.SetDataSource(dt);
  20074. designer.Process();
  20075. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  20076. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  20077. designer.Workbook.Save(serverPath);
  20078. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  20079. #region 删除指定行
  20080. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  20081. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  20082. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  20083. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  20084. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  20085. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  20086. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  20087. cssIndex = dt.Columns["CityTax"].Ordinal,
  20088. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  20089. remarkIndex = dt.Columns["Remark"].Ordinal;
  20090. //删除指定列
  20091. foreach (DataRow item in dt.Rows)
  20092. {
  20093. string singleStr = item["SingleRoomPrice"].ToString();
  20094. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  20095. if (containsDigitButNotZero1) singleDel = false;
  20096. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  20097. string doubleStr = item["DoubleRoomPrice"].ToString();
  20098. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  20099. if (containsDigitButNotZero2) doubleDel = false;
  20100. string suiteStr = item["SuiteRoomPrice"].ToString();
  20101. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  20102. if (containsDigitButNotZero3) suiteDel = false;
  20103. string otherStr = item["OtherRoomPrice"].ToString();
  20104. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  20105. if (containsDigitButNotZero4) otherDel = false;
  20106. string zcStr = item["BreakfastPrice"].ToString();
  20107. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  20108. if (containsDigitButNotZero5) zcDel = false;
  20109. string dsStr = item["GovernmentRent"].ToString();
  20110. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  20111. if (containsDigitButNotZero6) dsDel = false;
  20112. string cssStr = item["CityTax"].ToString();
  20113. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  20114. if (containsDigitButNotZero7) cssDel = false;
  20115. string cpStr = item["ConsumptionPatterns"].ToString();
  20116. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  20117. string remarkStr = item["Remark"].ToString();
  20118. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  20119. }
  20120. DeleteColumn(serverPath, remarkIndex, remarkDel);
  20121. DeleteColumn(serverPath, cpIndex, cpDel);
  20122. DeleteColumn(serverPath, dsIndex, dsDel);
  20123. DeleteColumn(serverPath, cssIndex, cssDel);
  20124. DeleteColumn(serverPath, zcIndex, zcDel);
  20125. DeleteColumn(serverPath, otherIndex, otherDel);
  20126. DeleteColumn(serverPath, suiteIndex, suiteDel);
  20127. DeleteColumn(serverPath, doubleIndex, doubleDel);
  20128. DeleteColumn(serverPath, singleIndex, singleDel);
  20129. #endregion
  20130. //只保留第一个表格
  20131. DeleteSheet(serverPath);
  20132. return Ok(JsonView(true, "操作成功", url = rst));
  20133. }
  20134. //return Ok(JsonView(false));
  20135. }
  20136. /// <summary>
  20137. /// 删除指定列
  20138. /// </summary>
  20139. /// <param name="file"></param>
  20140. /// <param name="columnIndex"></param>
  20141. /// <param name="isDel"></param>
  20142. private void DeleteColumn(string file, int columnIndex, bool isDel)
  20143. {
  20144. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  20145. //wb.Save(file);
  20146. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  20147. if (sheet1 != null)
  20148. {
  20149. if (isDel)
  20150. {
  20151. Cells cells = sheet1.Cells;
  20152. cells.DeleteColumn(columnIndex);
  20153. }
  20154. }
  20155. wb.Save(file);
  20156. }
  20157. /// <summary>
  20158. /// 删除sheet
  20159. /// </summary>
  20160. /// <param name="file"></param>
  20161. private void DeleteSheet(string file)
  20162. {
  20163. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  20164. //wb.Save(file);
  20165. List<string> sheets = new List<string>();
  20166. foreach (var item in wb.Worksheets)
  20167. {
  20168. sheets.Add(item.Name);
  20169. }
  20170. if (sheets.Count > 0)
  20171. {
  20172. sheets.RemoveAt(0);//不删除第一个sheet
  20173. foreach (var item in sheets)
  20174. {
  20175. wb.Worksheets.RemoveAt(item);
  20176. }
  20177. }
  20178. wb.Save(file);
  20179. }
  20180. /// <summary>
  20181. /// 酒店预订
  20182. /// 确认单
  20183. /// </summary>
  20184. /// <param name="_dto"></param>
  20185. /// <returns></returns>
  20186. [HttpPost]
  20187. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20188. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  20189. {
  20190. try
  20191. {
  20192. #region 参数验证
  20193. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  20194. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  20195. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  20196. #region 团组操作权限验证 76 酒店预定模块
  20197. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  20198. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  20199. #endregion
  20200. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20201. #region 页面操作权限验证
  20202. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20203. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  20204. #endregion
  20205. #endregion
  20206. //团组信息
  20207. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  20208. //酒店数据
  20209. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  20210. if (listhoteldata.Count < 0)
  20211. {
  20212. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  20213. }
  20214. //利datatable存储
  20215. DataTable dt = new DataTable();
  20216. dt.Columns.Add("CheckInDate", typeof(string));
  20217. dt.Columns.Add("City", typeof(string));
  20218. dt.Columns.Add("Hotel", typeof(string));
  20219. dt.Columns.Add("Room", typeof(string));
  20220. for (int i = 0; i < listhoteldata.Count; i++)
  20221. {
  20222. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  20223. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  20224. while (dayStart < dayEnd)
  20225. {
  20226. string temp = "";
  20227. DataRow row = dt.NewRow();
  20228. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  20229. row["City"] = listhoteldata[i].City;
  20230. row["Hotel"] = listhoteldata[i].HotelName;
  20231. if (listhoteldata[i].SingleRoomCount > 0)
  20232. {
  20233. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  20234. }
  20235. if (listhoteldata[i].DoubleRoomCount > 0)
  20236. {
  20237. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  20238. }
  20239. if (listhoteldata[i].SuiteRoomCount > 0)
  20240. {
  20241. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  20242. }
  20243. if (listhoteldata[i].OtherRoomCount > 0)
  20244. {
  20245. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  20246. }
  20247. row["Room"] = temp;
  20248. dt.Rows.Add(row);
  20249. dayStart = dayStart.AddDays(1);
  20250. }
  20251. }
  20252. Dictionary<string, string> dic = new Dictionary<string, string>();
  20253. dic.Add("Dele", di.TeamName);
  20254. dic.Add("City", di.VisitCountry);
  20255. //模板路径
  20256. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  20257. //载入模板
  20258. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  20259. DocumentBuilder builder = new DocumentBuilder(doc);
  20260. foreach (var key in dic.Keys)
  20261. {
  20262. builder.MoveToBookmark(key);
  20263. builder.Write(dic[key]);
  20264. }
  20265. //获取word里所有表格
  20266. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  20267. //获取所填表格的序数
  20268. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  20269. var rowStart = tableOne.Rows[0]; //获取第1行
  20270. //循环赋值
  20271. for (int i = 0; i < dt.Rows.Count; i++)
  20272. {
  20273. builder.MoveToCell(0, i + 1, 0, 0);
  20274. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  20275. builder.MoveToCell(0, i + 1, 1, 0);
  20276. builder.Write(dt.Rows[i]["City"].ToString());
  20277. builder.MoveToCell(0, i + 1, 2, 0);
  20278. builder.Write(dt.Rows[i]["Hotel"].ToString());
  20279. builder.MoveToCell(0, i + 1, 3, 0);
  20280. builder.Write(dt.Rows[i]["Room"].ToString());
  20281. }
  20282. //删除多余行
  20283. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  20284. {
  20285. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  20286. }
  20287. string strFileName = di.TeamName + "酒店确认单.doc";
  20288. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  20289. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  20290. return Ok(JsonView(true, "成功", url));
  20291. }
  20292. catch (Exception ex)
  20293. {
  20294. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  20295. }
  20296. }
  20297. #endregion
  20298. #region 团组状态
  20299. /// <summary>
  20300. /// 团组状态列表 Page
  20301. /// </summary>
  20302. /// <param name="dto">团组列表请求dto</param>
  20303. /// <returns></returns>
  20304. [HttpPost]
  20305. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20306. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  20307. {
  20308. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  20309. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  20310. {
  20311. string sqlWhere = string.Empty;
  20312. if (dto.IsSure == 0) //未完成
  20313. {
  20314. sqlWhere += string.Format(@" And IsSure = 0");
  20315. }
  20316. else if (dto.IsSure == 1) //已完成
  20317. {
  20318. sqlWhere += string.Format(@" And IsSure = 1");
  20319. }
  20320. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  20321. {
  20322. string tj = dto.SearchCriteria;
  20323. 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}%')",
  20324. tj, tj, tj, tj, tj);
  20325. }
  20326. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  20327. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  20328. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  20329. From (
  20330. Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
  20331. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  20332. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  20333. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  20334. From Grp_DelegationInfo gdi
  20335. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  20336. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  20337. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  20338. Where gdi.IsDel = 0 {0}
  20339. ) temp ", sqlWhere);
  20340. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  20341. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  20342. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  20343. }
  20344. else
  20345. {
  20346. return Ok(JsonView(false, "查询失败"));
  20347. }
  20348. }
  20349. /// <summary>
  20350. /// 团组状态
  20351. /// 设置操作完成
  20352. /// </summary>
  20353. /// <param name="dto">团组列表请求dto</param>
  20354. /// <returns></returns>
  20355. [HttpPost]
  20356. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20357. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  20358. {
  20359. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  20360. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  20361. {
  20362. Id = dto.Id,
  20363. IsSure = 1
  20364. };
  20365. var result = await _sqlSugar.Updateable(_DelegationInfo)
  20366. .UpdateColumns(it => new { it.IsSure })
  20367. .WhereColumns(it => new { it.Id })
  20368. .ExecuteCommandAsync();
  20369. if (result > 0)
  20370. {
  20371. return Ok(JsonView(true, "操作完成!"));
  20372. }
  20373. return Ok(JsonView(false, "操作失败!"));
  20374. }
  20375. #endregion
  20376. #region 保险费用录入
  20377. /// <summary>
  20378. /// 根据团组Id查询保险费用列表
  20379. /// </summary>
  20380. /// <param name="dto"></param>
  20381. /// <returns></returns>
  20382. [HttpPost]
  20383. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20384. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  20385. {
  20386. Result groupData = await _customersRep.CustomersByDiId(dto);
  20387. if (groupData.Code != 0)
  20388. {
  20389. return Ok(JsonView(false, groupData.Msg));
  20390. }
  20391. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  20392. }
  20393. /// <summary>
  20394. /// 根据保险费用Id查询保险费用详细
  20395. /// </summary>
  20396. /// <param name="dto"></param>
  20397. /// <returns></returns>
  20398. [HttpPost]
  20399. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20400. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  20401. {
  20402. try
  20403. {
  20404. Result groupData = await _customersRep.CustomersById(dto);
  20405. if (groupData.Code != 0)
  20406. {
  20407. return Ok(JsonView(false, groupData.Msg));
  20408. }
  20409. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  20410. }
  20411. catch (Exception ex)
  20412. {
  20413. return Ok(JsonView(false, ex.Message));
  20414. }
  20415. }
  20416. /// <summary>
  20417. /// 保险费用录入页面初始化绑定
  20418. /// </summary>
  20419. /// <param name="dto"></param>
  20420. /// <returns></returns>
  20421. [HttpPost]
  20422. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20423. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  20424. {
  20425. try
  20426. {
  20427. Result groupData = await _customersRep.CustomersInitialize(dto);
  20428. if (groupData.Code != 0)
  20429. {
  20430. return Ok(JsonView(false, groupData.Msg));
  20431. }
  20432. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  20433. }
  20434. catch (Exception ex)
  20435. {
  20436. return Ok(JsonView(false, ex.Message));
  20437. }
  20438. }
  20439. /// <summary>
  20440. /// 保险费用操作(Status:1.新增,2.修改)
  20441. /// </summary>
  20442. /// <param name="dto"></param>
  20443. /// <returns></returns>
  20444. [HttpPost]
  20445. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20446. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  20447. {
  20448. Result groupData = await _customersRep.OpCustomers(dto);
  20449. if (groupData.Code != 0)
  20450. {
  20451. return Ok(JsonView(false, groupData.Msg));
  20452. }
  20453. #region 应用推送
  20454. try
  20455. {
  20456. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  20457. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  20458. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  20459. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  20460. //自动审核
  20461. await _feeAuditRep.FeeAutomaticAudit(4, dto.DiId, dataId);
  20462. //2024-10-21 新增LZ UID
  20463. var userIds = new List<int>() { 21 };
  20464. string title = $"系统通知";
  20465. var diId = dto.DiId;
  20466. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  20467. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  20468. string content = "";
  20469. if (dto.Status == 1) content = $"[新增-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  20470. else if (dto.Status == 2) content = $"[更新-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  20471. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  20472. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "82" };
  20473. await APNsTools.iOS_PushNotifications1("051", "保险费用审核", "", content, true, "ExpenseAuditWebView", h5);
  20474. }
  20475. catch (Exception ex)
  20476. {
  20477. }
  20478. #endregion
  20479. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  20480. }
  20481. /// <summary>
  20482. /// 保险文件上传
  20483. /// </summary>
  20484. /// <param name="file"></param>
  20485. /// <returns></returns>
  20486. [HttpPost]
  20487. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20488. public async Task<IActionResult> UploadCus(IFormFile file)
  20489. {
  20490. try
  20491. {
  20492. if (file != null)
  20493. {
  20494. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  20495. //文件名称
  20496. string projectFileName = file.FileName;
  20497. //上传的文件的路径
  20498. string filePath = "";
  20499. if (!Directory.Exists(fileDir))
  20500. {
  20501. Directory.CreateDirectory(fileDir);
  20502. }
  20503. //上传的文件的路径
  20504. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  20505. using (FileStream fs = System.IO.File.Create(filePath))
  20506. {
  20507. file.CopyTo(fs);
  20508. fs.Flush();
  20509. }
  20510. return Ok(JsonView(true, "上传成功!", projectFileName));
  20511. }
  20512. else
  20513. {
  20514. return Ok(JsonView(false, "上传失败!"));
  20515. }
  20516. }
  20517. catch (Exception ex)
  20518. {
  20519. return Ok(JsonView(false, ex.Message));
  20520. }
  20521. }
  20522. /// <summary>
  20523. /// 保险删除指定文件
  20524. /// </summary>
  20525. /// <param name="dto"></param>
  20526. /// <returns></returns>
  20527. [HttpPost]
  20528. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20529. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  20530. {
  20531. try
  20532. {
  20533. string filePath = "";
  20534. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  20535. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  20536. //int id = 0;
  20537. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  20538. // 删除该文件
  20539. try
  20540. {
  20541. System.IO.File.Delete(filePath);
  20542. 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()
  20543. {
  20544. Attachment = "",
  20545. }).ExecuteCommandAsync();
  20546. if (result != 0)
  20547. {
  20548. return Ok(JsonView(true, "成功!"));
  20549. }
  20550. else
  20551. {
  20552. return Ok(JsonView(false, "失败!"));
  20553. }
  20554. }
  20555. catch (Exception)
  20556. {
  20557. 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()
  20558. {
  20559. Attachment = "",
  20560. }).ExecuteCommandAsync();
  20561. if (result != 0)
  20562. {
  20563. return Ok(JsonView(true, "成功!"));
  20564. }
  20565. else
  20566. {
  20567. return Ok(JsonView(false, "失败!"));
  20568. }
  20569. }
  20570. }
  20571. catch (Exception ex)
  20572. {
  20573. return Ok(JsonView(false, "程序错误!"));
  20574. throw;
  20575. }
  20576. }
  20577. /// <summary>
  20578. /// 保险费用操作(删除)
  20579. /// </summary>
  20580. /// <param name="dto"></param>
  20581. /// <returns></returns>
  20582. [HttpPost]
  20583. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20584. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  20585. {
  20586. try
  20587. {
  20588. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  20589. if (!res)
  20590. {
  20591. return Ok(JsonView(false, "删除失败"));
  20592. }
  20593. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  20594. {
  20595. IsDel = 1,
  20596. DeleteUserId = dto.DeleteUserId,
  20597. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  20598. }).ExecuteCommandAsync();
  20599. return Ok(JsonView(true, "删除成功!"));
  20600. }
  20601. catch (Exception ex)
  20602. {
  20603. return Ok(JsonView(false, "程序错误!"));
  20604. throw;
  20605. }
  20606. }
  20607. #endregion
  20608. #region 接团客户名单 PageId 104
  20609. /// <summary>
  20610. /// 接团客户名单
  20611. /// 迁移数据(慎用!)
  20612. /// </summary>
  20613. /// <returns></returns>
  20614. [HttpPost]
  20615. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20616. public async Task<IActionResult> PostTourClientListChange()
  20617. {
  20618. try
  20619. {
  20620. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  20621. //var groupClinetData1
  20622. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  20623. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  20624. int updateCount = 0;
  20625. if (oldOAClientList.Count > 0)
  20626. {
  20627. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  20628. _sqlSugar.BeginTran();
  20629. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  20630. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  20631. foreach (var item in oldOAClientList)
  20632. {
  20633. int comId = 0;
  20634. string format = "yyyy-MM-dd HH:mm:ss";
  20635. string data11 = "1990-01-01 00:00";
  20636. var data1 = IsValidDate(item.OPdate, format);
  20637. if (data1) data11 = item.OPdate;
  20638. //客户公司验证
  20639. if (!string.IsNullOrEmpty(item.Company))
  20640. {
  20641. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  20642. if (clientComInfo == null) // add
  20643. {
  20644. var addInfo = new Crm_CustomerCompany()
  20645. {
  20646. CompanyAbbreviation = "",
  20647. CompanyFullName = item.Company,
  20648. Address = "",
  20649. PostCodes = "",
  20650. LastedOpUserId = item.OPer,
  20651. LastedOpDt = Convert.ToDateTime(data11),
  20652. CreateUserId = item.OPer,
  20653. CreateTime = Convert.ToDateTime(data11),
  20654. IsDel = 0
  20655. };
  20656. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  20657. if (comId1 > 0) comId = comId1;
  20658. }
  20659. else comId = clientComInfo.Id;
  20660. }
  20661. //客户人员验证
  20662. int clientId = 0;
  20663. string name = item.LastName + item.Name;
  20664. if (!string.IsNullOrEmpty(name))
  20665. {
  20666. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  20667. if (clientInfo == null)
  20668. {
  20669. DateTime? dateTime = null;
  20670. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  20671. if (isDt) dateTime = birthDayDt;
  20672. var addInfo1 = new Crm_DeleClient()
  20673. {
  20674. CrmCompanyId = comId,
  20675. DiId = -1,
  20676. LastName = item.LastName,
  20677. FirstName = item.Name,
  20678. OldName = "",
  20679. Pinyin = item.Pinyin,
  20680. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  20681. Marriage = 0,
  20682. Phone = item.Phone,
  20683. Job = item.Job,
  20684. BirthDay = dateTime
  20685. };
  20686. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  20687. if (clientId1 > 0) clientId = clientId1;
  20688. }
  20689. else clientId = clientInfo.Id;
  20690. }
  20691. if (clientId < 1)
  20692. {
  20693. continue;
  20694. }
  20695. int airType = 0;
  20696. if (item.AirType == "超经舱") airType = 459;
  20697. else if (item.AirType == "公务舱") airType = 458;
  20698. else if (item.AirType == "经济舱") airType = 460;
  20699. else if (item.AirType == "其他") airType = 565;
  20700. else if (item.AirType == "头等舱") airType = 457;
  20701. var _TourClientListEntity = new Grp_TourClientList()
  20702. {
  20703. DiId = item.Diid,
  20704. ClientId = clientId,
  20705. CreateUserId = item.OPer,
  20706. CreateTime = Convert.ToDateTime(data11),
  20707. Remark = item.Remark,
  20708. IsDel = item.Isdel,
  20709. ShippingSpaceTypeId = airType,
  20710. ShippingSpaceSpecialNeeds = item.AirRemark,
  20711. HotelSpecialNeeds = item.RoomType
  20712. };
  20713. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  20714. if (_TourClientList > 0)
  20715. {
  20716. updateCount++;
  20717. }
  20718. }
  20719. _sqlSugar.CommitTran();
  20720. }
  20721. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  20722. }
  20723. catch (Exception ex)
  20724. {
  20725. _sqlSugar.RollbackTran();
  20726. return Ok(JsonView(false, ex.Message));
  20727. }
  20728. //return Ok(JsonView(true));
  20729. }
  20730. private bool IsValidDate(string dateString, string format)
  20731. {
  20732. return DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime dateValue);
  20733. }
  20734. /// <summary>
  20735. /// 接团客户名单
  20736. /// 根据团组Id查询List
  20737. /// </summary>
  20738. /// <param name="_dto"></param>
  20739. /// <returns></returns>
  20740. [HttpPost]
  20741. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20742. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  20743. {
  20744. #region 参数验证
  20745. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  20746. if (_dto.PageId != 104) _dto.PageId = 104; //接团客户名单PageId
  20747. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  20748. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20749. #region 页面操作权限验证
  20750. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20751. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  20752. #endregion
  20753. #endregion
  20754. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  20755. if (viewData.Code != 0)
  20756. {
  20757. return Ok(JsonView(false, viewData.Msg));
  20758. }
  20759. return Ok(JsonView(viewData.Data));
  20760. }
  20761. /// <summary>
  20762. /// 接团客户名单
  20763. /// 基础数据 Init
  20764. /// </summary>
  20765. /// <param name="_dto"></param>
  20766. /// <returns></returns>
  20767. [HttpPost]
  20768. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20769. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  20770. {
  20771. #region 参数验证
  20772. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  20773. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  20774. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20775. #region 页面操作权限验证
  20776. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20777. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  20778. #endregion
  20779. #endregion
  20780. return Ok(await _tourClientListRep._BasicDataInit(_dto.PortType));
  20781. }
  20782. /// <summary>
  20783. /// 接团客户名单
  20784. /// 根据 Id查询 Details
  20785. /// </summary>
  20786. /// <param name="_dto"></param>
  20787. /// <returns></returns>
  20788. [HttpPost]
  20789. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20790. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  20791. {
  20792. #region 参数验证
  20793. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  20794. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  20795. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  20796. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20797. #region 页面操作权限验证
  20798. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20799. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  20800. #endregion
  20801. #endregion
  20802. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  20803. if (viewData.Code != 0)
  20804. {
  20805. return Ok(JsonView(false, viewData.Msg));
  20806. }
  20807. return Ok(JsonView(viewData.Data));
  20808. }
  20809. /// <summary>
  20810. /// 接团客户名单
  20811. /// Add Or Edit
  20812. /// </summary>
  20813. /// <param name="_dto"></param>
  20814. /// <returns></returns>
  20815. [HttpPost]
  20816. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20817. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  20818. {
  20819. #region 参数验证
  20820. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  20821. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  20822. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  20823. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20824. #region 页面操作权限验证
  20825. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20826. if (_dto.Id == 0) //添加
  20827. {
  20828. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  20829. }
  20830. else if (_dto.Id >= 0) //修改
  20831. {
  20832. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  20833. }
  20834. #endregion
  20835. #endregion
  20836. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  20837. if (viewData.Code != 0)
  20838. {
  20839. return Ok(JsonView(false, viewData.Msg));
  20840. }
  20841. return Ok(JsonView(true));
  20842. }
  20843. /// <summary>
  20844. /// 接团客户名单
  20845. /// json字符串 AddMultiple(添加多个)
  20846. /// </summary>
  20847. /// <param name="_dto"></param>
  20848. /// <returns></returns>
  20849. [HttpPost]
  20850. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20851. public async Task<IActionResult> PostTourClientListJsonFormatAddMultiple(PostTourClientListJsonFormatAddMultipleDto _dto)
  20852. {
  20853. #region 参数验证
  20854. string jsonLabel = _dto.JsonLabel;
  20855. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  20856. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  20857. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20858. #region 页面操作权限验证
  20859. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20860. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  20861. #endregion
  20862. #endregion
  20863. var request = new TourClientListAddMultipleDto();
  20864. request.DiId = _dto.DiId;
  20865. request.UserId = _dto.UserId;
  20866. if (!CommonFun.IsValidJson(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数不是合法的json格式!"));
  20867. if (string.IsNullOrEmpty(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数值不能为空"));
  20868. List<TourClientListInfoCN> datas = JsonConvert.DeserializeObject<List<TourClientListInfoCN>>(jsonLabel);
  20869. if (!datas.Any()) return Ok(JsonView(false, "JsonLabel参数值不能为空!"));
  20870. var infos = new List<TourClientListInfo>();
  20871. foreach (var data in datas)
  20872. {
  20873. (string lastName, string firstName) = CommonFun.GetLastNameAndFirstName(data.Name);
  20874. string lastNameEn = CommonFun.ConvertToPinyin(lastName),
  20875. firstNameEn = CommonFun.ConvertToPinyin(lastName);
  20876. if (string.IsNullOrEmpty(lastNameEn) || string.IsNullOrEmpty(firstNameEn))
  20877. {
  20878. continue;
  20879. }
  20880. infos.Add(new TourClientListInfo()
  20881. {
  20882. IsAccompany = 1,
  20883. LastName = lastName,
  20884. FirstName = firstName,
  20885. Pinyin = lastNameEn + @"/" + firstNameEn,
  20886. Sex = data.Sex.Equals("男") ? 0 : data.Sex.Equals("女") ? 1 : 2,
  20887. CompanyFullName = data.CompanyFullName,
  20888. Job = data.Job
  20889. });
  20890. }
  20891. if (infos.Any())
  20892. {
  20893. var viewData = await _tourClientListRep._AddMultiple(request);
  20894. if (viewData.Code != 0)
  20895. {
  20896. return Ok(JsonView(false, viewData.Msg));
  20897. }
  20898. return Ok(JsonView(true));
  20899. }
  20900. return Ok(JsonView(false));
  20901. }
  20902. /// <summary>
  20903. /// 接团客户名单
  20904. /// AddMultiple(添加多个)
  20905. /// </summary>
  20906. /// <param name="_dto"></param>
  20907. /// <returns></returns>
  20908. [HttpPost]
  20909. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20910. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  20911. {
  20912. #region 参数验证
  20913. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  20914. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  20915. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20916. #region 页面操作权限验证
  20917. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20918. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  20919. #endregion
  20920. #endregion
  20921. var viewData = await _tourClientListRep._AddMultiple(_dto);
  20922. if (viewData.Code != 0)
  20923. {
  20924. return Ok(JsonView(false, viewData.Msg));
  20925. }
  20926. return Ok(JsonView(true));
  20927. }
  20928. /// <summary>
  20929. /// 接团客户名单
  20930. /// Del
  20931. /// </summary>
  20932. /// <param name="_dto"></param>
  20933. /// <returns></returns>
  20934. [HttpPost]
  20935. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20936. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  20937. {
  20938. #region 参数验证
  20939. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  20940. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  20941. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20942. #region 页面操作权限验证
  20943. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20944. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  20945. #endregion
  20946. #endregion
  20947. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  20948. if (viewData.Code != 0)
  20949. {
  20950. return Ok(JsonView(false, viewData.Msg));
  20951. }
  20952. return Ok(JsonView(true));
  20953. }
  20954. /// <summary>
  20955. /// 接团客户名单
  20956. /// 文件下载 客户名单
  20957. /// </summary>
  20958. /// <param name="_dto"></param>
  20959. /// <returns></returns>
  20960. [HttpPost]
  20961. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20962. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  20963. {
  20964. #region 参数验证
  20965. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  20966. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  20967. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  20968. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20969. #region 页面操作权限验证
  20970. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20971. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  20972. #endregion
  20973. #endregion
  20974. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  20975. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  20976. From Grp_TourClientList tcl
  20977. Left Join
  20978. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  20979. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  20980. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  20981. From Crm_DeleClient dc
  20982. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  20983. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  20984. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  20985. Where dc.IsDel = 0) temp
  20986. On temp.DcId =tcl.ClientId
  20987. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  20988. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  20989. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  20990. //载入模板
  20991. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  20992. if (_dto.Language == 1)
  20993. {
  20994. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  20995. }
  20996. //载入模板
  20997. var doc = new Document(tempPath);
  20998. DocumentBuilder builder = new DocumentBuilder(doc);
  20999. //获取word里所有表格
  21000. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  21001. //获取所填表格的序数
  21002. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  21003. var rowStart = tableOne.Rows[0]; //获取第1行
  21004. if (_dto.Language == 0)
  21005. {
  21006. //循环赋值
  21007. for (int i = 0; i < DcList.Count; i++)
  21008. {
  21009. EncryptionProcessor.DecryptProperties(DcList[i]);
  21010. builder.MoveToCell(0, i + 1, 0, 0);
  21011. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  21012. builder.MoveToCell(0, i + 1, 1, 0);
  21013. int sex = DcList[i].Sex;
  21014. string sexStr = string.Empty;
  21015. if (sex == 0) sexStr = "男";
  21016. else if (sex == 1) sexStr = "女";
  21017. else sexStr = "未设置";
  21018. builder.Write(sexStr);
  21019. builder.MoveToCell(0, i + 1, 2, 0);
  21020. string birthDay = DcList[i].BirthDay;
  21021. string birthDayStr = string.Empty;
  21022. if (!string.IsNullOrEmpty(birthDay))
  21023. {
  21024. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  21025. }
  21026. builder.Write(birthDayStr);
  21027. builder.MoveToCell(0, i + 1, 3, 0);
  21028. string company = "";
  21029. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  21030. {
  21031. company = DcList[i].CompanyFullName.ToString();
  21032. }
  21033. builder.Write(company);
  21034. builder.MoveToCell(0, i + 1, 4, 0);
  21035. builder.Write(DcList[i].Job);
  21036. }
  21037. }
  21038. else if (_dto.Language == 1)
  21039. {
  21040. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  21041. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  21042. List<string> transArrayStr = new List<string>();
  21043. string transStrRes1 = "";
  21044. var clientEnglishs = new List<ClientEnglishView>();
  21045. for (int i = 0; i < DcList.Count; i++)
  21046. {
  21047. var dc = DcList[i];
  21048. EncryptionProcessor.DecryptProperties(dc);
  21049. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  21050. if (dc.Job.Equals("暂无")) dc.Job = "-";
  21051. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  21052. if (DcList.Count - 1 == i) transStrRes1 += str1;
  21053. else transStrRes1 += $"{str1}|";
  21054. clientEnglishs.Add(new()
  21055. {
  21056. Id = dc.Id,
  21057. LastName = dc.LastName,
  21058. FirstName = dc.FirstName,
  21059. Pinyin = dc.Pinyin,
  21060. Sex = dc.Sex,
  21061. CompanyFullName = dc.CompanyFullName,
  21062. Job = dc.Job,
  21063. IDCardNo = dc.IDCardNo,
  21064. BirthDay = dc.BirthDay,
  21065. });
  21066. }
  21067. #region AI转英文
  21068. string jsonValue = JsonConvert.SerializeObject(clientEnglishs);
  21069. string text = @"将此JSON的中文部分全部翻译为英文,然后只给出修改后的JSON数据,不要其他任何文字";
  21070. List<SeedMessages> messages = new List<SeedMessages>()
  21071. {
  21072. new SeedMessages
  21073. {
  21074. Role = KimiRole.user,
  21075. Content = jsonValue + text
  21076. }
  21077. };
  21078. KiMiApiClient client = new KiMiApiClient();
  21079. var kimiApiResult = await client.SeedMessage(messages);
  21080. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  21081. string clients = kimiApiResult_JObject["content"].ToString();
  21082. string startStr = "```json", endStr = "```";
  21083. // 判断并清除开头部分
  21084. if (clients.StartsWith(startStr))
  21085. {
  21086. clients = clients.Remove(0, startStr.Length);
  21087. }
  21088. // 判断并清除结尾部分
  21089. if (clients.EndsWith(endStr))
  21090. {
  21091. clients = clients.Remove(clients.Length - endStr.Length);
  21092. }
  21093. var en_Json = JsonConvert.DeserializeObject<List<ClientEnglishView>>(clients);
  21094. //循环赋值
  21095. for (int i = 0; i < en_Json.Count; i++)
  21096. {
  21097. var dc = en_Json[i];
  21098. var dc1 = DcList.Find(x => x.Id == dc.Id);
  21099. string PYName = dc.FirstName + " " + dc.LastName;
  21100. builder.MoveToCell(0, i + 1, 0, 0);
  21101. builder.Write(PYName);
  21102. string sex = dc.Sex == 0 ? "Male" : dc.Sex == 1 ? "Female" : "";
  21103. builder.MoveToCell(0, i + 1, 1, 0);
  21104. builder.Write(sex);
  21105. DateTime birthDt;
  21106. bool b_birth = DateTime.TryParse(dc.BirthDay, out birthDt);
  21107. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  21108. builder.MoveToCell(0, i + 1, 2, 0);
  21109. builder.Write(birthday);
  21110. string company = string.Empty, job = string.Empty;
  21111. company = dc.CompanyFullName;
  21112. job = dc.Job;
  21113. if (dc1 != null && !string.IsNullOrEmpty(dc1.CompanyFullName))
  21114. {
  21115. //查询对照表
  21116. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(dc1.CompanyFullName.ToString().Trim()));
  21117. if (tempCec != null)
  21118. {
  21119. company = tempCec.enName;
  21120. }
  21121. }
  21122. builder.MoveToCell(0, i + 1, 3, 0);
  21123. builder.Write(company);
  21124. if (dc1 != null && !string.IsNullOrEmpty(dc1.Job))
  21125. {
  21126. //查询对照表
  21127. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == dc1.Job.ToString().Trim());
  21128. if (tempPec != null)
  21129. {
  21130. job = tempPec.enName;
  21131. }
  21132. }
  21133. builder.MoveToCell(0, i + 1, 4, 0);
  21134. builder.Write(job);
  21135. }
  21136. #endregion
  21137. #region 旧翻译英文处理
  21138. ////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";
  21139. //string transStrRes = "";
  21140. //if (transStrRes1.Length > 0)
  21141. //{
  21142. // transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  21143. //}
  21144. ////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
  21145. ////await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  21146. ////List<string> transArray = new List<string> { };
  21147. //List<TranslateInfo> transArray = new List<TranslateInfo>();
  21148. //if (transStrRes.Contains("|"))
  21149. //{
  21150. // string[] transArray1 = transStrRes.Split('|');
  21151. // if (transArray1.Length > 0)
  21152. // {
  21153. // foreach (var item in transArray1)
  21154. // {
  21155. // if (item.Contains("&"))
  21156. // {
  21157. // string[] transArray2 = item.Split('&');
  21158. // int index = 0;
  21159. // string companyName = "", job = "";
  21160. // if (transArray2.Length > 0)
  21161. // {
  21162. // bool success = int.TryParse(transArray2[0].Trim(), out index);
  21163. // if (1 < transArray2.Length) companyName = transArray2[1];
  21164. // if (2 < transArray2.Length) job = transArray2[2];
  21165. // }
  21166. // transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  21167. // }
  21168. // }
  21169. // }
  21170. //}
  21171. ////循环赋值
  21172. //for (int i = 0; i < DcList.Count; i++)
  21173. //{
  21174. // string PYName = "";
  21175. // if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  21176. // {
  21177. // string PY_Last = DcList[i].Pinyin.Split('/')[0];
  21178. // string PY_First = DcList[i].Pinyin.Split('/')[1];
  21179. // PYName = PY_First + " " + PY_Last;
  21180. // }
  21181. // else
  21182. // {
  21183. // string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  21184. // string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  21185. // PYName = PY_First + " " + PY_Last;
  21186. // }
  21187. // builder.MoveToCell(0, i + 1, 0, 0);
  21188. // builder.Write(PYName);
  21189. // string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  21190. // builder.MoveToCell(0, i + 1, 1, 0);
  21191. // builder.Write(sex);
  21192. // DateTime birthDt;
  21193. // bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  21194. // string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  21195. // builder.MoveToCell(0, i + 1, 2, 0);
  21196. // builder.Write(birthday);
  21197. // string company = string.Empty, job = string.Empty;
  21198. // var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  21199. // if (dcTransInfo != null)
  21200. // {
  21201. // company = dcTransInfo.CompanyName;
  21202. // job = dcTransInfo.Job;
  21203. // }
  21204. // if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  21205. // {
  21206. // //查询对照表
  21207. // Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  21208. // if (tempCec != null)
  21209. // {
  21210. // company = tempCec.enName;
  21211. // }
  21212. // //翻译
  21213. // else
  21214. // {
  21215. // }
  21216. // }
  21217. // builder.MoveToCell(0, i + 1, 3, 0);
  21218. // builder.Write(company);
  21219. // if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  21220. // {
  21221. // //查询对照表
  21222. // Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  21223. // if (tempPec != null)
  21224. // {
  21225. // job = tempPec.enName;
  21226. // }
  21227. // //翻译
  21228. // else
  21229. // {
  21230. // }
  21231. // }
  21232. // builder.MoveToCell(0, i + 1, 4, 0);
  21233. // builder.Write(job);
  21234. //}
  21235. #endregion
  21236. }
  21237. //删除多余行
  21238. while (tableOne.Rows.Count > DcList.Count + 1)
  21239. {
  21240. tableOne.Rows.RemoveAt(DcList.Count + 1);
  21241. }
  21242. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  21243. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  21244. doc.Save(fileDir);
  21245. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  21246. return Ok(JsonView(true, "操作成功!", Url));
  21247. }
  21248. private class TranslateInfo
  21249. {
  21250. public int Index { get; set; }
  21251. public string CompanyName { get; set; }
  21252. public string Job { get; set; }
  21253. }
  21254. [HttpPost]
  21255. public async Task<IActionResult> FileReadClient(List<IFormFile> files)
  21256. {
  21257. if (files.Count == 0)
  21258. {
  21259. return Ok(JsonView(false, "文件为空"));
  21260. }
  21261. KiMiApiClient KiMiApi = new KiMiApiClient();
  21262. var seedConter = await KiMiApi.UploadFilesAsync(files);
  21263. if (seedConter.Count == 0)
  21264. {
  21265. return Ok(JsonView(false, "上传结果为空!"));
  21266. }
  21267. var messages = new List<SeedMessages>
  21268. {
  21269. new SeedMessages { Role = KimiRole.system, Content = "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长中文和英文的对话。你会为用户提供安全,有帮助,准确的回答。同时,你会拒绝一切涉及恐怖主义,种族歧视,黄色暴力等问题的回答。Moonshot AI 为专有名词,不可翻译成其他语言。" },
  21270. new SeedMessages { Role = KimiRole.user, Content = "根据文件内容 ,按照“姓、名、姓名拼音、性别、单位、职务、出生日期”的json格式来排列整理(性别和出生日期通过身份证来识别 , 当识别到性别为男时值给0女给1 未识别到性别的情况下值给-1,出生日期按照yyyy-MM-dd来整理(若出生日期没有值则为‘-’),文件存在拼音的情况读取对应的拼音不存在则设置拼音为中文名字全拼),只输出JSON数组数据 从'['开始 到']'结尾 ,不要除JSON数据外的任何文字以及符号" }
  21271. };
  21272. messages.InsertRange(1, seedConter);
  21273. var kimiApiResult = await KiMiApi.SeedMessage(messages);
  21274. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  21275. string clients = kimiApiResult_JObject["content"].ToString();
  21276. string startStr = "```json", endStr = "```";
  21277. // 判断并清除开头部分
  21278. if (clients.StartsWith(startStr))
  21279. {
  21280. clients = clients.Remove(0, startStr.Length);
  21281. }
  21282. // 判断并清除结尾部分
  21283. if (clients.EndsWith(endStr))
  21284. {
  21285. clients = clients.Remove(clients.Length - endStr.Length);
  21286. }
  21287. var clients_JObject = JsonConvert.DeserializeObject<List<JObject>>(clients);
  21288. Dictionary<string, string> clientFieldMap = new Dictionary<string, string>()
  21289. {
  21290. {"姓", "LastName" },
  21291. {"名", "FirstName" },
  21292. {"姓名拼音", "Pinyin" },
  21293. {"性别", "Sex" },
  21294. {"单位", "CompanyFullName" },
  21295. {"职务", "Job" },
  21296. {"出生日期", "Birthday" },
  21297. };
  21298. List<BaiduClientOCRView> crmClients = new List<BaiduClientOCRView>();
  21299. foreach (var item in clients_JObject)
  21300. {
  21301. BaiduClientOCRView cdc = new BaiduClientOCRView();
  21302. foreach (var field in clientFieldMap.Keys)
  21303. {
  21304. if (item.TryGetValue(field, out JToken value))
  21305. {
  21306. var getValue = value.ToString();
  21307. System.Type type = cdc.GetType();
  21308. PropertyInfo propertyInfo = type.GetProperty(clientFieldMap[field]);
  21309. var propertyValue = Convert.ChangeType(getValue, propertyInfo.PropertyType);
  21310. propertyInfo.SetValue(cdc, propertyValue);
  21311. }
  21312. }
  21313. crmClients.Add(cdc);
  21314. }
  21315. return Ok(JsonView(new
  21316. {
  21317. fileCount = files.Count,
  21318. UploadCount = seedConter.Count,
  21319. ApiResult = clients,
  21320. CrmClients = crmClients
  21321. }));
  21322. }
  21323. #endregion
  21324. #region 团组倒推表
  21325. /// <summary>
  21326. /// 倒推表基础数据
  21327. /// Init
  21328. /// </summary>
  21329. /// <returns></returns>
  21330. [HttpPost]
  21331. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21332. public async Task<IActionResult> PostInvertedListInit()
  21333. {
  21334. var viewData = await _invertedListRep._Init();
  21335. if (viewData.Code != 0)
  21336. {
  21337. return Ok(JsonView(false, viewData.Msg));
  21338. }
  21339. return Ok(JsonView(viewData.Data));
  21340. }
  21341. /// <summary>
  21342. /// 倒推表
  21343. /// Info
  21344. /// </summary>
  21345. /// <param name="dto"></param>
  21346. /// <returns></returns>
  21347. [HttpPost]
  21348. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21349. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  21350. {
  21351. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  21352. if (viewData.Code != 0)
  21353. {
  21354. return Ok(JsonView(false, viewData.Msg));
  21355. }
  21356. return Ok(JsonView(viewData.Data));
  21357. }
  21358. /// <summary>
  21359. /// 倒推表
  21360. /// Create
  21361. /// </summary>
  21362. /// <param name="dto"></param>
  21363. /// <returns></returns>
  21364. [HttpPost]
  21365. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21366. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  21367. {
  21368. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  21369. if (viewData.Code != 0)
  21370. {
  21371. return Ok(JsonView(false, viewData.Msg));
  21372. }
  21373. return Ok(JsonView(viewData.Data));
  21374. }
  21375. /// <summary>
  21376. /// 倒推表
  21377. /// Update
  21378. /// </summary>
  21379. /// <param name="dto"></param>
  21380. /// <returns></returns>
  21381. [HttpPost]
  21382. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21383. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  21384. {
  21385. var viewData = await _invertedListRep._Update(dto);
  21386. if (viewData.Code != 0)
  21387. {
  21388. return Ok(JsonView(false, viewData.Msg));
  21389. }
  21390. return Ok(JsonView(viewData.Data));
  21391. }
  21392. /// <summary>
  21393. /// 倒推表
  21394. /// File Download
  21395. /// </summary>
  21396. /// <param name="dto"></param>
  21397. /// <returns></returns>
  21398. [HttpPost]
  21399. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21400. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  21401. {
  21402. var info2 = await _invertedListRep._Info(1, dto.DiId);
  21403. if (info2.Code != 0)
  21404. {
  21405. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  21406. }
  21407. var info1 = info2.Data as InvertedListInfoView;
  21408. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  21409. string teamName = "";
  21410. if (info != null) teamName = info.TeamName;
  21411. var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20250121.doc";
  21412. var doc = new Document();
  21413. var builder = new DocumentBuilder(doc);
  21414. #region old insert
  21415. ////载入模板
  21416. //var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20200617.doc";
  21417. //Document doc = new Document(tempPath);
  21418. //DocumentBuilder builder = new DocumentBuilder(doc);
  21419. //利用键值对存放数据
  21420. //Dictionary<string, string> dic = new Dictionary<string, string>();
  21421. //dic.Add("TeamName", teamName);
  21422. //dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  21423. //dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  21424. //dic.Add("BPRemark", info1.ApprovalDataRemark);
  21425. //dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  21426. //dic.Add("SQRemark", info1.ApprovalRemark);
  21427. //dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  21428. //dic.Add("CPJRemark", info1.IssueApprovalRemark);
  21429. ////dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  21430. ////dic.Add("HZRemark", info1.ApplyPassportRemark);
  21431. //dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  21432. //dic.Add("QZRemark", info1.VisaInformationRemark);
  21433. //dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  21434. //dic.Add("SQQZRemark", info1.SendVisaRemark);
  21435. //dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  21436. //dic.Add("CQRemark", info1.IssueVisaRemark);
  21437. //dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  21438. //dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  21439. //dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  21440. //dic.Add("SJRemark", info1.AirportdDropOffRemark);
  21441. //#region 填充word模板书签内容
  21442. //foreach (var key in dic.Keys)
  21443. //{
  21444. // builder.MoveToBookmark(key);
  21445. // builder.Write(dic[key]);
  21446. //}
  21447. //#endregion
  21448. #endregion
  21449. #region New Insert
  21450. string titleFont = $"仿宋",
  21451. contentFont = $"仿宋";
  21452. var fontColor = Color.FromArgb(64, 64, 64);
  21453. //设置标题 团组名称
  21454. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  21455. builder.Font.Name = titleFont;
  21456. builder.Font.Color = fontColor;
  21457. builder.Font.Size = 12;
  21458. builder.Font.Bold = true;
  21459. builder.Writeln(teamName);
  21460. //设置副标题 团组出访时间
  21461. builder.Font.Size = 12;
  21462. builder.Writeln("出发时间:" + info1.AirportdDropOffDt.ConvertToDatetime());
  21463. builder.Writeln();
  21464. var backgroundColor = Color.FromArgb(199, 199, 199);
  21465. var table = builder.StartTable();
  21466. builder.InsertCell();
  21467. builder.CellFormat.Shading.BackgroundPatternColor = backgroundColor;
  21468. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Single;
  21469. builder.CellFormat.Borders.LineWidth = 1;
  21470. builder.CellFormat.Borders.Color = Color.FromArgb(183, 183, 183);
  21471. table.FirstRow.FirstCell.CellFormat.Width = 20; // 单位为百分比
  21472. builder.RowFormat.Height = 40;
  21473. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  21474. builder.Font.Name = contentFont;
  21475. builder.Font.Size = 12;
  21476. builder.Font.Bold = true;
  21477. builder.Font.Color = fontColor;
  21478. builder.Write("时间");
  21479. builder.InsertCell();
  21480. table.FirstRow.FirstCell.CellFormat.Width = 30; // 单位为百分比
  21481. builder.Write("流程");
  21482. builder.InsertCell();
  21483. table.FirstRow.FirstCell.CellFormat.Width = 50; // 单位为百分比
  21484. builder.Write("说明");
  21485. builder.EndRow();
  21486. //报批资料准备
  21487. if (info1.IsSelectedAirportd)
  21488. {
  21489. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDataDt.ConvertToDatetime(), "报批资料准备", info1.ApprovalDataRemark);
  21490. }
  21491. //报批/提供送签资料
  21492. if (info1.IsSelectedApprovalData)
  21493. {
  21494. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDt.ConvertToDatetime(), "报批/提供送签资料", info1.ApprovalRemark);
  21495. }
  21496. //出批件护照办理
  21497. if (info1.IsSelectedIssueApproval)
  21498. {
  21499. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueApprovalDt.ConvertToDatetime(), "出批件\r\n护照办理", info1.IssueApprovalRemark);
  21500. }
  21501. //签证资料准备
  21502. if (info1.IsSelectedVisaInfo)
  21503. {
  21504. InvertedListFileDownloadSetRow(builder, contentFont, info1.VisaInformationDt.ConvertToDatetime(), "签证资料准备", info1.VisaInformationRemark);
  21505. }
  21506. //送签
  21507. if (info1.IsSelectedSendVisa)
  21508. {
  21509. InvertedListFileDownloadSetRow(builder, contentFont, info1.SendVisaDt.ConvertToDatetime(), "送签", info1.SendVisaRemark);
  21510. }
  21511. //出签
  21512. if (info1.IsSelectedIssueVisa)
  21513. {
  21514. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueVisaDt.ConvertToDatetime(), "出签", info1.IssueVisaRemark);
  21515. }
  21516. //机票
  21517. if (info1.IsSelectedAirTicket)
  21518. {
  21519. if (string.IsNullOrEmpty(info1.AirTicketDt)) info1.AirTicketDt = info1.IssueVisaDt;
  21520. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirTicketDt.ConvertToDatetime(), "机票", info1.AirTicketRemark);
  21521. }
  21522. //酒店
  21523. if (info1.IsSelectedHotel)
  21524. {
  21525. if (string.IsNullOrEmpty(info1.HotelDt)) info1.HotelDt = info1.IssueVisaDt;
  21526. InvertedListFileDownloadSetRow(builder, contentFont, info1.HotelDt.ConvertToDatetime(), "酒店", info1.HotelRemark);
  21527. }
  21528. //开行前会
  21529. if (info1.IsSelectedPreTripMeeting)
  21530. {
  21531. InvertedListFileDownloadSetRow(builder, contentFont, info1.PreTripMeetingDt.ConvertToDatetime(), "开行前会", info1.PreTripMeetingRemark);
  21532. }
  21533. //送机
  21534. if (info1.IsSelectedAirportdDropOff)
  21535. {
  21536. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirportdDropOffDt.ConvertToDatetime(), "送机", info1.AirportdDropOffRemark);
  21537. }
  21538. builder.EndTable();
  21539. //table.PreferredWidth = PreferredWidth.FromPercent(100.00);
  21540. //table.AutoFit(AutoFitBehavior.FixedColumnWidths);
  21541. for (int i = 0; i < table.Rows.Count; i++)
  21542. {
  21543. var row = table.Rows[i];
  21544. //设置宽度
  21545. row.Cells[0].CellFormat.Width = 20.00;
  21546. row.Cells[1].CellFormat.Width = 30.00;
  21547. row.Cells[2].CellFormat.Width = 50.00;
  21548. if (i != 0)
  21549. {
  21550. //边框设置
  21551. InvertedListFileDownloadSetBorders(row.Cells, 0);
  21552. InvertedListFileDownloadSetBorders(row.Cells, 1);
  21553. InvertedListFileDownloadSetBorders(row.Cells, 2);
  21554. }
  21555. }
  21556. #region 页脚插入图片
  21557. // 创建页脚
  21558. Aspose.Words.HeaderFooter footer = new Aspose.Words.HeaderFooter(doc, HeaderFooterType.FooterPrimary);
  21559. doc.FirstSection.HeadersFooters.Add(footer);
  21560. Paragraph para = new Paragraph(doc);
  21561. para.ParagraphFormat.Alignment = ParagraphAlignment.Right;
  21562. footer.AppendChild(para);
  21563. builder.MoveTo(para);
  21564. string imagePath = "./Images/FMGJ_Log.png";
  21565. builder.InsertImage(imagePath);
  21566. #endregion
  21567. #endregion
  21568. var fileDir = AppSettingsHelper.Get("WordBasePath");
  21569. string fileName = $"{teamName}团出行准备流程表{CommonFun.GUID}.doc";
  21570. string filePath = fileDir + $@"InvertedList/{fileName}";
  21571. doc.Save(filePath);
  21572. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  21573. return Ok(JsonView(true, "操作成功!", Url));
  21574. }
  21575. private void InvertedListFileDownloadSetRow(DocumentBuilder builder, string fontName, string dateTime, string content, string reamrk)
  21576. {
  21577. var fontColor = Color.FromArgb(64, 64, 64);
  21578. builder.InsertCell();
  21579. builder.CellFormat.Shading.BackgroundPatternColor = Color.Empty;
  21580. builder.RowFormat.Height = 40;
  21581. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  21582. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  21583. builder.Font.Name = fontName;
  21584. builder.Font.Size = 8;
  21585. builder.Font.Bold = true;
  21586. builder.Font.Color = fontColor;
  21587. builder.Write(dateTime);
  21588. builder.InsertCell();
  21589. builder.Font.Size = 9;
  21590. builder.Font.Bold = true;
  21591. builder.Font.Color = fontColor;
  21592. builder.Write(content);
  21593. builder.InsertCell();
  21594. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  21595. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  21596. builder.Font.Size = 9;
  21597. builder.Font.Bold = false;
  21598. builder.Font.Color = fontColor;
  21599. builder.Write(reamrk);
  21600. builder.EndRow();
  21601. }
  21602. private void InvertedListFileDownloadSetBorders(CellCollection cell, int index)
  21603. {
  21604. cell[index].CellFormat.Borders.Top.LineStyle = Aspose.Words.LineStyle.None;
  21605. cell[index].CellFormat.Borders.Bottom.LineStyle = Aspose.Words.LineStyle.None;
  21606. cell[index].CellFormat.Borders.Left.LineStyle = Aspose.Words.LineStyle.None;
  21607. cell[index].CellFormat.Borders.Right.LineStyle = Aspose.Words.LineStyle.None;
  21608. //cell[index].CellFormat.Borders.Horizontal.LineStyle = Aspose.Words.LineStyle.None;
  21609. //cell[index].CellFormat.Borders.Vertical.LineStyle = Aspose.Words.LineStyle.None;
  21610. }
  21611. #endregion
  21612. #region 会务倒推表
  21613. /// <summary>
  21614. /// 会务倒推表
  21615. /// Init
  21616. /// </summary>
  21617. /// <returns></returns>
  21618. [HttpPost]
  21619. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21620. public async Task<IActionResult> InforRetrogressTableInit()
  21621. {
  21622. var groupData = await _groupRepository.PostShareGroupInfos(1);
  21623. if (groupData.Code == 0) return Ok(JsonView(groupData.Data));
  21624. return Ok(JsonView(false, groupData.Msg));
  21625. }
  21626. /// <summary>
  21627. /// 会务倒推表
  21628. /// ExcelDownload
  21629. /// </summary>
  21630. /// <param name="dto"></param>
  21631. /// <returns></returns>
  21632. [HttpPost]
  21633. [ApiLog("InforRetrogressTable", OperationEnum.Download)]
  21634. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21635. public async Task<IActionResult> InforRetrogressTableFileDownload(InforRetrogressTableFileDownloadDto dto)
  21636. {
  21637. var validator = new InforRetrogressTableFileDownloadDtoValidator();
  21638. var validatorRes = await validator.ValidateAsync(dto);
  21639. if (!validatorRes.IsValid)
  21640. {
  21641. StringBuilder sb = new StringBuilder();
  21642. foreach (var item in validatorRes.Errors)
  21643. {
  21644. sb.AppendLine(item.ErrorMessage);
  21645. }
  21646. return Ok(JsonView(false, sb.ToString()));
  21647. }
  21648. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.GroupId);
  21649. if (groupInfo == null) return Ok(JsonView(false, $"该团组信息未填写!"));
  21650. //时间根据团组出访日期-接团录入日期的天数来判断用哪个模板
  21651. var days = groupInfo.VisitDate.Subtract(groupInfo.CreateTime).Days;
  21652. #region Excel
  21653. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  21654. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  21655. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "InforRetrogressTable/";
  21656. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "InforRetrogressTable/";
  21657. var fileNamePrefix = string.Empty;
  21658. if (days >= 30)
  21659. {
  21660. tempPath += $"会务工作倒推进度表(30天).xlsx";
  21661. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(30天)";
  21662. }
  21663. else if (days < 30 && days > 7)
  21664. {
  21665. tempPath += $"会务工作倒推进度表(15天).xlsx";
  21666. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(15天)";
  21667. }
  21668. else if (days <= 7)
  21669. {
  21670. tempPath += $"会务工作倒推进度表(7天).xlsx";
  21671. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(7天)";
  21672. }
  21673. var fileName = $"{fileNamePrefix}{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  21674. fileName = CommonFun.ValidFileName(fileName);
  21675. //载入模板
  21676. WorkbookDesigner designer = new WorkbookDesigner();
  21677. designer.Workbook = new Workbook(tempPath);
  21678. designer.Process();
  21679. if (!Directory.Exists(savePath))
  21680. {
  21681. Directory.CreateDirectory(savePath);
  21682. }
  21683. string serverPath = $"{savePath}{fileName}";
  21684. designer.Workbook.Save(serverPath);
  21685. string rst = $"{servicePath}{ftpPath}{fileName}";
  21686. #endregion
  21687. return Ok(JsonView(new { url = rst }));
  21688. }
  21689. #endregion
  21690. #region 三公签证费用(签证费、代办费)
  21691. /// <summary>
  21692. /// 三公签证费用(签证费、代办费)
  21693. /// List
  21694. /// </summary>
  21695. /// <returns></returns>
  21696. [HttpPost]
  21697. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21698. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  21699. {
  21700. return Ok(await _visaFeeInfoRep.List(_dto.PortType, _dto.DiId));
  21701. }
  21702. /// <summary>
  21703. /// 三公签证费用(签证费、代办费)
  21704. /// Add Or Update
  21705. /// </summary>
  21706. /// <returns></returns>
  21707. [HttpPost]
  21708. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21709. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  21710. {
  21711. var _view = await _visaFeeInfoRep.Update(_dto);
  21712. if (_view.Code != 0)
  21713. {
  21714. return Ok(JsonView(false, _view.Msg));
  21715. }
  21716. return Ok(JsonView(true, _view.Msg));
  21717. }
  21718. #endregion
  21719. #region 酒店询价
  21720. /// <summary>
  21721. /// 酒店询价
  21722. /// Init
  21723. /// </summary>
  21724. /// <returns></returns>
  21725. [HttpPost]
  21726. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21727. public async Task<IActionResult> PostHotelInquiryInit()
  21728. {
  21729. var res = await _hotelInquiryRep._Init();
  21730. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  21731. return Ok(JsonView(true, res.Msg, res.Data));
  21732. }
  21733. /// <summary>
  21734. /// 酒店询价
  21735. /// page Item
  21736. /// </summary>
  21737. /// <param name="_dto"></param>
  21738. /// <returns></returns>
  21739. [HttpPost]
  21740. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21741. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  21742. {
  21743. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  21744. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  21745. var view = res.Data as PageDataViewBase;
  21746. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  21747. }
  21748. /// <summary>
  21749. /// 酒店询价
  21750. /// info
  21751. /// </summary>
  21752. /// <param name="_dto"></param>
  21753. /// <returns></returns>
  21754. [HttpPost]
  21755. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21756. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  21757. {
  21758. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  21759. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  21760. return Ok(JsonView(true, res.Msg, res.Data));
  21761. }
  21762. /// <summary>
  21763. /// 酒店询价
  21764. /// Add Or Edit
  21765. /// </summary>
  21766. /// <param name="_dto"></param>
  21767. /// <returns></returns>
  21768. [HttpPost]
  21769. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21770. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  21771. {
  21772. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  21773. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  21774. return Ok(JsonView(true, res.Msg, res.Data));
  21775. }
  21776. /// <summary>
  21777. /// 酒店询价
  21778. /// Del
  21779. /// </summary>
  21780. /// <param name="_dto"></param>
  21781. /// <returns></returns>
  21782. [HttpPost]
  21783. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21784. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  21785. {
  21786. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  21787. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  21788. return Ok(JsonView(true, res.Msg, res.Data));
  21789. }
  21790. #endregion
  21791. #region 下载匹配op行程单
  21792. /// <summary>
  21793. /// 匹配op行程单
  21794. /// Init
  21795. /// </summary>
  21796. /// <param name="dto">团组列表请求dto</param>
  21797. /// <returns></returns>
  21798. [HttpPost]
  21799. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21800. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  21801. {
  21802. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  21803. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  21804. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  21805. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  21806. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  21807. .Where(it => it.IsDel == 0)
  21808. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  21809. .OrderByDescending(it => it.VisitStartDate)
  21810. .ToList();
  21811. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  21812. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  21813. var diids = groupInfos.Select(it => it.Id).ToList();
  21814. List<string> countrys = new List<string>();
  21815. foreach (var item in country)
  21816. {
  21817. var data = _groupRepository.FormartTeamName(item);
  21818. var dataArray = _groupRepository.GroupSplitCountry(data);
  21819. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  21820. }
  21821. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  21822. List<string> areaArray = new List<string>(); //GetGroupCityLine
  21823. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  21824. foreach (var item in areaItem)
  21825. {
  21826. string areaStr = item.Value;
  21827. if (!string.IsNullOrEmpty(areaStr))
  21828. {
  21829. string[] str1 = areaStr.Split("-");
  21830. if (str1.Length > 0)
  21831. {
  21832. areaArray.AddRange(str1);
  21833. }
  21834. }
  21835. }
  21836. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  21837. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  21838. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  21839. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  21840. .ToList();
  21841. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  21842. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  21843. .Where(it => countriesIds.Contains(it.Id))
  21844. .Select(it => new { it.Id, Name = it.Name_CN })
  21845. .ToList();
  21846. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  21847. .Select(it => it.TeamName).ToList();
  21848. stopwatch.Stop();
  21849. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  21850. }
  21851. ///// <summary>
  21852. ///// 匹配op行程单
  21853. ///// Init 查询区域数据
  21854. ///// </summary>
  21855. ///// <param name="dto">团组列表请求dto</param>
  21856. ///// <returns></returns>
  21857. //[HttpPost]
  21858. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21859. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  21860. //{
  21861. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  21862. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  21863. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  21864. // if (string.IsNullOrEmpty(countriesDataStr))
  21865. // {
  21866. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  21867. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  21868. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  21869. // }
  21870. // else
  21871. // {
  21872. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  21873. // }
  21874. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  21875. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  21876. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  21877. // List<dynamic> childList = new List<dynamic>();
  21878. // int parentId = dto.CountriesId;
  21879. // if (provinceData.Count > 1)
  21880. // {
  21881. // foreach (var item1 in provinceData)
  21882. // {
  21883. // List<dynamic> childList1 = new List<dynamic>();
  21884. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  21885. // foreach (var item2 in citiesData1)
  21886. // {
  21887. // List<dynamic> childList2 = new List<dynamic>();
  21888. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  21889. // foreach (var item3 in countiesData1)
  21890. // {
  21891. // childList2.Add(new
  21892. // {
  21893. // id = item3.Id,
  21894. // parentId = item2.Id,
  21895. // level = "district",
  21896. // name = item3.Name_CN,
  21897. // });
  21898. // }
  21899. // childList1.Add(new
  21900. // {
  21901. // id = item2.Id,
  21902. // parentId = item1.Id,
  21903. // level = "city",
  21904. // name = item2.Name_CN,
  21905. // childList = childList2
  21906. // });
  21907. // }
  21908. // childList.Add(new
  21909. // {
  21910. // id = item1.Id,
  21911. // parentId = parentId,
  21912. // level = "province",
  21913. // name = item1.Name_CN,
  21914. // childList = childList1
  21915. // });
  21916. // }
  21917. // //城市
  21918. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  21919. // foreach (var item2 in citiesData2)
  21920. // {
  21921. // List<dynamic> childList22 = new List<dynamic>();
  21922. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  21923. // foreach (var item3 in countiesData1)
  21924. // {
  21925. // childList22.Add(new
  21926. // {
  21927. // id = item3.Id,
  21928. // parentId = item2.Id,
  21929. // level = "district",
  21930. // name = item3.Name_CN,
  21931. // });
  21932. // }
  21933. // childList.Add(new
  21934. // {
  21935. // id = item2.Id,
  21936. // parentId = parentId,
  21937. // level = "city",
  21938. // name = item2.Name_CN,
  21939. // childList = childList22
  21940. // });
  21941. // }
  21942. // }
  21943. // else
  21944. // {
  21945. // foreach (var item2 in citiesData)
  21946. // {
  21947. // string cname = item2.Name_CN;
  21948. // List<dynamic> childList1 = new List<dynamic>();
  21949. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  21950. // foreach (var item3 in countiesData1)
  21951. // {
  21952. // childList1.Add(new
  21953. // {
  21954. // Id = item3.Id,
  21955. // parentId = item2.Id,
  21956. // level = "district",
  21957. // name = item3.Name_CN
  21958. // });
  21959. // }
  21960. // childList.Add(new
  21961. // {
  21962. // id = item2.Id,
  21963. // parentId = parentId,
  21964. // level = "city",
  21965. // name = item2.Name_CN,
  21966. // childList = childList1
  21967. // });
  21968. // }
  21969. // }
  21970. // stopwatch.Stop();
  21971. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  21972. //}
  21973. /// <summary>
  21974. /// 匹配op行程单
  21975. /// 接团信息列表 Page
  21976. /// </summary>
  21977. /// <param name="dto">团组列表请求dto</param>
  21978. /// <returns></returns>
  21979. [HttpPost]
  21980. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21981. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  21982. {
  21983. var swatch = new Stopwatch();
  21984. swatch.Start();
  21985. #region 参数验证
  21986. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  21987. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  21988. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  21989. #region 页面操作权限验证
  21990. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  21991. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  21992. #endregion
  21993. #endregion
  21994. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  21995. {
  21996. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  21997. //string sqlWhere = "";
  21998. if (!string.IsNullOrEmpty(dto.Country))
  21999. {
  22000. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  22001. }
  22002. if (!string.IsNullOrEmpty(dto.Area))
  22003. {
  22004. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  22005. }
  22006. if (!string.IsNullOrEmpty(dto.TeamName))
  22007. {
  22008. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  22009. }
  22010. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  22011. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  22012. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  22013. swatch.Stop();
  22014. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  22015. }
  22016. else
  22017. {
  22018. return Ok(JsonView(false, "查询失败"));
  22019. }
  22020. }
  22021. /// <summary>
  22022. /// 匹配op行程单
  22023. /// 行程单下载
  22024. /// </summary>
  22025. /// <param name="dto">团组列表请求dto</param>
  22026. /// <returns></returns>
  22027. [HttpPost]
  22028. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22029. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  22030. {
  22031. #region 参数验证
  22032. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  22033. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  22034. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  22035. #region 页面操作权限验证
  22036. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  22037. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  22038. #endregion
  22039. #endregion
  22040. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  22041. {
  22042. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  22043. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  22044. }
  22045. else
  22046. {
  22047. return Ok(JsonView(false, "下载失败!"));
  22048. }
  22049. }
  22050. #endregion
  22051. #region 国家信息 数据 注释
  22052. //[HttpPost]
  22053. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  22054. //{
  22055. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  22056. // foreach (var item in dto)
  22057. // {
  22058. // infos.Add(new Grp_GroupsTaskAssignment()
  22059. // {
  22060. // DIId = item,
  22061. // CTId = 82,
  22062. // UId = 248,
  22063. // IsEnable = 1,
  22064. // CreateUserId = 233,
  22065. // CreateTime = DateTime.Now,
  22066. // IsDel = 0
  22067. // });
  22068. // infos.Add(new Grp_GroupsTaskAssignment()
  22069. // {
  22070. // DIId = item,
  22071. // CTId = 82,
  22072. // UId = 286,
  22073. // IsEnable = 1,
  22074. // CreateUserId = 233,
  22075. // CreateTime = DateTime.Now,
  22076. // IsDel = 0
  22077. // });
  22078. // }
  22079. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  22080. // return Ok("操作成功");
  22081. //}
  22082. //public class paramJsonDto
  22083. //{
  22084. // public List<CountriesInfo> str { get; set; }
  22085. //}
  22086. //[HttpPost]
  22087. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  22088. //{
  22089. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  22090. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  22091. // List<Sys_Cities> cities = new List<Sys_Cities>();
  22092. // List<Sys_Cities> districts = new List<Sys_Cities>();
  22093. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  22094. // _sqlSugar.BeginTran();
  22095. // int countitiesIndex = 0;
  22096. // foreach (var item in dto.str)
  22097. // {
  22098. // dynamic data = item.c;
  22099. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  22100. // if (data != null)
  22101. // {
  22102. // countitiesIndex++;
  22103. // foreach (var item1 in data)
  22104. // {
  22105. // string cnname = item1.cn;
  22106. // string enname = item1.en;
  22107. // Sys_Cities provinceInfo = new Sys_Cities()
  22108. // {
  22109. // CountriesId = countriesId,
  22110. // Name_CN = cnname,
  22111. // Name_EN = enname,
  22112. // ParentId = 0,
  22113. // IsCapital = 1,
  22114. // CreateUserId = 208,
  22115. // CreateTime = DateTime.Now,
  22116. // IsDel = 0
  22117. // };
  22118. // if (item1.lv == "province") //省份
  22119. // {
  22120. // provinceInfo.Level = 1;
  22121. // int provinceId = 0;
  22122. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  22123. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  22124. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  22125. // var data1 = item1.c;
  22126. // foreach (var item2 in data1)
  22127. // {
  22128. // if (item2.lv == "city")
  22129. // {
  22130. // string citycnname = item2.cn;
  22131. // string cityenname = item2.en;
  22132. // Sys_Cities cityInfo = new Sys_Cities()
  22133. // {
  22134. // CountriesId = countriesId,
  22135. // ParentId = provinceId,
  22136. // Level = 2,
  22137. // Name_CN = citycnname,
  22138. // Name_EN = cityenname,
  22139. // IsCapital = 1,
  22140. // CreateUserId = 208,
  22141. // CreateTime = DateTime.Now,
  22142. // IsDel = 0
  22143. // };
  22144. // if (item2.c != null)
  22145. // {
  22146. // int cityId = 0;
  22147. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  22148. // if (citiesInfo != null) cityId = citiesInfo.Id;
  22149. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  22150. // foreach (var item3 in item2.c)
  22151. // {
  22152. // if (item3.lv == "district")
  22153. // {
  22154. // var districtInfo = new Sys_Cities()
  22155. // {
  22156. // CountriesId = countriesId,
  22157. // Name_CN = item3.cn,
  22158. // Name_EN = item3.en,
  22159. // Level = 3,
  22160. // ParentId = cityId,
  22161. // IsCapital = 1,
  22162. // CreateUserId = 208,
  22163. // CreateTime = DateTime.Now,
  22164. // IsDel = 0
  22165. // };
  22166. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  22167. // //{
  22168. // districts.Add(districtInfo);
  22169. // //}
  22170. // }
  22171. // }
  22172. // }
  22173. // else
  22174. // {
  22175. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  22176. // //{
  22177. // cities.Add(cityInfo);
  22178. // //}
  22179. // }
  22180. // }
  22181. // }
  22182. // }
  22183. // else if (item1.lv == "city")//城市
  22184. // {
  22185. // provinceInfo.Level = 2;
  22186. // if (item1.c != null)
  22187. // {
  22188. // int cityId = 0;
  22189. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  22190. // if (citiesInfo != null) cityId = citiesInfo.Id;
  22191. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  22192. // foreach (var item3 in item1.c)
  22193. // {
  22194. // if (item3.lv == "district")
  22195. // {
  22196. // var districtInfo = new Sys_Cities()
  22197. // {
  22198. // CountriesId = countriesId,
  22199. // Name_CN = item3.cn,
  22200. // Name_EN = item3.en,
  22201. // Level = 3,
  22202. // ParentId = cityId,
  22203. // IsCapital = 1,
  22204. // CreateUserId = 208,
  22205. // CreateTime = DateTime.Now,
  22206. // IsDel = 0
  22207. // };
  22208. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  22209. // //{
  22210. // districts.Add(districtInfo);
  22211. // //}
  22212. // }
  22213. // }
  22214. // }
  22215. // else
  22216. // {
  22217. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  22218. // //{
  22219. // cities.Add(provinceInfo);
  22220. // //}
  22221. // }
  22222. // }
  22223. // }
  22224. // }
  22225. // }
  22226. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  22227. // cities = cities.Distinct().ToList();
  22228. // districts = districts.Distinct().ToList();
  22229. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  22230. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  22231. // cities.AddRange(districts);
  22232. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  22233. // //_sqlSugar.RollbackTran();
  22234. // _sqlSugar.CommitTran();
  22235. // return Ok(JsonView(false, "操作成功!"));
  22236. //}
  22237. //[HttpPost]
  22238. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  22239. //{
  22240. // List<CountitiesInfo> infos = dto.MyProperty;
  22241. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  22242. // _sqlSugar.BeginTran();
  22243. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  22244. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  22245. // foreach (var item in infos)
  22246. // {
  22247. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  22248. // if (countryInfo != null)
  22249. // {
  22250. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  22251. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  22252. // if (cityInfo1 != null)
  22253. // {
  22254. // cityInfo1.IsCapital = 0;
  22255. // cityInfos.Add(cityInfo1);
  22256. // }
  22257. // }
  22258. // }
  22259. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  22260. // .UpdateColumns(it => it.IsCapital)
  22261. // .WhereColumns(it => it.Id)
  22262. // .ExecuteCommand();
  22263. // //_sqlSugar.RollbackTran();
  22264. // _sqlSugar.CommitTran();
  22265. // return Ok(JsonView(false, "操作成功!"));
  22266. //}
  22267. //public class CounrtiesDto
  22268. //{
  22269. // public List<CountitiesInfo> MyProperty { get; set; }
  22270. //}
  22271. //public class CountitiesInfo
  22272. //{
  22273. // /// <summary>
  22274. // /// 圣约翰
  22275. // /// </summary>
  22276. // public string capital_name_chinese { get; set; }
  22277. // /// <summary>
  22278. // ///
  22279. // /// </summary>
  22280. // public string capital_name { get; set; }
  22281. // /// <summary>
  22282. // ///
  22283. // /// </summary>
  22284. // public string country_type { get; set; }
  22285. // /// <summary>
  22286. // /// 安提瓜和巴布达
  22287. // /// </summary>
  22288. // public string country_name_chinese { get; set; }
  22289. // /// <summary>
  22290. // /// 安提瓜和巴布达
  22291. // /// </summary>
  22292. // public string country_name_chinese_short { get; set; }
  22293. // /// <summary>
  22294. // /// 安提瓜和巴布达
  22295. // /// </summary>
  22296. // public string country_name_chinese_UN { get; set; }
  22297. // /// <summary>
  22298. // ///
  22299. // /// </summary>
  22300. // public string country_name_english_abbreviation { get; set; }
  22301. // /// <summary>
  22302. // ///
  22303. // /// </summary>
  22304. // public string country_name_english_formal { get; set; }
  22305. // /// <summary>
  22306. // ///
  22307. // /// </summary>
  22308. // public string country_name_english_UN { get; set; }
  22309. // /// <summary>
  22310. // ///
  22311. // /// </summary>
  22312. // public string continent_name { get; set; }
  22313. // /// <summary>
  22314. // ///
  22315. // /// </summary>
  22316. // public string subregion_name { get; set; }
  22317. // /// <summary>
  22318. // ///
  22319. // /// </summary>
  22320. // public string country_code2 { get; set; }
  22321. // /// <summary>
  22322. // ///
  22323. // /// </summary>
  22324. // public string country_code3 { get; set; }
  22325. // /// <summary>
  22326. // ///
  22327. // /// </summary>
  22328. // public string phone_code { get; set; }
  22329. //}
  22330. //public class CountriesInfo : BasicInfo
  22331. //{
  22332. // public List<CitiesInfo> c { get; set; }
  22333. //}
  22334. //public class CitiesInfo : BasicInfo
  22335. //{
  22336. // public List<AreaInfo> c { get; set; }
  22337. //}
  22338. //public class AreaInfo : BasicInfo
  22339. //{
  22340. // public List<AreaInfo> c { get; set; }
  22341. //}
  22342. //public class BasicInfo
  22343. //{
  22344. // public string code { get; set; }
  22345. // public string cn { get; set; }
  22346. // public string lv { get; set; }
  22347. // public string en { get; set; }
  22348. //}
  22349. #endregion
  22350. #region 查看邀请方
  22351. /// <summary>
  22352. /// 查看邀请方
  22353. /// 邀请方信息 Init
  22354. /// </summary>
  22355. /// <param name="dto"></param>
  22356. /// <returns></returns>
  22357. [HttpPost]
  22358. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22359. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  22360. {
  22361. string sqlWhere = string.Empty;
  22362. if (!string.IsNullOrEmpty(dto.Search))
  22363. {
  22364. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  22365. }
  22366. string sql = string.Format($@"Select
  22367. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  22368. Id,
  22369. UnitName
  22370. From Res_InvitationOfficialActivityData
  22371. Where IsDel = 0
  22372. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  22373. RefAsync<int> total = 0;
  22374. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  22375. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  22376. }
  22377. /// <summary>
  22378. /// 查看邀请方
  22379. /// 国家信息 Init
  22380. /// </summary>
  22381. /// <param name="dto"></param>
  22382. /// <returns></returns>
  22383. [HttpPost]
  22384. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22385. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  22386. {
  22387. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  22388. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  22389. var diids = groupInfos.Select(it => it.Id).ToList();
  22390. List<string> countrys = new List<string>();
  22391. foreach (var item in country)
  22392. {
  22393. var data = _groupRepository.FormartTeamName(item);
  22394. var dataArray = _groupRepository.GroupSplitCountry(data);
  22395. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  22396. }
  22397. countrys = countrys.Distinct().ToList();
  22398. for (int i = 0; i < countrys.Count; i++)
  22399. {
  22400. string item = countrys[i];
  22401. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  22402. {
  22403. countrys.Remove(item);
  22404. i--;
  22405. }
  22406. }
  22407. RefAsync<int> total = 0;
  22408. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  22409. .Where(it => countrys.Contains(it.Name_CN))
  22410. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  22411. .Select(it => new { id = it.Id, name = it.Name_CN })
  22412. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  22413. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  22414. }
  22415. /// <summary>
  22416. /// 查看邀请方
  22417. /// 城市信息 Init
  22418. /// </summary>
  22419. /// <param name="dto"></param>
  22420. /// <returns></returns>
  22421. [HttpPost]
  22422. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22423. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  22424. {
  22425. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  22426. RefAsync<int> total = 0;
  22427. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  22428. .Where(it => it.CountriesId == dto.CountiesId)
  22429. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  22430. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  22431. .Select(it => new { id = it.Id, name = it.Name_CN })
  22432. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  22433. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  22434. }
  22435. /// <summary>
  22436. /// 查看邀请方
  22437. /// 团组名称 Init
  22438. /// </summary>
  22439. /// <param name="dto"></param>
  22440. /// <returns></returns>
  22441. [HttpPost]
  22442. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22443. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  22444. {
  22445. var watch = new Stopwatch();
  22446. watch.Start();
  22447. RefAsync<int> total = 0;
  22448. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  22449. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  22450. .Where((oa, di) => oa.IsDel == 0)
  22451. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  22452. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  22453. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  22454. .Distinct()
  22455. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  22456. watch.Stop();
  22457. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  22458. }
  22459. /// <summary>
  22460. /// 查看邀请方
  22461. /// 团组 & 邀请方信息
  22462. /// </summary>
  22463. /// <param name="dto"></param>
  22464. /// <returns></returns>
  22465. [HttpPost]
  22466. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22467. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  22468. {
  22469. var watch = new Stopwatch();
  22470. watch.Start();
  22471. RefAsync<int> total = 0;
  22472. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  22473. .AS("Grp_DelegationInfo")
  22474. .Includes(x => x.InvitingInfos)
  22475. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  22476. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  22477. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  22478. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  22479. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  22480. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  22481. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  22482. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  22483. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  22484. infos.ForEach(x =>
  22485. {
  22486. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  22487. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  22488. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  22489. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  22490. });
  22491. watch.Stop();
  22492. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  22493. }
  22494. #endregion
  22495. #region 报批行程
  22496. /// <summary>
  22497. /// 报批行程初始化
  22498. /// </summary>
  22499. /// <param name="dto"></param>
  22500. /// <returns></returns>
  22501. [HttpPost]
  22502. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  22503. {
  22504. const int chiNumber = 5;
  22505. var jw = JsonView(false);
  22506. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  22507. var group = groupList.First();
  22508. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  22509. group = groupList.First(x => x.Id == diid);
  22510. var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  22511. .Where(x => x.DiId == diid && x.IsDel == 0)
  22512. .ToArray();
  22513. var count = 1;
  22514. foreach (var item in blackCodeList)
  22515. {
  22516. if (string.IsNullOrWhiteSpace(item.Title))
  22517. {
  22518. item.Title = "未设置名称数据" + count;
  22519. }
  22520. count++;
  22521. }
  22522. ;
  22523. if (group == null)
  22524. {
  22525. jw.Msg = "暂无团组!";
  22526. return Ok(jw);
  22527. }
  22528. var data = new
  22529. {
  22530. groupList = groupList.Select(x => new
  22531. {
  22532. x.TeamName,
  22533. x.Id
  22534. }),
  22535. content = new ArrayList(),
  22536. groupInfo = new
  22537. {
  22538. group.VisitDays,
  22539. group.TourCode,
  22540. group.VisitPNumber,
  22541. group.TeamName,
  22542. group.Id,
  22543. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  22544. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd"),
  22545. group.ClientUnit
  22546. },
  22547. blackCodeList = blackCodeList.Select(x => new
  22548. {
  22549. x.Title,
  22550. x.Id
  22551. }),
  22552. FileTempList = new ArrayList()
  22553. {
  22554. new { Index = 1,FileName = "旧模板" },
  22555. new { Index = 2,FileName = "省外办" },
  22556. new { Index = 3,FileName = "市外办" },
  22557. }
  22558. };
  22559. var resultArr = new ArrayList();
  22560. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  22561. #region 默认不生成行程
  22562. //if (content.Count == 0)
  22563. //{
  22564. // var stay = "-";
  22565. // var cityPath = "-";
  22566. // var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  22567. // .Where(x => x.DiId == diid && x.IsDel == 0)
  22568. // .ToList();
  22569. // //添加城市路径以及住宿地
  22570. // //黑屏代码数据
  22571. // DataTable dtBlack = GeneralMethod.GetTableByBlackCodeById(blackCodeList.FirstOrDefault());
  22572. // if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  22573. // {
  22574. // jw = JsonView(true, "黑屏代码有误!", data);
  22575. // return Ok(jw);
  22576. // }
  22577. // data = data with
  22578. // {
  22579. // blackCodeList = new ArrayList(blackCodeList.Select(x => new
  22580. // {
  22581. // x.Title,
  22582. // x.Id,
  22583. // }).ToArray())
  22584. // };
  22585. // foreach (DataRow row in dtBlack.Rows)
  22586. // {
  22587. // if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  22588. // {
  22589. // jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  22590. // return Ok(jw);
  22591. // }
  22592. // }
  22593. // //黑屏代码获取时间区间
  22594. // var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  22595. // string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  22596. // _sqlSugar.BeginTran();
  22597. // for (int i = 0; i < timeArr.Count; i++)
  22598. // {
  22599. // stay = "-";
  22600. // cityPath = "-";
  22601. // DateTime NewData = DateTime.Parse(timeArr[i]);
  22602. // string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  22603. // Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  22604. // var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  22605. // if (tbSelect.Length > 0)
  22606. // {
  22607. // List<string> threeCodeStr = new List<string>();
  22608. // foreach (var item in tbSelect)
  22609. // {
  22610. // var threeCode = item["Three"].ToString() ?? "";
  22611. // if (threeCode.Length == 6)
  22612. // {
  22613. // var start = threeCode.Substring(0, 3);
  22614. // var end = threeCode.Substring(3, 3);
  22615. // if (threeCodeStr.Count == 0)
  22616. // {
  22617. // threeCodeStr.Add(start);
  22618. // threeCodeStr.Add(end);
  22619. // }
  22620. // else
  22621. // {
  22622. // if (threeCodeStr[threeCodeStr.Count - 1] == start)
  22623. // {
  22624. // threeCodeStr.Add(end);
  22625. // }
  22626. // else
  22627. // {
  22628. // threeCodeStr.Add(start);
  22629. // threeCodeStr.Add(end);
  22630. // }
  22631. // }
  22632. // }
  22633. // }
  22634. // var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  22635. // var last = threeCodeStr.Last();
  22636. // foreach (var item in threeCodeStr)
  22637. // {
  22638. // cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  22639. // if (item.Equals(last))
  22640. // {
  22641. // stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  22642. // }
  22643. // }
  22644. // cityPath = cityPath.Trim('-');
  22645. // }
  22646. // appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  22647. // appro.Diid = diid ?? -1;
  22648. // var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  22649. // appro.Id = thisId;
  22650. // appro.CreateUserId = dto.UserId;
  22651. // appro.CreateTime = DateTime.Now;
  22652. // content.Add(appro);
  22653. // }
  22654. // _sqlSugar.CommitTran();
  22655. //}
  22656. #endregion
  22657. foreach (var x in content)
  22658. {
  22659. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  22660. if (chiList.Count < chiNumber)
  22661. {
  22662. for (int i = chiList.Count; i < chiNumber; i++)
  22663. {
  22664. chiList.Add(new Grp_ApprovalTravelDetails());
  22665. }
  22666. }
  22667. resultArr.Add(new
  22668. {
  22669. x.Id,
  22670. x.Date,
  22671. x.Diid,
  22672. chiList = chiList.Select(x1 => new
  22673. {
  22674. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  22675. x1.Details,
  22676. x1.ParentId,
  22677. x1.Id
  22678. })
  22679. });
  22680. }
  22681. data = data with
  22682. {
  22683. content = resultArr,
  22684. };
  22685. jw = JsonView(true, "获取成功!", data);
  22686. return Ok(jw);
  22687. }
  22688. /// <summary>
  22689. /// 报批行程删除
  22690. /// </summary>
  22691. /// <param name="dto"></param>
  22692. /// <returns></returns>
  22693. [HttpPost]
  22694. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  22695. {
  22696. var jw = JsonView(false);
  22697. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  22698. if (group == null)
  22699. {
  22700. jw.Msg = "团组参数有误!";
  22701. return Ok(jw);
  22702. }
  22703. try
  22704. {
  22705. _sqlSugar.BeginTran();
  22706. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  22707. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  22708. {
  22709. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  22710. DeleteUserId = dto.uesrId,
  22711. IsDel = 1
  22712. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  22713. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  22714. {
  22715. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  22716. DeleteUserId = dto.uesrId,
  22717. IsDel = 1
  22718. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  22719. _sqlSugar.CommitTran();
  22720. jw = JsonView(true, "删除成功");
  22721. }
  22722. catch (Exception ex)
  22723. {
  22724. jw = JsonView(false, ex.Message);
  22725. }
  22726. return Ok(jw);
  22727. }
  22728. /// <summary>
  22729. /// 报批行程保存
  22730. /// </summary>
  22731. /// <param name="dto"></param>
  22732. /// <returns></returns>
  22733. [HttpPost]
  22734. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  22735. {
  22736. var jw = JsonView(false);
  22737. var Find = dto.Arr.Find(x => x.id == 0);
  22738. if (Find != null)
  22739. {
  22740. jw.Msg = "生成的ID为0!";
  22741. return Ok(jw);
  22742. }
  22743. foreach (var item in dto.Arr)
  22744. {
  22745. foreach (var chi in item.chiList)
  22746. {
  22747. if (chi.parentId == 0)
  22748. {
  22749. chi.parentId = item.id;
  22750. }
  22751. }
  22752. }
  22753. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  22754. _sqlSugar.BeginTran();
  22755. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  22756. {
  22757. var parentIds = dto.Arr.Select(x => x.id).ToList();
  22758. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  22759. {
  22760. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  22761. DeleteUserId = dto.UserId,
  22762. IsDel = 1
  22763. }).ExecuteCommand();
  22764. }
  22765. try
  22766. {
  22767. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  22768. {
  22769. CreateTime = DateTime.Now,
  22770. CreateUserId = dto.UserId,
  22771. Details = x.details,
  22772. ParentId = x.parentId,
  22773. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  22774. Remark = "",
  22775. IsDel = 0
  22776. }).ToList()).ExecuteCommand();
  22777. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  22778. {
  22779. Id = x.id,
  22780. Details = x.details,
  22781. ParentId = x.parentId,
  22782. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  22783. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  22784. {
  22785. Details = x.Details,
  22786. ParentId = x.ParentId,
  22787. Time = x.Time
  22788. }).ExecuteCommand();
  22789. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  22790. {
  22791. Id = x.id,
  22792. Date = x.date,
  22793. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  22794. {
  22795. Date = x.Date
  22796. }).ExecuteCommand();
  22797. _sqlSugar.CommitTran();
  22798. jw = JsonView(true, "保存成功!");
  22799. }
  22800. catch (Exception ex)
  22801. {
  22802. _sqlSugar.RollbackTran();
  22803. jw = JsonView(false, "保存失败!" + ex.Message);
  22804. }
  22805. return Ok(jw);
  22806. }
  22807. /// <summary>
  22808. /// 报批行程生成
  22809. /// </summary>
  22810. /// <param name="dto"></param>
  22811. /// <returns></returns>
  22812. [HttpPost]
  22813. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  22814. {
  22815. var jw = JsonView(false);
  22816. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  22817. if (group == null)
  22818. {
  22819. jw.Msg = "暂无该团组!";
  22820. return Ok(jw);
  22821. }
  22822. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().First(x => x.Id == dto.BlackCodeId && x.IsDel == 0);
  22823. //黑屏代码数据
  22824. DataTable dtBlack = GeneralMethod.GetTableByBlackCodeBySingle(blackCode);
  22825. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  22826. {
  22827. jw.Msg = "黑屏代码有误!";
  22828. return Ok(jw);
  22829. }
  22830. foreach (DataRow row in dtBlack.Rows)
  22831. {
  22832. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  22833. {
  22834. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  22835. return Ok(jw);
  22836. }
  22837. }
  22838. //var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  22839. var resultArr = new ArrayList();
  22840. //if (officialActivitiesArr.Count == 0)
  22841. //{
  22842. // jw.Msg = "暂无公务出访信息!";
  22843. // return Ok(jw);
  22844. //}
  22845. try
  22846. {
  22847. _sqlSugar.BeginTran();
  22848. DeleteApprovalJourney(new
  22849. Domain.Dtos.Groups.DeleteApprovalJourney
  22850. {
  22851. Diid = dto.Diid,
  22852. uesrId = dto.Userid
  22853. });
  22854. var stay = "-";
  22855. var cityPath = "-";
  22856. var arriveCountry = string.Empty;
  22857. //添加城市路径以及住宿地
  22858. //黑屏代码获取时间区间
  22859. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  22860. var empty = "【未收入该三字码!请机票同事录入】";
  22861. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  22862. #region 配置公务活动时间
  22863. List<Tuple<int, string, string>> Times = new List<Tuple<int, string, string>>();
  22864. Times.Add(new Tuple<int, string, string>(9, "9:00", "10:30"));
  22865. Times.Add(new Tuple<int, string, string>(11, "11:00", "12:00"));
  22866. Times.Add(new Tuple<int, string, string>(14, "14:00", "15:30"));
  22867. Times.Add(new Tuple<int, string, string>(16, "16:00", "17:00"));
  22868. List<Tuple<DateTime, List<string>>> fallTimesCheckCountry = new List<Tuple<DateTime, List<string>>>()
  22869. {
  22870. 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" }),
  22871. 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"}),
  22872. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,11,30,0), new List<string>{"14:00-15:30","16:00-17:00"}),
  22873. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,13,30,0), new List<string>{"16:30-17:30"}),
  22874. };
  22875. List<Tuple<DateTime, List<string>>> fallTimesNotCheckCountry = new List<Tuple<DateTime, List<string>>>()
  22876. {
  22877. 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" }),
  22878. 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"}),
  22879. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,11,30,0), new List<string>{"14:00-15:30","16:00-17:00"}),
  22880. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,14,30,0), new List<string>{"16:30-17:30"}),
  22881. };
  22882. List<Tuple<DateTime, List<string>>> takeoffTimes = new List<Tuple<DateTime, List<string>>>()
  22883. {
  22884. 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" }),
  22885. 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"}),
  22886. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,14,00,0), new List<string>{"9:00-10:30", "11:00-12:00",}),
  22887. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,12,00,0), new List<string>{"09:00-10:00"}),
  22888. };
  22889. #endregion
  22890. var nextDayNum = 0;
  22891. for (int i = 0; i < timeArr.Count; i++)
  22892. {
  22893. stay = "-";
  22894. cityPath = "-";
  22895. var chiarr = new List<Grp_ApprovalTravelDetails>();
  22896. DateTime NewData = DateTime.Parse(timeArr[i]);
  22897. //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();
  22898. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  22899. if (nextDayNum > 0)
  22900. {
  22901. nextDayNum--;
  22902. }
  22903. if (tbSelect.Length > 0)
  22904. {
  22905. List<string> threeCodeStr = new List<string>();
  22906. bool isTrade = false;
  22907. string trip = string.Empty;
  22908. foreach (var item in tbSelect)
  22909. {
  22910. if (nextDayNum == 0)
  22911. {
  22912. nextDayNum = Convert.ToInt32(item["Sign"]);
  22913. }
  22914. var airStartTime = item["StartTime"].ToString() ?? "0000";
  22915. var airEndTime = item["EndTime"].ToString() ?? "0000";
  22916. var takeOffTime = DateTime.Parse(timeArr[i]);
  22917. var fallToTime = DateTime.Parse(timeArr[i]);
  22918. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  22919. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  22920. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  22921. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  22922. if (nextDayNum > 0)
  22923. {
  22924. fallToTime = fallToTime.AddDays(nextDayNum);
  22925. }
  22926. trip = string.Empty;
  22927. var start = string.Empty;
  22928. var end = string.Empty;
  22929. var threeCode = item["Three"].ToString() ?? "";
  22930. if (threeCode.Length == 6)
  22931. {
  22932. start = threeCode.Substring(0, 3);
  22933. end = threeCode.Substring(3, 3);
  22934. if (threeCodeStr.Count == 0)
  22935. {
  22936. threeCodeStr.Add(start);
  22937. threeCodeStr.Add(end);
  22938. }
  22939. else
  22940. {
  22941. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  22942. {
  22943. threeCodeStr.Add(end);
  22944. }
  22945. else
  22946. {
  22947. threeCodeStr.Add(start);
  22948. threeCodeStr.Add(end);
  22949. }
  22950. }
  22951. }
  22952. //处理机票信息
  22953. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  22954. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  22955. if (start_Object == null)
  22956. {
  22957. start_Object = new Res_ThreeCode()
  22958. {
  22959. AirPort = empty,
  22960. AirPort_En = empty,
  22961. City = empty,
  22962. Country = empty,
  22963. Four = empty,
  22964. Three = empty,
  22965. };
  22966. }
  22967. if (end_Object == null)
  22968. {
  22969. end_Object = new Res_ThreeCode()
  22970. {
  22971. AirPort = empty,
  22972. AirPort_En = empty,
  22973. City = empty,
  22974. Country = empty,
  22975. Four = empty,
  22976. Three = empty,
  22977. };
  22978. }
  22979. //机型判断
  22980. string airModel = item["AirModel"].ToString();
  22981. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  22982. string flightTime = item["FlightTime"].ToString();
  22983. flightTime = ParseBlackTime(flightTime);
  22984. //航班号
  22985. string flightcode = item["Fliagtcode"].ToString();
  22986. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  22987. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  22988. if (aircompany == null)
  22989. {
  22990. aircompany = new Res_AirCompany
  22991. {
  22992. CnName = hsEmpty,
  22993. EnName = hsEmpty,
  22994. ShortCode = hsEmpty,
  22995. };
  22996. }
  22997. //航班前公务安排
  22998. if (tbSelect.First().Equals(item) && i != 0)
  22999. {
  23000. foreach (var takeoff in takeoffTimes)
  23001. {
  23002. var takeoffItem1 = NewData.AddHours(takeoff.Item1.Hour).AddMinutes(takeoff.Item1.Minute);
  23003. if (DateTime.Compare(takeOffTime, takeoffItem1) > 0)
  23004. {
  23005. foreach (var addTime in takeoff.Item2)
  23006. {
  23007. chiarr.Add(new Grp_ApprovalTravelDetails
  23008. {
  23009. Time = addTime,
  23010. CreateTime = DateTime.Now,
  23011. CreateUserId = dto.Userid,
  23012. ParentId = 0,
  23013. Details = "公务活动"
  23014. });
  23015. }
  23016. break;
  23017. }
  23018. }
  23019. }
  23020. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  23021. //trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName}{flightcode}飞往{end_Object.City}。\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  23022. //乘坐四川航空3U3901次航班由成都飞往加德满都,3小时25分钟
  23023. trip += $"乘坐{aircompany.CnName}{flightcode}次航班由{start_Object.City}飞往{end_Object.City},{flightTime}";
  23024. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  23025. if (isTrade)
  23026. {
  23027. //trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  23028. trip += "(转机不出机场)。";
  23029. }
  23030. //else
  23031. //{
  23032. // trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  23033. //}
  23034. chiarr.Add(new Grp_ApprovalTravelDetails
  23035. {
  23036. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  23037. CreateTime = DateTime.Now,
  23038. CreateUserId = dto.Userid,
  23039. ParentId = 0,
  23040. Details = trip
  23041. });
  23042. //最后一条到达的时间安排公务
  23043. if (tbSelect.Last().Equals(item) && i != timeArr.Count - 1)
  23044. {
  23045. bool isCheckCountry = false;
  23046. if (end_Object.Country != arriveCountry)
  23047. {
  23048. arriveCountry = end_Object.Country;
  23049. isCheckCountry = true;
  23050. }
  23051. if (nextDayNum == 0)
  23052. {
  23053. //需要入境的情况
  23054. if (isCheckCountry)
  23055. {
  23056. foreach (var fallTime in fallTimesCheckCountry)
  23057. {
  23058. var fallTimeItem1 = NewData.AddHours(fallTime.Item1.Hour).AddMinutes(fallTime.Item1.Minute);
  23059. if (DateTime.Compare(fallToTime, fallTimeItem1) < 0)
  23060. {
  23061. foreach (var addTime in fallTime.Item2)
  23062. {
  23063. chiarr.Add(new Grp_ApprovalTravelDetails
  23064. {
  23065. Time = addTime,
  23066. CreateTime = DateTime.Now,
  23067. CreateUserId = dto.Userid,
  23068. ParentId = 0,
  23069. Details = "公务活动"
  23070. });
  23071. }
  23072. break;
  23073. }
  23074. }
  23075. }
  23076. else
  23077. {
  23078. foreach (var fallTime in fallTimesNotCheckCountry)
  23079. {
  23080. var fallTimeItem1 = NewData.AddHours(fallTime.Item1.Hour).AddMinutes(fallTime.Item1.Minute);
  23081. if (DateTime.Compare(fallToTime, fallTimeItem1) < 0)
  23082. {
  23083. foreach (var addTime in fallTime.Item2)
  23084. {
  23085. chiarr.Add(new Grp_ApprovalTravelDetails
  23086. {
  23087. Time = addTime,
  23088. CreateTime = DateTime.Now,
  23089. CreateUserId = dto.Userid,
  23090. ParentId = 0,
  23091. Details = "公务活动"
  23092. });
  23093. }
  23094. break;
  23095. }
  23096. }
  23097. }
  23098. }
  23099. }
  23100. }
  23101. //添加乘车语句
  23102. //chiarr.Add(new Grp_ApprovalTravelDetails
  23103. //{
  23104. // Time = (fallToTime.AddHours(2.5).ToString("HH:mm") + "-" + fallToTime.AddHours(3).ToString("HH:mm")),
  23105. // CreateTime = DateTime.Now,
  23106. // CreateUserId = dto.Userid,
  23107. // ParentId = 0,
  23108. // Details = "乘车前往市区(约xx公里,大约需要xx分钟)"
  23109. //});
  23110. //if (i != timeArr.Count - 1)
  23111. //{
  23112. // fallToTime = fallToTime.AddHours(2.5);
  23113. // foreach (var item in Times)
  23114. // {
  23115. // //排列公务时间
  23116. // if (fallToTime.Hour < item.Item1)
  23117. // {
  23118. // chiarr.Add(new Grp_ApprovalTravelDetails
  23119. // {
  23120. // Time = $"{item.Item2} - {item.Item3}",
  23121. // CreateTime = DateTime.Now,
  23122. // CreateUserId = dto.Userid,
  23123. // ParentId = 0,
  23124. // Details = "公务活动"
  23125. // });
  23126. // }
  23127. // }
  23128. //}
  23129. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  23130. var last = threeCodeStr.Last();
  23131. foreach (var item in threeCodeStr)
  23132. {
  23133. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  23134. if (item.Equals(last))
  23135. {
  23136. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  23137. }
  23138. }
  23139. cityPath = cityPath.Trim('-');
  23140. }
  23141. else
  23142. {
  23143. foreach (var item in Times)
  23144. {
  23145. chiarr.Add(new Grp_ApprovalTravelDetails
  23146. {
  23147. Time = $"{item.Item2} - {item.Item3}",
  23148. CreateTime = DateTime.Now,
  23149. CreateUserId = dto.Userid,
  23150. ParentId = 0,
  23151. Details = "公务活动"
  23152. });
  23153. }
  23154. }
  23155. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  23156. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  23157. appro.Date = NewData.Month + "月" + NewData.Day + "日(" + week + ")" + "第" + intToString(i + 1) + "天 ";
  23158. appro.Diid = dto.Diid;
  23159. appro.CreateUserId = dto.Userid;
  23160. appro.CreateTime = DateTime.Now;
  23161. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  23162. appro.Id = thisId;
  23163. //foreach (var item in gwinfo)
  23164. //{
  23165. // Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  23166. // chi.Details = "拜访" + item.Client;
  23167. // if (!string.IsNullOrWhiteSpace(item.ReqSample))
  23168. // {
  23169. // chi.Details += "," + item.ReqSample;
  23170. // }
  23171. // chi.ParentId = thisId;
  23172. // chi.Time = item.Time;
  23173. // chiarr.Add(chi);
  23174. //}
  23175. if (chiarr.Count < 6)
  23176. {
  23177. for (int j = chiarr.Count; j < 6; j++)
  23178. {
  23179. chiarr.Add(new
  23180. Grp_ApprovalTravelDetails());
  23181. }
  23182. }
  23183. resultArr.Add(new
  23184. {
  23185. appro.Id,
  23186. appro.Date,
  23187. appro.Diid,
  23188. chiList = chiarr.Select(x1 => new
  23189. {
  23190. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  23191. x1.Details,
  23192. x1.ParentId,
  23193. x1.Id
  23194. })
  23195. });
  23196. }
  23197. _sqlSugar.CommitTran();
  23198. jw = JsonView(true, "生成成功!", resultArr);
  23199. }
  23200. catch (Exception ex)
  23201. {
  23202. jw.Code = 400;
  23203. jw.Msg = "生成失败!" + ex.Message;
  23204. }
  23205. return Ok(jw);
  23206. }
  23207. /// <summary>
  23208. /// 报批行程word导出
  23209. /// </summary>
  23210. /// <param name="dto"></param>
  23211. /// <returns></returns>
  23212. [HttpPost]
  23213. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  23214. {
  23215. var jw = JsonView(false);
  23216. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  23217. if (group == null)
  23218. {
  23219. jw.Msg = "暂无该团组!";
  23220. return Ok(jw);
  23221. }
  23222. //模板路径
  23223. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/";
  23224. var fileName = string.Empty;
  23225. string titleFont = string.Empty, timeFont = string.Empty, contentFont = string.Empty;
  23226. bool bold = false;
  23227. if (dto.FileIndex == 1)
  23228. {
  23229. fileName = "公务行程导出模板.docx"; //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  23230. }
  23231. else if (dto.FileIndex == 2)
  23232. {
  23233. fileName = "省外办-报批.docx";
  23234. bold = false;
  23235. titleFont = "方正黑体简体";
  23236. timeFont = "Times New Roman";
  23237. contentFont = "方正仿宋_GBK";
  23238. }
  23239. else if (dto.FileIndex == 3)
  23240. {
  23241. fileName = "市外办-报批.docx";
  23242. titleFont = "方正黑体简体";
  23243. timeFont = "Times New Roman";
  23244. contentFont = "方正仿宋简体";
  23245. }
  23246. tempPath = tempPath + fileName;
  23247. //载入模板
  23248. Document doc = new Document(tempPath);
  23249. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  23250. //获取所填表格的序数
  23251. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  23252. Aspose.Words.Tables.Row titleRowClone = null;
  23253. Aspose.Words.Tables.Row CenterRowClone = null;
  23254. int index = 0;
  23255. int indexChi = 0;
  23256. int SetIndex = 0;
  23257. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  23258. //获取数据,放到datatable
  23259. foreach (var item in ApprovalTravelArr)
  23260. {
  23261. if (index > 0)
  23262. {
  23263. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  23264. tableOne.AppendChild(titleRowClone);
  23265. }
  23266. var textTime = item.Date;
  23267. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  23268. SetCells(tableOne, doc, SetIndex, 0, textTime, titleFont, bold);
  23269. SetIndex++;
  23270. if (ChiRep.Count > 0)
  23271. {
  23272. foreach (var itemChi in ChiRep)
  23273. {
  23274. var txtTime = itemChi.Time;
  23275. var txtDetail = itemChi.Details;
  23276. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  23277. {
  23278. //SetCells(tableOne, doc, SetIndex, 0, "", timeFont, bold);
  23279. //SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  23280. //indexChi++;
  23281. //SetIndex++;
  23282. break;
  23283. }
  23284. if (indexChi > 0)
  23285. {
  23286. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  23287. tableOne.AppendChild(CenterRowClone);
  23288. }
  23289. SetCells(tableOne, doc, SetIndex, 0, txtTime, timeFont, bold);
  23290. SetCells(tableOne, doc, SetIndex, 1, txtDetail, contentFont, bold);
  23291. indexChi++;
  23292. SetIndex++;
  23293. }
  23294. }
  23295. //else
  23296. //{
  23297. // if (indexChi > 0)
  23298. // {
  23299. // CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  23300. // tableOne.AppendChild(CenterRowClone);
  23301. // }
  23302. // SetCells(tableOne, doc, SetIndex, 0, "",timeFont, bold);
  23303. // SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  23304. // indexChi++;
  23305. // SetIndex++;
  23306. //}
  23307. index++;
  23308. }
  23309. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + fileName;
  23310. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName, Aspose.Words.SaveFormat.Docx); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  23311. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  23312. jw.Code = 200;
  23313. jw.Msg = "";
  23314. return Ok(jw);
  23315. }
  23316. private string ParseBlackTime(string time)
  23317. {
  23318. // 匹配可能只有分钟的情况
  23319. string pattern = @"(?:(\d+)H)?(?:(\d+)M)?";
  23320. System.Text.RegularExpressions.Match match = Regex.Match(time, pattern);
  23321. if (match.Success)
  23322. {
  23323. string hours = match.Groups[1].Value;
  23324. string minutes = match.Groups[2].Value;
  23325. // 如果小时部分为空,则只显示分钟
  23326. if (string.IsNullOrEmpty(hours))
  23327. {
  23328. return $"{minutes}分钟";
  23329. }
  23330. // 如果分钟部分为空,则只显示小时
  23331. else if (string.IsNullOrEmpty(minutes))
  23332. {
  23333. return $"{hours}小时";
  23334. }
  23335. // 否则显示完整格式
  23336. else
  23337. {
  23338. return $"{hours}小时{minutes}分钟";
  23339. }
  23340. }
  23341. else
  23342. {
  23343. return "未知时长";
  23344. }
  23345. }
  23346. private string intToString(int numberVal)
  23347. {
  23348. string numberval = numberVal.ToString();
  23349. Dictionary<char, string> Number = new Dictionary<char, string>();
  23350. Number.Add('1', "一");
  23351. Number.Add('2', "二");
  23352. Number.Add('3', "三");
  23353. Number.Add('4', "四");
  23354. Number.Add('5', "五");
  23355. Number.Add('6', "六");
  23356. Number.Add('7', "七");
  23357. Number.Add('8', "八");
  23358. Number.Add('9', "九");
  23359. string stringNumberVal = string.Empty;
  23360. for (int i = 0; i < numberval.Length; i++)
  23361. {
  23362. if (i == 0)
  23363. {
  23364. stringNumberVal += Number[numberval[i]];
  23365. }
  23366. else if (i >= 1)
  23367. {
  23368. if (numberval[i] == '0')
  23369. {
  23370. stringNumberVal = "十";
  23371. }
  23372. else
  23373. {
  23374. stringNumberVal += "十" + Number[numberval[i]];
  23375. }
  23376. }
  23377. }
  23378. return stringNumberVal;
  23379. }
  23380. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val, string font, bool bold)
  23381. {
  23382. //获取table中的某个单元格,从0开始
  23383. Cell lshCell = table.Rows[rows].Cells[cells];
  23384. //将单元格中段落移除
  23385. foreach (Paragraph item in lshCell.Paragraphs)
  23386. {
  23387. lshCell.Paragraphs.Remove(item);
  23388. }
  23389. if (val.Contains("\r\n"))
  23390. {
  23391. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  23392. foreach (var item in spArr)
  23393. {
  23394. //新建一个段落
  23395. Paragraph p = new Paragraph(doc);
  23396. var r = new Run(doc, item);
  23397. //设置字体
  23398. if (!string.IsNullOrEmpty(font))
  23399. {
  23400. r.Font.Name = font;
  23401. }
  23402. r.Font.Bold = bold;
  23403. //把设置的值赋给之前新建的段落
  23404. p.AppendChild(r);
  23405. //将此段落加到单元格内
  23406. lshCell.AppendChild(p);
  23407. }
  23408. }
  23409. else
  23410. {
  23411. //新建一个段落
  23412. Paragraph p = new Paragraph(doc);
  23413. var r = new Run(doc, val);
  23414. //设置字体
  23415. if (!string.IsNullOrEmpty(font))
  23416. {
  23417. r.Font.Name = font;
  23418. }
  23419. r.Font.Bold = bold;
  23420. //把设置的值赋给之前新建的段落
  23421. p.AppendChild(r);
  23422. //将此段落加到单元格内
  23423. lshCell.AppendChild(p);
  23424. }
  23425. }
  23426. /// <summary>
  23427. /// 报批行程AI续写
  23428. /// </summary>
  23429. /// <returns></returns>
  23430. [HttpPost]
  23431. public async Task<IActionResult> ApprovalJourneyAiWrite(ApprovalJourneyAiWriteDto dto)
  23432. {
  23433. var jw = JsonView(false);
  23434. if (dto.ClientPurpose.IsNullOrWhiteSpace() || dto.ClientName.IsNullOrWhiteSpace())
  23435. {
  23436. jw.Msg = "参数有误!";
  23437. return Ok(jw);
  23438. }
  23439. KiMiApiClient kiMi = new KiMiApiClient();
  23440. List<SeedMessages> messages = new List<SeedMessages>() {
  23441. new SeedMessages
  23442. {
  23443. Role = KimiRole.system,
  23444. Content = "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长中文和英文的对话。你会为用户提供安全,有帮助,准确的回答。"
  23445. },
  23446. new SeedMessages
  23447. {
  23448. Role = KimiRole.user,
  23449. Content = $@"参考这个模板格式来编写一份{dto.ClientName}拜访{dto.ClientPurpose},结合{dto.ClientName}的业务,描述拜访目的,字数在200字内(直接给出拜访目的,不输出其他内容)"
  23450. }
  23451. };
  23452. var kimi_result = await kiMi.SeedMessageByFullConterObject(messages);
  23453. string data = kimi_result.Choices[0]?.Message.Content;
  23454. if (string.IsNullOrWhiteSpace(data))
  23455. {
  23456. jw.Data = "Ai续写失败!";
  23457. }
  23458. else
  23459. {
  23460. jw = JsonView(true, "success!", data);
  23461. }
  23462. return Ok(jw);
  23463. }
  23464. #endregion
  23465. #region 团组接待意见调查
  23466. /// <summary>
  23467. /// 团组接待意见调查 - 信息管理
  23468. /// 基础数据(团组)
  23469. /// </summary>
  23470. /// <returns></returns>
  23471. [HttpGet]
  23472. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23473. public async Task<IActionResult> OpinionaireInit()
  23474. {
  23475. var groupData = await _groupRepository.Query(x => x.IsDel == 0)
  23476. .Select(x => new
  23477. {
  23478. x.Id,
  23479. GroupName = $"[{x.VisitDate.ToString("yyyy-MM-dd")}]{x.TeamName}"
  23480. })
  23481. .OrderByDescending(x => x.Id)
  23482. .ToListAsync();
  23483. return Ok(JsonView(groupData, groupData.Count));
  23484. }
  23485. /// <summary>
  23486. /// 团组接待意见调查 - 信息管理
  23487. /// 列表
  23488. /// </summary>
  23489. /// <param name="groupId"></param>
  23490. /// <returns></returns>
  23491. [HttpGet("{groupId}")]
  23492. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23493. public async Task<IActionResult> OpinionaireManageList(int groupId)
  23494. {
  23495. if (groupId < 1) Ok(JsonView(false, "请传入有效的diId"));
  23496. var data = await _opinionaireRep.Query(x => x.DiId == groupId)
  23497. .Select(x => new
  23498. {
  23499. x.Id,
  23500. x.TourGuideName,
  23501. x.CityName,
  23502. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x.CreateUserId == x1.Id).Select(x1 => x1.CnName),
  23503. x.CreateTime
  23504. })
  23505. .OrderBy(x => x.Id)
  23506. .ToListAsync();
  23507. return Ok(JsonView(data));
  23508. }
  23509. /// <summary>
  23510. /// 团组接待意见调查 - 信息管理
  23511. /// 保存
  23512. /// </summary>
  23513. /// <param name="dto"></param>
  23514. /// <returns></returns>
  23515. [HttpPost]
  23516. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23517. public async Task<IActionResult> OpinionaireManageSave(OpinionaireManageSaveDto dto)
  23518. {
  23519. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  23520. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  23521. if (dto.DiId < 1) Ok(JsonView(false, "请传入有效的diId"));
  23522. if (dto.Items.Length < 1) Ok(JsonView(false, "请传入需要保存的信息"));
  23523. var addData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id == 0).ToList());
  23524. var updData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id > 0).ToList());
  23525. _opinionaireRep.BeginTran();
  23526. if (addData != null && addData.Count > 0)
  23527. {
  23528. foreach (var item in addData)
  23529. {
  23530. item.CreateUserId = currUserInfo.UserId;
  23531. item.DiId = dto.DiId;
  23532. }
  23533. var add = await _opinionaireRep._sqlSugar.Insertable(addData).ExecuteCommandAsync();
  23534. }
  23535. if (updData != null && updData.Count > 0)
  23536. {
  23537. var upd = await _opinionaireRep._sqlSugar
  23538. .Updateable(updData)
  23539. .UpdateColumns(x => new { x.CityName, x.TourGuideName })
  23540. .WhereColumns(x => new { x.Id })
  23541. .ExecuteCommandAsync();
  23542. }
  23543. _opinionaireRep.CommitTran();
  23544. return Ok(JsonView("操作成功!"));
  23545. }
  23546. /// <summary>
  23547. /// 团组接待意见调查 - 信息管理
  23548. /// 删除
  23549. /// </summary>
  23550. /// <param name="id"></param>
  23551. /// <returns></returns>
  23552. [HttpDelete("{id}")]
  23553. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23554. public async Task<IActionResult> OpinionaireManageDel(int id)
  23555. {
  23556. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  23557. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  23558. if (id < 1) Ok(JsonView(false, "请传入有效的id"));
  23559. var del = await _opinionaireRep.SoftDeleteAsync(x => x.Id == id, currUserInfo.UserId);
  23560. if (!del) return Ok(JsonView("操作失败!"));
  23561. return Ok(JsonView("操作成功!"));
  23562. }
  23563. /// <summary>
  23564. /// 团组接待意见调查 - 用户
  23565. /// 列表
  23566. /// </summary>
  23567. /// <param name="diId"></param>
  23568. /// <returns></returns>
  23569. [HttpGet("{diId}")]
  23570. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23571. public async Task<IActionResult> OpinionaireUserList(int diId)
  23572. {
  23573. if (diId < 1) Ok(JsonView(false, "请传入有效的diId"));
  23574. var sql = string.Format(@"
  23575. SELECT
  23576. o.Id,
  23577. o.DiId,
  23578. di.TeamName AS 'GroupName',
  23579. di.VisitPNumber AS 'PeopleNumber',
  23580. di.ClientName AS 'LeadGroup',
  23581. di.VisitCountry AS 'Travel',
  23582. di.VisitDays AS 'Days',
  23583. o.CityName,
  23584. o.TourGuideName,
  23585. o.Catering,
  23586. o.CateringReason,
  23587. o.Stay,
  23588. o.StayReason,
  23589. o.[Route],
  23590. o.RouteReason,
  23591. o.OfficialActivity,
  23592. o.OfficialActivityReason,
  23593. o.TourGuide,
  23594. o.TourGuideReason,
  23595. o.[Translate],
  23596. o.TranslateReason,
  23597. o.Trip,
  23598. o.TripReason,
  23599. o.ESFileName,
  23600. o.SignatureDate,
  23601. o.Remark
  23602. FROM
  23603. Grp_Opinionaire o
  23604. LEFT JOIN Grp_DelegationInfo di ON o.DiId = di.Id
  23605. WHERE
  23606. o.IsDel = 0
  23607. AND o.DiId = {0}
  23608. ORDER BY
  23609. o.Id ASC", diId);
  23610. var data = await _sqlSugar.SqlQueryable<OpinionaireUserListView>(sql).ToListAsync();
  23611. if (data.Count < 1) return Ok(JsonView(false, "暂无数据"));
  23612. return Ok(JsonView(data));
  23613. }
  23614. /// <summary>
  23615. /// 团组接待意见调查 - 用户
  23616. /// 保存
  23617. /// </summary>
  23618. /// <param name="dto"></param>
  23619. /// <returns></returns>
  23620. [HttpPost]
  23621. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23622. public async Task<IActionResult> OpinionaireUserSave([FromForm] OpinionaireUserSaveInfo[] dto)
  23623. {
  23624. if (dto.Length < 1) Ok(JsonView(false, "请传入有效的参数"));
  23625. foreach (var item in dto)
  23626. {
  23627. if (string.IsNullOrEmpty(item.Catering)) Ok(JsonView(false, "请选择餐饮评分!"));
  23628. if (string.IsNullOrEmpty(item.Stay)) Ok(JsonView(false, "请选择住宿评分!"));
  23629. if (string.IsNullOrEmpty(item.Route)) Ok(JsonView(false, "请选择行程评分!"));
  23630. if (string.IsNullOrEmpty(item.OfficialActivity)) Ok(JsonView(false, "请选择公务活动评分!"));
  23631. if (string.IsNullOrEmpty(item.Translate)) Ok(JsonView(false, "请选择翻译评分!"));
  23632. if (string.IsNullOrEmpty(item.Trip)) Ok(JsonView(false, "请选择行程评分!"));
  23633. if (string.IsNullOrEmpty(item.SignatureDate)) Ok(JsonView(false, "请填写签名日期!"));
  23634. if (item.File.Length < 1) Ok(JsonView(false, "请上传签名图片!"));
  23635. }
  23636. var filePathBase = $"{AppSettingsHelper.Get("GrpFileBasePath")}OpinionaireElectronicSignature";
  23637. if (!Directory.Exists(filePathBase))
  23638. {
  23639. Directory.CreateDirectory(filePathBase);
  23640. }
  23641. #region 上传文件
  23642. var filePaths = new List<string>();
  23643. foreach (var item in dto)
  23644. {
  23645. var file = item.File;
  23646. // 将文件保存到指定位置
  23647. var filePath = Path.Combine(filePathBase, file.FileName);
  23648. using (var stream = new FileStream(filePath, FileMode.Create))
  23649. {
  23650. await file.CopyToAsync(stream);
  23651. }
  23652. //验证文件是否上传成功
  23653. if (!System.IO.File.Exists(filePath))
  23654. {
  23655. foreach (var filePathStr in filePaths)
  23656. {
  23657. System.IO.File.Delete(filePathStr);
  23658. }
  23659. return Ok(JsonView(false, "文件上传失败!"));
  23660. }
  23661. item.ESFileName = file.FileName;
  23662. }
  23663. #endregion
  23664. var infos = _mapper.Map<List<Grp_Opinionaire>>(dto);
  23665. var upd = await _sqlSugar.Updateable<Grp_Opinionaire>(infos)
  23666. .UpdateColumns(x => new
  23667. {
  23668. x.Catering,
  23669. x.CateringReason,
  23670. x.Stay,
  23671. x.StayReason,
  23672. x.Route,
  23673. x.RouteReason,
  23674. x.OfficialActivity,
  23675. x.OfficialActivityReason,
  23676. x.TourGuide,
  23677. x.TourGuideReason,
  23678. x.Translate,
  23679. x.TranslateReason,
  23680. x.Trip,
  23681. x.TripReason,
  23682. x.ESFileName,
  23683. x.SignatureDate,
  23684. x.Remark
  23685. })
  23686. .WhereColumns(x => new { x.Id })
  23687. .ExecuteCommandAsync();
  23688. if (upd < 1)
  23689. {
  23690. foreach (var filePathStr in filePaths)
  23691. {
  23692. System.IO.File.Delete(filePathStr);
  23693. }
  23694. return Ok(JsonView(false));
  23695. }
  23696. return Ok(JsonView(true));
  23697. }
  23698. #endregion
  23699. #region 团组餐厅相关信息
  23700. /// <summary>
  23701. /// 团组相关餐厅信息
  23702. /// 基础数据(团组)
  23703. /// </summary>
  23704. /// <returns></returns>
  23705. [HttpGet]
  23706. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23707. public async Task<IActionResult> RestaurantInit()
  23708. {
  23709. return Ok(await _restaurantRep.InitAsync());
  23710. }
  23711. /// <summary>
  23712. /// 团组相关餐厅信息
  23713. /// Item
  23714. /// </summary>
  23715. /// <param name="dto"></param>
  23716. /// <returns></returns>
  23717. [HttpPost]
  23718. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23719. public async Task<IActionResult> RestaurantItem(RestaurantItemDto dto)
  23720. {
  23721. int portType = dto.PortType,
  23722. groupId = dto.GroupId;
  23723. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  23724. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  23725. return Ok(await _restaurantRep.ItemAsync(portType, groupId));
  23726. }
  23727. /// <summary>
  23728. /// 团组相关餐厅信息
  23729. /// List
  23730. /// </summary>
  23731. /// <param name="dto"></param>
  23732. /// <returns></returns>
  23733. [HttpPost]
  23734. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23735. public async Task<IActionResult> RestaurantList(RestaurantItemDto dto)
  23736. {
  23737. int portType = dto.PortType,
  23738. groupId = dto.GroupId;
  23739. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  23740. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  23741. var sql = string.Format(@" SELECT
  23742. ri.Id,
  23743. ri.GroupId,
  23744. ri.Date,
  23745. ri.StartTime,
  23746. ri.EndTime,
  23747. CASE WHEN ri.Type = 1 THEN '早餐'
  23748. WHEN ri.Type = 2 THEN '午餐'
  23749. WHEN ri.Type = 3 THEN '晚餐'
  23750. ELSE '其他'
  23751. END AS 'Type',
  23752. ri.Name,
  23753. ri.Address,
  23754. ri.Tel,
  23755. ri.Remark,
  23756. ri.CreateTime,
  23757. u.CnName AS CreateUserName
  23758. FROM
  23759. Grp_RestaurantInfo ri
  23760. LEFT JOIN Sys_Users u ON ri.CreateUserId = u.Id
  23761. WHERE
  23762. ri.IsDel = 0
  23763. AND ri.GroupId = {0}
  23764. ORDER BY
  23765. ri.Date ASC
  23766. ", groupId);
  23767. var infos = await _sqlSugar.SqlQueryable<RestaurantItemView>(sql).ToListAsync();
  23768. if (!infos.Any()) Ok(JsonView(false, "数据未填写!"));
  23769. return Ok(JsonView(infos));
  23770. }
  23771. /// <summary>
  23772. /// 团组相关餐厅信息
  23773. /// Info
  23774. /// </summary>
  23775. /// <param name="dto"></param>
  23776. /// <returns></returns>
  23777. [HttpPost]
  23778. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23779. public async Task<IActionResult> RestaurantInfo(RestaurantInfoDto dto)
  23780. {
  23781. int portType = dto.PortType,
  23782. id = dto.Id;
  23783. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  23784. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  23785. return Ok(await _restaurantRep.InfoAsync(portType, id));
  23786. }
  23787. /// <summary>
  23788. /// 团组相关餐厅信息
  23789. /// Op
  23790. /// </summary>
  23791. /// <param name="dto"></param>
  23792. /// <returns></returns>
  23793. [HttpPost]
  23794. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23795. public async Task<IActionResult> RestaurantOp(RestaurantOpDto dto)
  23796. {
  23797. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  23798. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  23799. if (string.IsNullOrEmpty(dto.Name)) return Ok(JsonView(false, "餐厅名称为空!"));
  23800. return Ok(await _restaurantRep.OpAsync(dto));
  23801. }
  23802. /// <summary>
  23803. /// 团组相关餐厅信息
  23804. /// Del
  23805. /// </summary>
  23806. /// <param name="dto"></param>
  23807. /// <returns></returns>
  23808. [HttpPost]
  23809. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23810. public async Task<IActionResult> RestaurantDel(RestaurantDelDto dto)
  23811. {
  23812. int userId = dto.DeleteUserId;
  23813. var id = dto.Id;
  23814. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  23815. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  23816. return Ok(await _restaurantRep.DelAsync(dto));
  23817. }
  23818. #endregion
  23819. #region 团组会务成本
  23820. /// <summary>
  23821. /// 团组会务成本数据初始化
  23822. /// </summary>
  23823. /// <returns></returns>
  23824. [HttpPost]
  23825. public async Task<IActionResult> ConferenceAffairsInIt(ConferenceAffairsInItDto Dto)
  23826. {
  23827. var expr = _sqlSugar.Queryable<Grp_DelegationInfo>()
  23828. .OrderByDescending(x => x.CreateTime)
  23829. .Where(x => x.IsDel == 0)
  23830. .Select<DelegationEasyView>();
  23831. DelegationEasyView di = Dto.GroupId == 0 ?
  23832. expr.First() :
  23833. expr.First(x => x.Id == Dto.GroupId);
  23834. if (di == null)
  23835. {
  23836. return Ok(JsonView(false, "团组信息不存在!"));
  23837. }
  23838. var typeData = await _sqlSugar.Queryable<Sys_SetData>()
  23839. .Where(x => x.IsDel == 0 && x.STid == 21)
  23840. .Select(x => new { x.Id, Text = x.Name })
  23841. .ToListAsync();
  23842. var hwids = _sqlSugar.Queryable<Sys_SetData>()
  23843. .Where(x => x.IsDel == 0 && x.STid == 10 && x.Name.Contains("会务活动"))
  23844. .Select(x => x.Id)
  23845. .ToList();
  23846. //仅检索会务团组
  23847. var groupList = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  23848. .Where(x => x.IsDel == 0 && hwids.Contains(x.TeamDid))
  23849. .OrderByDescending(x => x.VisitDate)
  23850. .Select(x => new { x.Id, x.TeamName })
  23851. .ToListAsync();
  23852. var currenyList = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(1, di.Id, 98);
  23853. var userList = await _sqlSugar.Queryable<Sys_Users>()
  23854. .Where(x => x.IsDel == 0)
  23855. .Select(x => new { x.Id, x.CnName })
  23856. .ToListAsync();
  23857. var units = await _sqlSugar.Queryable<Sys_SetData>()
  23858. .Where(x => x.IsDel == 0 && x.STid == 119)
  23859. .Select(x => new { x.Id, Text = x.Name })
  23860. .ToListAsync();
  23861. var FileType = new[]
  23862. {
  23863. new { Id = 0 , Name = "成本下载" },
  23864. new { Id = 1 , Name = "报价下载" },
  23865. new { Id = 2 , Name = "总表下载" },
  23866. };
  23867. var GM = new List<int>();
  23868. var permissionControlDB = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1448)?.Remark;
  23869. try
  23870. {
  23871. GM = JsonConvert.DeserializeObject<List<int>>(permissionControlDB);
  23872. }
  23873. catch (Exception ex)
  23874. {
  23875. GM = new List<int>() { 21 };
  23876. }
  23877. var isReview = Dto.UserId == 21;
  23878. var isGM = GM.Contains(Dto.UserId);
  23879. var ConferenceAffairsCost = _sqlSugar.Queryable<Grp_ConferenceAffairsCost>()
  23880. .Where(x => x.IsDel == 0)
  23881. .Select<ConferenceAffairsCostView>()
  23882. .First(x => x.Diid == di.Id);
  23883. if (ConferenceAffairsCost == null)
  23884. {
  23885. ConferenceAffairsCost = new ConferenceAffairsCostView();
  23886. ConferenceAffairsCost.Diid = di.Id;
  23887. }
  23888. #region 权限校验
  23889. var ids = _sqlSugar.Queryable<Grp_ConferenceAffairsCostControl>()
  23890. .Where(x => x.Diid == di.Id && x.IsDel == 0)
  23891. .Select(x => x.UserId)
  23892. .Distinct()
  23893. .ToList();
  23894. if (!ids.Contains(Dto.UserId) && !isGM)
  23895. {
  23896. return Ok(JsonView(201, "暂无权限!", new
  23897. {
  23898. typeData,
  23899. groupList,
  23900. currenyList,
  23901. isGM,
  23902. userList,
  23903. units,
  23904. isReview,
  23905. operatorUser = ids,
  23906. di,
  23907. FileType
  23908. }));
  23909. }
  23910. #endregion
  23911. var ConferenceAffairsCostChi = _sqlSugar.Queryable<Grp_ConferenceAffairsCostChild>()
  23912. .Where(x => x.IsDel == 0 && x.Diid == di.Id)
  23913. .Select<ConferenceAffairsCostChildView>()
  23914. .OrderBy(x => x.Index)
  23915. .ToList();
  23916. for (int i = 1; i <= ConferenceAffairsCostChi.Count; i++)
  23917. {
  23918. ConferenceAffairsCostChi[i - 1].Index = i;
  23919. }
  23920. var backData = new
  23921. {
  23922. ConferenceAffairsCost,
  23923. ConferenceAffairsCostChi,
  23924. typeData,
  23925. groupList,
  23926. currenyList,
  23927. isGM,
  23928. userList,
  23929. units,
  23930. isReview,
  23931. operatorUser = ids,
  23932. di,
  23933. FileType
  23934. };
  23935. return Ok(JsonView(true, "SUCCESS", backData));
  23936. }
  23937. /// <summary>
  23938. /// 会务成本保存
  23939. /// </summary>
  23940. /// <returns></returns>
  23941. [HttpPost]
  23942. public async Task<IActionResult> ConferenceAffairsSave(ConferenceAffairsSaveDto Dto)
  23943. {
  23944. _sqlSugar.BeginTran();
  23945. var data = _mapper.Map<Grp_ConferenceAffairsCost>(Dto.ConferenceAffairsCost);
  23946. var childResult = new
  23947. {
  23948. success = 0,
  23949. error = 0
  23950. };
  23951. try
  23952. {
  23953. if (data.Id == 0)
  23954. {
  23955. _sqlSugar.Updateable<Grp_ConferenceAffairsCost>()
  23956. .Where(x => x.Diid == Dto.GroupId)
  23957. .SetColumns(x => new Grp_ConferenceAffairsCost
  23958. {
  23959. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  23960. DeleteUserId = Dto.UserId
  23961. })
  23962. .ExecuteCommand();
  23963. data.Diid = Dto.GroupId;
  23964. data.CreateTime = DateTime.Now;
  23965. data.CreateUserId = Dto.UserId;
  23966. data.Id = _sqlSugar.Insertable<Grp_ConferenceAffairsCost>(data)
  23967. .ExecuteReturnIdentity();
  23968. }
  23969. else
  23970. {
  23971. _sqlSugar.Updateable<Grp_ConferenceAffairsCost>(data)
  23972. .ExecuteCommand();
  23973. data.Id = data.Id;
  23974. }
  23975. if (Dto.ConferenceAffairsCostChild.Any())
  23976. {
  23977. var datas = _mapper.Map<List<Grp_ConferenceAffairsCostChild>>(Dto.ConferenceAffairsCostChild);
  23978. var insertArr = datas.Where(x => x.Id == 0).ToList();
  23979. var updateArr = datas.Where(x => x.Id != 0 && x.ReviewStatus != 1).ToList();
  23980. var notUpdateArr = datas.Where(x => x.Id != 0 && x.ReviewStatus == 1).ToList();
  23981. insertArr.ForEach(x => { x.Diid = Dto.GroupId; x.ConferenceAffairsCostId = data.Id; });
  23982. var inrsetCount = insertArr.Any() ? _sqlSugar.Insertable<Grp_ConferenceAffairsCostChild>(insertArr).ExecuteCommand() : 0;
  23983. var updateCount = updateArr.Any() ? _sqlSugar.Updateable<Grp_ConferenceAffairsCostChild>(updateArr)
  23984. .IgnoreColumns(x => new { x.ConferenceAffairsCostId })
  23985. .ExecuteCommand() : 0;
  23986. childResult = childResult with
  23987. {
  23988. error = notUpdateArr.Count(),
  23989. success = inrsetCount + updateCount
  23990. };
  23991. }
  23992. _sqlSugar.CommitTran();
  23993. }
  23994. catch (Exception ex)
  23995. {
  23996. _sqlSugar.RollbackTran();
  23997. return Ok(JsonView(false, "失败!" + ex.Message));
  23998. }
  23999. return Ok(JsonView(true, "操作成功!", childResult));
  24000. }
  24001. [HttpPost]
  24002. public async Task<IActionResult> ConferenceAffairsAudit(ConferenceAffairsAuditDto Dto)
  24003. {
  24004. var count = 0;
  24005. if (Dto.ConferenceAffairsCostChildids.Any())
  24006. {
  24007. count = _sqlSugar.Updateable<Grp_ConferenceAffairsCostChild>().
  24008. Where(x => Dto.ConferenceAffairsCostChildids.Contains(x.Id)).
  24009. SetColumns(x => new Grp_ConferenceAffairsCostChild
  24010. {
  24011. ReviewStatus = Dto.ReviewStatus
  24012. }).
  24013. ExecuteCommand();
  24014. }
  24015. return Ok(JsonView(true, "操作成功!", count));
  24016. }
  24017. /// <summary>
  24018. /// 会务成本所有数据清除
  24019. /// </summary>
  24020. /// <param name="Dto"></param>
  24021. /// <returns></returns>
  24022. [HttpPost]
  24023. public async Task<IActionResult> ConferenceAffairsDelete(ConferenceAffairsDeleteDto Dto)
  24024. {
  24025. if (Dto.GroupId < 1) return Ok(JsonView(false, "请传入有效的Id"));
  24026. if (Dto.UserId < 1) return Ok(JsonView(false, "请传入有效的用户Id"));
  24027. _sqlSugar.BeginTran();
  24028. try
  24029. {
  24030. var delCount = _sqlSugar.Updateable<Grp_ConferenceAffairsCost>()
  24031. .Where(x => x.Diid == Dto.GroupId)
  24032. .SetColumns(x => new Grp_ConferenceAffairsCost
  24033. {
  24034. IsDel = 1,
  24035. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  24036. DeleteUserId = Dto.UserId
  24037. })
  24038. .ExecuteCommand();
  24039. if (delCount > 0)
  24040. {
  24041. _sqlSugar.Updateable<Grp_ConferenceAffairsCostChild>()
  24042. .Where(x => x.Diid == Dto.GroupId)
  24043. .SetColumns(x => new Grp_ConferenceAffairsCostChild
  24044. {
  24045. IsDel = 1,
  24046. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  24047. DeleteUserId = Dto.UserId
  24048. })
  24049. .ExecuteCommand();
  24050. _sqlSugar.Updateable<Grp_ConferenceAffairsCostControl>()
  24051. .Where(x => x.Diid == Dto.GroupId && x.IsDel == 0)
  24052. .SetColumns(x => new Grp_ConferenceAffairsCostControl
  24053. {
  24054. IsDel = 1,
  24055. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  24056. DeleteUserId = Dto.UserId
  24057. })
  24058. .ExecuteCommand();
  24059. }
  24060. _sqlSugar.CommitTran();
  24061. }
  24062. catch (Exception ex)
  24063. {
  24064. _sqlSugar.RollbackTran();
  24065. return Ok(JsonView(false, "操作失败!" + ex.Message));
  24066. }
  24067. return Ok(JsonView(true, "操作成功!"));
  24068. }
  24069. /// <summary>
  24070. /// 子项数据删除
  24071. /// </summary>
  24072. /// <param name="Dto"></param>
  24073. /// <returns></returns>
  24074. [HttpPost]
  24075. public async Task<IActionResult> ConferenceAffairSinglesDelete(ConferenceAffairsDeleteSingleDto Dto)
  24076. {
  24077. var isAudit = _sqlSugar.Queryable<Grp_ConferenceAffairsCostChild>().Where(x => x.IsDel == 0 && Dto.ids.Contains(x.Id))
  24078. .Any(x => x.ReviewStatus == 1);
  24079. if (isAudit) return Ok(JsonView(false, "包含已审核数据无法删除!"));
  24080. var count = _sqlSugar.Updateable<Grp_ConferenceAffairsCostChild>()
  24081. .Where(x => Dto.ids.Contains(x.Id) && x.IsDel == 0)
  24082. .SetColumns(x => new Grp_ConferenceAffairsCostChild
  24083. {
  24084. IsDel = 1,
  24085. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  24086. DeleteUserId = Dto.UserId
  24087. })
  24088. .ExecuteCommand();
  24089. return Ok(JsonView(true, "SUCCESS!", count));
  24090. }
  24091. /// <summary>
  24092. /// 会务成本权限分配
  24093. /// </summary>
  24094. /// <param name="Dto"></param>
  24095. /// <returns></returns>
  24096. [HttpPost]
  24097. public async Task<IActionResult> PermissionSetting(PermissionSettingDto Dto)
  24098. {
  24099. _sqlSugar.BeginTran();
  24100. var count = 0;
  24101. try
  24102. {
  24103. _sqlSugar.Updateable<Grp_ConferenceAffairsCostControl>()
  24104. .Where(x => x.Diid == Dto.GroupId && x.IsDel == 0)
  24105. .SetColumns(x => new Grp_ConferenceAffairsCostControl
  24106. {
  24107. IsDel = 1,
  24108. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  24109. DeleteUserId = Dto.CreateUserId
  24110. })
  24111. .ExecuteCommand();
  24112. count = _sqlSugar.Insertable<Grp_ConferenceAffairsCostControl>(Dto.UserIds.Select(x => new Grp_ConferenceAffairsCostControl
  24113. {
  24114. CreateTime = DateTime.Now,
  24115. CreateUserId = Dto.CreateUserId,
  24116. UserId = x,
  24117. Diid = Dto.GroupId,
  24118. }).ToList()).ExecuteCommand();
  24119. _sqlSugar.CommitTran();
  24120. }
  24121. catch (Exception ex)
  24122. {
  24123. _sqlSugar.RollbackTran();
  24124. return Ok(JsonView(false, "操作失败!" + ex.Message));
  24125. }
  24126. return Ok(JsonView(true, "操作成功!", count));
  24127. }
  24128. /// <summary>
  24129. /// 团组会务成本文件下载
  24130. /// </summary>
  24131. /// <returns></returns>
  24132. [HttpPost]
  24133. public async Task<IActionResult> ConferenceAffairsFileDown(ConferenceAffairsFileDownDto Dto)
  24134. {
  24135. var FileType = new[]
  24136. {
  24137. new { Id = 0 , Name = "成本下载" },
  24138. new { Id = 1 , Name = "报价下载" },
  24139. new { Id = 2 , Name = "总表下载" },
  24140. };
  24141. if (Dto.GroupId < 1) return Ok(JsonView(false, "请传入有效的Id"));
  24142. if (Dto.FileTypeId < 0 || Dto.FileTypeId > 2) return Ok(JsonView(false, "请传入有效的文件类型"));
  24143. var di = _sqlSugar.Queryable<Grp_DelegationInfo>()
  24144. .Where(x => x.IsDel == 0 && x.Id == Dto.GroupId)
  24145. .Select<DelegationEasyView>()
  24146. .First();
  24147. var main = _sqlSugar.Queryable<Grp_ConferenceAffairsCost>()
  24148. .First(x => x.Diid == Dto.GroupId && x.IsDel == 0);
  24149. if (main == null)
  24150. {
  24151. return Ok(JsonView(false, "团组会务成本信息不存在!"));
  24152. }
  24153. JsonView jw = JsonView(false);
  24154. //总表下载
  24155. var loadPath = $"{AppSettingsHelper.Get("ExcelBasePath")}ConferenceAffairs/template/";
  24156. var outputPath = $"{AppSettingsHelper.Get("ExcelBasePath")}ConferenceAffairs/output/total/";
  24157. var networkPath = outputPath.Replace(AppSettingsHelper.Get("ExcelBasePath"), AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath"));
  24158. var field = string.Empty;
  24159. var fileTypeName = string.Empty;
  24160. field = @$"
  24161. a.[Index],a.PriceName,a.CostPrice,a.Count,a.Coefficient,a.BaoJiaPrice,a.AddedValue,a.Details,a.Remark,a.Rate,
  24162. b.Name as PriceTypeStr ,
  24163. c.Name as CurrencyStr ,
  24164. d.Name as UnitStr ,
  24165. case a.ReviewStatus
  24166. WHEN 1 THEN '已通过'
  24167. WHEN 0 THEN '未审核'
  24168. WHEN -1 THEN '未通过'
  24169. ELSE '未审核'
  24170. END AS ReviewStatusStr
  24171. ";
  24172. if (Dto.FileTypeId == 0)
  24173. {
  24174. fileTypeName = "会务成本成本表";
  24175. loadPath += $"{fileTypeName}.xlsx";
  24176. outputPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  24177. networkPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  24178. }
  24179. else if (Dto.FileTypeId == 1)
  24180. {
  24181. fileTypeName = "会务成本报价表";
  24182. loadPath += $"{fileTypeName}.xlsx";
  24183. outputPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  24184. networkPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  24185. }
  24186. else if (Dto.FileTypeId == 2)
  24187. {
  24188. fileTypeName = "会务成本总表";
  24189. loadPath += $"{fileTypeName}.xlsx";
  24190. outputPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  24191. networkPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  24192. }
  24193. var chiExcelContent = _sqlSugar.SqlQueryable<ConferenceAffairsExcelContent>(@$"
  24194. SELECT
  24195. {field}
  24196. FROM Grp_ConferenceAffairsCostChild a
  24197. LEFT JOIN Sys_SetData b on b.IsDel = 0 AND b.Id = a.PriceType
  24198. LEFT JOIN Sys_SetData c on c.IsDel = 0 AND c.Id = a.Currency
  24199. LEFT JOIN Sys_SetData d on d.IsDel = 0 AND d.Id = a.Unit
  24200. WHERE a.isdel = 0
  24201. AND a.Diid = {main.Diid}
  24202. AND a.ConferenceAffairsCostId = {main.Id}
  24203. ").ToList();
  24204. var currLists = chiExcelContent.Select(x => new CurrList
  24205. {
  24206. CurrName = x.CurrencyStr,
  24207. CurrRate = x.Rate
  24208. })
  24209. .Distinct()
  24210. .ToList();
  24211. var designer = new WorkbookDesigner
  24212. {
  24213. Workbook = new Workbook(loadPath)
  24214. };
  24215. var MostCurr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.IsDel == 0 && x.Id == main.MostCurr);
  24216. MostCurr ??= new Sys_SetData { Name = "暂无!" };
  24217. designer.SetDataSource("TeamName", di.TeamName);
  24218. designer.SetDataSource("City", main.City);
  24219. designer.SetDataSource("AllCost", main.CostAll);
  24220. designer.SetDataSource("AllBaoJia", main.BaoJiaAll);
  24221. designer.SetDataSource("Curr", MostCurr.Name);
  24222. designer.SetDataSource("Curr1", MostCurr.Name);
  24223. DataTable dt = CommonFun.GetDataTableFromIList<ConferenceAffairsExcelContent>(chiExcelContent);
  24224. dt.TableName = "TB";
  24225. designer.SetDataSource(dt);
  24226. DataTable dt1 = CommonFun.GetDataTableFromIList<CurrList>(currLists);
  24227. dt1.TableName = "currTb";
  24228. designer.SetDataSource(dt1);
  24229. designer.Process();
  24230. designer.Workbook.Save(outputPath);
  24231. jw = JsonView(true, "操作成功!", new
  24232. {
  24233. FileName = $"{di.TeamName}_{fileTypeName}.xlsx",
  24234. FilePath = networkPath
  24235. });
  24236. return Ok(jw);
  24237. }
  24238. [HttpPost]
  24239. public async Task<IActionResult> QueryConferenceAffairsChild(QueryConferenceAffairsChildDto Dto)
  24240. {
  24241. return Ok(JsonView(true, "SUCCESS", _sqlSugar.Queryable<Grp_ConferenceAffairsCostChild>().Where(x => x.IsDel == 0 && x.Diid == Dto.GroupId)
  24242. .Select(x => x.PriceName).ToList()));
  24243. }
  24244. #endregion
  24245. #region 会务流程
  24246. /// <summary>
  24247. /// 会务流程 - 数据初始化
  24248. /// </summary>
  24249. /// <param name="dto"></param>
  24250. /// <returns>团组基本信息、团组列表和会务基本信息列表</returns>
  24251. [HttpPost]
  24252. public async Task<IActionResult> ConferenceProceduresInit(ConferenceProceduresInitDto dto)
  24253. {
  24254. try
  24255. {
  24256. Grp_DelegationInfo targetGroup = null;
  24257. targetGroup = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  24258. .Where(x => x.Id == dto.GroupId && x.IsDel == 0)
  24259. .FirstAsync();
  24260. if (targetGroup == null)
  24261. {
  24262. targetGroup = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  24263. .Where(x => x.IsDel == 0)
  24264. .OrderByDescending(x => x.CreateTime)
  24265. .FirstAsync();
  24266. }
  24267. if (targetGroup == null)
  24268. {
  24269. return Ok(JsonView(false, "未找到任何团组信息"));
  24270. }
  24271. var groupList = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  24272. .Where(x => x.IsDel == 0)
  24273. .OrderByDescending(x => x.CreateTime)
  24274. .Select(x => new { x.Id, x.TeamName })
  24275. .ToListAsync();
  24276. var conferenceProceduresList = await _sqlSugar.Queryable<Grp_ConferenceProcedures>()
  24277. .Where(x => x.DiId == targetGroup.Id && x.IsDel == 0)
  24278. .Select(x => new { x.Id, x.Title, x.DataDetails, x.Details, x.Remark })
  24279. .ToListAsync();
  24280. if (!conferenceProceduresList.Any())
  24281. {
  24282. conferenceProceduresList = await _sqlSugar.Queryable<Grp_ConferenceProcedures>()
  24283. .Where(x => x.DiId == -1 && x.IsDel == 0)
  24284. .Select(x => new { x.Id, x.Title, x.DataDetails, x.Details, x.Remark })
  24285. .ToListAsync();
  24286. }
  24287. var conferenceProceduresGroupByTitle = conferenceProceduresList
  24288. .GroupBy(x => x.Title)
  24289. .Select(x => new
  24290. {
  24291. title = x.Key,
  24292. itmes = x.Select(y => new
  24293. {
  24294. y.Id,
  24295. y.DataDetails,
  24296. y.Details,
  24297. y.Remark
  24298. }).ToList()
  24299. })
  24300. .ToList();
  24301. var response = new
  24302. {
  24303. GroupInfo = new
  24304. {
  24305. targetGroup.Id,
  24306. targetGroup.TeamName,
  24307. targetGroup.VisitDate,
  24308. targetGroup.VisitDays,
  24309. targetGroup.VisitPNumber,
  24310. targetGroup.VisitCountry,
  24311. targetGroup.VisitStartDate,
  24312. targetGroup.VisitEndDate,
  24313. targetGroup.ClientName,
  24314. targetGroup.ClientUnit
  24315. },
  24316. GroupList = groupList,
  24317. ConferenceProceduresList = conferenceProceduresList,
  24318. conferenceProceduresGroupByTitle = conferenceProceduresGroupByTitle
  24319. };
  24320. return Ok(JsonView(true, "SUCCESS", response));
  24321. }
  24322. catch (Exception ex)
  24323. {
  24324. _logger.LogError(ex, "数据初始化失败");
  24325. return Ok(JsonView(false, $"ERROR:{ex.Message}"));
  24326. }
  24327. }
  24328. /// <summary>
  24329. /// 会务流程 - 保存
  24330. /// </summary>
  24331. /// <param name="dto"></param>
  24332. /// <returns></returns>
  24333. [HttpPost]
  24334. public async Task<IActionResult> ConferenceProceduresSave(ConferenceProceduresSaveDto dto)
  24335. {
  24336. _sqlSugar.BeginTran();
  24337. try
  24338. {
  24339. //删除旧数据
  24340. _sqlSugar.Updateable<Grp_ConferenceProcedures>()
  24341. .Where(x => x.DiId == dto.GroupId && x.IsDel == 0)
  24342. .SetColumns(x => new Grp_ConferenceProcedures
  24343. {
  24344. IsDel = 1,
  24345. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  24346. DeleteUserId = dto.UserId
  24347. })
  24348. .ExecuteCommand();
  24349. //添加新数据
  24350. var newData = new List<Grp_ConferenceProcedures>();
  24351. foreach (var item in dto.ConferenceProceduresSaveItem)
  24352. {
  24353. foreach (var item2 in item.itmes)
  24354. {
  24355. newData.Add(new Grp_ConferenceProcedures
  24356. {
  24357. DiId = dto.GroupId,
  24358. Title = item.title,
  24359. DataDetails = item2.DataDetails,
  24360. Details = item2.details,
  24361. Remark = item2.Remark,
  24362. CreateTime = DateTime.Now,
  24363. CreateUserId = dto.UserId
  24364. });
  24365. }
  24366. }
  24367. _sqlSugar.Insertable(newData).ExecuteCommand();
  24368. _sqlSugar.CommitTran();
  24369. }
  24370. catch (Exception ex)
  24371. {
  24372. _sqlSugar.RollbackTran();
  24373. return Ok(JsonView(false, $"ERROR:{ex.Message}"));
  24374. }
  24375. return Ok(JsonView(true, "SUCCESS"));
  24376. }
  24377. [HttpPost]
  24378. public async Task<IActionResult> ConferenceProceduresFileDown(ConferenceProceduresFileDownDto dto)
  24379. {
  24380. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  24381. .Where(x => x.Id == dto.GroupId && x.IsDel == 0)
  24382. .FirstAsync();
  24383. if (groupInfo == null)
  24384. {
  24385. return Ok(JsonView(false, "团组信息不存在"));
  24386. }
  24387. var conferenceProceduresList = await _sqlSugar.Queryable<Grp_ConferenceProcedures>()
  24388. .Where(x => x.DiId == dto.GroupId && x.IsDel == 0)
  24389. .ToListAsync();
  24390. if (!conferenceProceduresList.Any())
  24391. {
  24392. return Ok(JsonView(false, "会务流程信息不存在"));
  24393. }
  24394. var filePath = $"{AppSettingsHelper.Get("ExcelBasePath")}Template/会务流程.xlsx";
  24395. if (!System.IO.File.Exists(filePath))
  24396. {
  24397. return Ok(JsonView(false, "模板文件不存在"));
  24398. }
  24399. var designer = new WorkbookDesigner();
  24400. designer.Workbook = new Workbook(filePath);
  24401. designer.SetDataSource("TB", conferenceProceduresList);
  24402. designer.Process();
  24403. var sheet = designer.Workbook.Worksheets[0];
  24404. var cells = sheet.Cells;
  24405. int col = 0; // 第一列
  24406. int startRow = 2; // 若第0行为表头,则从第1行开始;无表头请改为0
  24407. int endRow = cells.MaxDataRow;
  24408. if (endRow >= startRow)
  24409. {
  24410. int mergeStart = startRow;
  24411. string prev = cells[mergeStart, col].StringValue?.Trim() ?? string.Empty;
  24412. for (int r = startRow + 1; r <= endRow; r++)
  24413. {
  24414. string cur = cells[r, col].StringValue?.Trim() ?? string.Empty;
  24415. if (!string.Equals(cur, prev, StringComparison.Ordinal))
  24416. {
  24417. int count = r - mergeStart;
  24418. if (count > 1)
  24419. cells.Merge(mergeStart, col, count, 1);
  24420. mergeStart = r;
  24421. prev = cur;
  24422. }
  24423. }
  24424. int tailCount = endRow - mergeStart + 1;
  24425. if (tailCount > 1)
  24426. cells.Merge(mergeStart, col, tailCount, 1);
  24427. }
  24428. // byte[] bytes = null;
  24429. // using (MemoryStream stream = new MemoryStream())
  24430. // {
  24431. // designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  24432. // bytes = stream.ToArray();
  24433. // }
  24434. // return File(bytes, "application/excel", $"{groupInfo.TeamName}_会务流程.xlsx");
  24435. string savePath = $"{AppSettingsHelper.Get("ExcelBasePath")}ConferenceProcedures";
  24436. if (!System.IO.Directory.Exists(savePath))
  24437. {
  24438. System.IO.Directory.CreateDirectory(savePath);
  24439. }
  24440. designer.Workbook.Save($"{savePath}/{groupInfo.TeamName}_会务流程.xlsx");
  24441. string rst = savePath.replace(AppSettingsHelper.Get("ExcelBasePath"),
  24442. AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath"));
  24443. return Ok(JsonView(true, "SUCCESS", $"{rst}/{groupInfo.TeamName}_会务流程.xlsx"));
  24444. }
  24445. #endregion
  24446. #region 团组签证流程
  24447. /// <summary>
  24448. /// 团组签证流程 - 团组列表(分页)
  24449. /// </summary>
  24450. /// <returns></returns>
  24451. [HttpPost]
  24452. public async Task<IActionResult> VisaProcessGroupNames(VisaProcessGroupNamesDto dto)
  24453. {
  24454. int currUserId = dto.CurrUserId <= 0 ? 1 : dto.CurrUserId;
  24455. string groupName = dto.GroupName.Trim();
  24456. int pageIndex = dto.PageIndex <= 0 ? 1 : dto.PageIndex;
  24457. int pageSize = dto.PageSize <= 0 ? 10 : dto.PageSize;
  24458. int portType = dto.PortType;
  24459. RefAsync<int> total = 0;
  24460. var query = _sqlSugar.Queryable<Grp_GroupsTaskAssignment>()
  24461. .InnerJoin<Grp_DelegationInfo>((x, y) => x.DIId == y.Id)
  24462. .Where((x, y) => x.IsDel == 0 && x.CTId == 80 && x.UId == currUserId);
  24463. //构建单字模糊查询
  24464. if (!string.IsNullOrEmpty(groupName))
  24465. {
  24466. var characters = groupName.ToCharArray();
  24467. foreach (var character in characters)
  24468. {
  24469. var charString = character.ToString();
  24470. query = query.Where((x, y) =>
  24471. SqlFunc.Contains(y.TeamName, charString));
  24472. }
  24473. }
  24474. var groups = await query
  24475. .OrderByDescending((x, y) => y.VisitDate)
  24476. .Select((x, y) => new
  24477. {
  24478. y.Id,
  24479. GroupName = y.TeamName,
  24480. y.VisitDate
  24481. })
  24482. .Distinct()
  24483. .ToPageListAsync(pageIndex, pageSize, total);
  24484. var msg = "SUCCESS";
  24485. if (total <= 0) msg = "暂无可操作的团组,请联系经理分配团组!";
  24486. var groups1 = groups.Select(x => new { x.Id, x.GroupName }).ToList();
  24487. return Ok(JsonView(true, msg, groups1, total));
  24488. }
  24489. /// <summary>
  24490. /// 团组签证流程 - 详情
  24491. /// </summary>
  24492. /// <returns></returns>
  24493. [HttpPost]
  24494. public async Task<IActionResult> VisaProcessInfoByGroupId(VisaProcessInfoByGroupIdDto dto)
  24495. {
  24496. var res = await _visaProcessRep.Info(dto);
  24497. if (res.Code != 200) return Ok(JsonView(false, res.Msg));
  24498. return Ok(JsonView(true, res.Msg, res.Data));
  24499. }
  24500. /// <summary>
  24501. /// 团组签证流程 - 流程创建测试
  24502. /// </summary>
  24503. /// <returns></returns>
  24504. [HttpPost]
  24505. public async Task<IActionResult> VisaProcessAdd(int groupId, int currUserId)
  24506. {
  24507. return Ok(await _visaProcessRep.Create(currUserId, groupId));
  24508. }
  24509. /// <summary>
  24510. /// 团组签证流程 - 流程Top4Init 测试
  24511. /// </summary>
  24512. /// <returns></returns>
  24513. [HttpPost]
  24514. public async Task<IActionResult> VisaProcessTop4StepInit(int groupId, int currUserId)
  24515. {
  24516. return Ok(await _visaProcessRep.UpdateBatchTop4Step(groupId, currUserId));
  24517. }
  24518. /// <summary>
  24519. /// 团组签证流程 - 设置状态为已完成
  24520. /// </summary>
  24521. /// <returns></returns>
  24522. [HttpPost]
  24523. public async Task<IActionResult> VisaProcessSetCompleted(int id, int currUserId)
  24524. {
  24525. //参数验证
  24526. var stepValid = await _sqlSugar.Queryable<Grp_VisaProcessSteps>().Where(x => x.Id == id && x.IsDel == 0).AnyAsync();
  24527. if (!stepValid) return Ok(JsonView(false, "签证流程ID无效。"));
  24528. var userValid = await _sqlSugar.Queryable<Sys_Users>().Where(x => x.Id == currUserId && x.IsDel == 0).AnyAsync();
  24529. if (!userValid) return Ok(JsonView(false, "用户ID无效。"));
  24530. var res = await _visaProcessRep.SetCompleted(id, currUserId);
  24531. if (res.Code != 200) return Ok(JsonView(false, res.Msg));
  24532. return Ok(JsonView(true, res.Msg));
  24533. }
  24534. /// <summary>
  24535. /// 团组签证流程 - 修改各步骤内容
  24536. /// </summary>
  24537. /// <returns></returns>
  24538. [HttpPost]
  24539. public async Task<IActionResult> VisaProcessSetContent(VisaProcessSetContent dto)
  24540. {
  24541. //参数验证
  24542. var stepValid = await _sqlSugar.Queryable<Grp_VisaProcessSteps>().Where(x => x.Id == dto.StepId && x.IsDel == 0).FirstAsync();
  24543. if (stepValid == null) return Ok(JsonView(false, "签证流程ID无效。"));
  24544. var userValid = await _sqlSugar.Queryable<Sys_Users>().Where(x => x.Id == dto.CurrUserId && x.IsDel == 0).AnyAsync();
  24545. if (!userValid) return Ok(JsonView(false, "用户ID无效。"));
  24546. if (dto.StepContents == null && dto.StepContents.Count < 1)
  24547. {
  24548. return Ok(JsonView(false, "步骤内容无效。"));
  24549. }
  24550. //各步骤值处理
  24551. object stepVal;
  24552. if (stepValid.Step == 7) stepVal = dto.StepContents;
  24553. else stepVal = dto.StepContents[0].ToString();
  24554. var stepInfo = new Grp_VisaProcessSteps
  24555. {
  24556. Id = dto.StepId,
  24557. DataType = stepValid.DataType,
  24558. TypedValue = stepVal,
  24559. LastUpdateUserId = dto.CurrUserId
  24560. };
  24561. var res = await _visaProcessRep.Update(stepInfo);
  24562. if (res.Code != 200) return Ok(JsonView(false, res.Msg));
  24563. return Ok(JsonView(true, res.Msg));
  24564. }
  24565. /// <summary>
  24566. /// 团组签证流程 - 上传文件
  24567. /// </summary>
  24568. /// <returns></returns>
  24569. [HttpPost]
  24570. public async Task<IActionResult> VisaProcessUploadFiles([FromForm] VisaProcessUploadFilesDto dto)
  24571. {
  24572. //参数验证
  24573. var stepValid = await _sqlSugar.Queryable<Grp_VisaProcessSteps>().Where(x => x.Id == dto.StepId && x.IsDel == 0).FirstAsync();
  24574. if (stepValid == null) return Ok(JsonView(false, "签证流程ID无效。"));
  24575. var userValid = await _sqlSugar.Queryable<Sys_Users>().Where(x => x.Id == dto.CurrUserId && x.IsDel == 0).AnyAsync();
  24576. if (!userValid) return Ok(JsonView(false, "用户ID无效。"));
  24577. //验证文件是否存在
  24578. if (dto.Files == null || dto.Files.Count < 1) return Ok(JsonView(false, "请选择文件。"));
  24579. //验证该步骤是否可以上传文件
  24580. var uploadSteps = new List<int>() {
  24581. 5, //实际出签时间
  24582. 6, //是否需要开出境证明
  24583. 7, //是否需要办理电子入境卡手续
  24584. };
  24585. if (!uploadSteps.Contains(stepValid.Step))
  24586. {
  24587. return Ok(JsonView(false, $"该步骤不可上传附件。可上传附件步骤({string.Join("、", uploadSteps)})"));
  24588. }
  24589. //验证根目录
  24590. string rootRrl = AppSettingsHelper.Get("OfficeBaseUrl");
  24591. string rootPath = AppSettingsHelper.Get("OfficeTempBasePath");
  24592. if (!System.IO.Directory.Exists(rootPath))
  24593. {
  24594. System.IO.Directory.CreateDirectory(rootPath);
  24595. }
  24596. //验证签证流程上传文件夹 //按照团组名称存储文件夹 GrpFile/VisaProcessFiles/
  24597. var groupName = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  24598. .Where(x => x.IsDel == 0 && x.Id == stepValid.GroupId)
  24599. .Select(x => $"{x.TeamName}({x.Id})")
  24600. .FirstAsync();
  24601. //创建团组文件夹
  24602. var groupPath = rootPath + "GrpFile/VisaProcessFiles/" + groupName;
  24603. if (!System.IO.Directory.Exists(groupPath))
  24604. {
  24605. System.IO.Directory.CreateDirectory(groupPath);
  24606. }
  24607. List<string> filePaths = new List<string>();
  24608. //保存文件
  24609. foreach (var file in dto.Files)
  24610. {
  24611. // 生成存储文件名
  24612. var fileName = CommonFun.GenerateStoredFileName($"Step{stepValid.Step}.{file.FileName.Split(".")[1]}");
  24613. var filePath = Path.Combine(groupPath, fileName);
  24614. // 保存文件到磁盘
  24615. using (var stream = new FileStream(filePath, FileMode.Create))
  24616. {
  24617. await file.CopyToAsync(stream);
  24618. }
  24619. filePaths.Add($"GrpFile/VisaProcessFiles/{groupName}/{fileName}");
  24620. }
  24621. //数据库存储
  24622. var stepInfo = new Grp_VisaProcessSteps
  24623. {
  24624. Id = dto.StepId,
  24625. TypedFileNameValue = filePaths,
  24626. LastUpdateUserId = dto.CurrUserId
  24627. };
  24628. var res = await _sqlSugar.Updateable<Grp_VisaProcessSteps>()
  24629. .SetColumns(s => new Grp_VisaProcessSteps
  24630. {
  24631. AttachUrl = stepInfo.AttachUrl,
  24632. LastUpdateUserId = dto.CurrUserId,
  24633. LastUpdateTime = DateTime.Now
  24634. })
  24635. .Where(s => s.Id == dto.StepId && s.IsDel == 0)
  24636. .ExecuteCommandAsync();
  24637. if (res < 1) Ok(JsonView(false, "文件上传失败。"));
  24638. return Ok(JsonView(true));
  24639. }
  24640. /// <summary>
  24641. /// 团组签证流程 - step 7 资料下载
  24642. /// </summary>
  24643. /// <returns></returns>
  24644. [HttpPost]
  24645. public async Task<IActionResult> VisaProcessDownload(int groupId)
  24646. {
  24647. //验证根目录
  24648. string rootRrl = AppSettingsHelper.Get("OfficeBaseUrl");
  24649. string rootPath = AppSettingsHelper.Get("OfficeTempBasePath");
  24650. if (!System.IO.Directory.Exists(rootPath))
  24651. {
  24652. System.IO.Directory.CreateDirectory(rootPath);
  24653. }
  24654. //验证签证流程上传文件夹 //按照团组名称存储文件夹 GrpFile/VisaProcessFiles/
  24655. var groupName = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  24656. .Where(x => x.IsDel == 0 && x.Id == groupId)
  24657. .Select(x => $"{x.TeamName}({x.Id})")
  24658. .FirstAsync();
  24659. //创建团组文件夹
  24660. var timestamp = DateTime.Now.ToString("yyyyMMddHHmmss");
  24661. var randomStr = Guid.NewGuid().ToString("N").Substring(0, 8);
  24662. var dirName = $"{groupName}_相关资料_{timestamp}";
  24663. var sourceDirectoryPath = $"{rootPath}/GrpFile/VisaProcessFiles/{groupName}";
  24664. var path = $"{rootPath}/GrpFile/VisaProcessFiles/{groupName}/{dirName}";
  24665. if (!System.IO.Directory.Exists(path))
  24666. {
  24667. System.IO.Directory.CreateDirectory(path);
  24668. }
  24669. //验证接团客户名单
  24670. string sql = string.Format(@"
  24671. SELECT
  24672. tcl.Id,
  24673. tcl.DiId,
  24674. tcl.IsAccompany,
  24675. temp.*,
  24676. u.CnName AS Operator,
  24677. tcl.CreateTime AS OperatingTime,
  24678. ssd.name AS ShippingSpaceType
  24679. FROM
  24680. Grp_TourClientList tcl
  24681. LEFT JOIN (
  24682. SELECT
  24683. dc.Id AS DcId,
  24684. dc.LastName,
  24685. dc.FirstName,
  24686. ccom.CompanyFullName,
  24687. dc.Job,
  24688. cc.CertNo AS IDCardNo,
  24689. dc.Sex,
  24690. dc.BirthDay
  24691. FROM
  24692. Crm_DeleClient dc
  24693. LEFT JOIN Crm_CustomerCompany ccom ON dc.CrmCompanyId = ccom.Id
  24694. AND ccom.IsDel = 0
  24695. LEFT JOIN Crm_CustomerCert cc ON dc.Id = cc.DcId
  24696. AND cc.SdId = 773
  24697. AND cc.IsDel = 0
  24698. WHERE
  24699. dc.IsDel = 0
  24700. ) temp ON temp.DcId = tcl.ClientId
  24701. LEFT JOIN Sys_Users u ON tcl.CreateUserId = u.Id
  24702. LEFT JOIN sys_setdata ssd ON ssd.isdel = 0 AND ssd.id = tcl.ShippingSpaceTypeid
  24703. WHERE
  24704. tcl.IsDel = 0
  24705. AND tcl.DiId = {0}", groupId);
  24706. var groupClientList = await _sqlSugar.SqlQueryable<TourClientInfosView>(sql).ToListAsync();
  24707. //解密
  24708. foreach (var item in groupClientList)
  24709. {
  24710. EncryptionProcessor.DecryptProperties(item);
  24711. }
  24712. if (groupClientList == null || groupClientList.Count < 1)
  24713. {
  24714. return Ok(JsonView(false, $"团组客户名单未录入客户信息,不可生成相关资料。"));
  24715. }
  24716. #region 生成文件
  24717. //酒店信息
  24718. var hotelInfos = await _sqlSugar.Queryable<Grp_HotelReservations>()
  24719. .Where(x => x.IsDel == 0 && x.DiId == groupId)
  24720. .OrderBy(x => x.CheckInDate)
  24721. .ToListAsync();
  24722. //航班信息
  24723. var airInfos = await _sqlSugar.Queryable<Grp_AirTicketReservations>()
  24724. .Where(x => x.IsDel == 0 && x.DIId == groupId)
  24725. .OrderBy(x => x.FlightsDate)
  24726. .ToListAsync();
  24727. foreach (var clientInfo in groupClientList)
  24728. {
  24729. var clientId = clientInfo.DcId;
  24730. var guestName = $"{clientInfo.LastName}{clientInfo.FirstName}";
  24731. #region 个人信息资料
  24732. #endregion
  24733. #region 机票航班信息
  24734. var clientAirInfos = airInfos.Where(x => x.ClientName.Contains(clientId.ToString())).ToList();
  24735. if (clientAirInfos != null && clientAirInfos.Count > 0)
  24736. {
  24737. //创建表格
  24738. Document airDoc = new Document();
  24739. DocumentBuilder airBuilder = new DocumentBuilder(airDoc);
  24740. GeneralMethod.SetupDocumentStyles(airBuilder);
  24741. GeneralMethod.AddTitle(airBuilder, $"{guestName} - 机票信息");
  24742. GeneralMethod.AddAirInfoSections(airBuilder, clientAirInfos, "机票航班信息");
  24743. var airRandomStr = Guid.NewGuid().ToString("N").Substring(0, 8);
  24744. var airFileName = $"{guestName}_机票信息_{airRandomStr}.docx";
  24745. airDoc.Save($"{path}/{airFileName}");
  24746. }
  24747. #endregion
  24748. #region 酒店信息
  24749. var clientHotelInfos = hotelInfos.Where(x => x.GuestName.Contains(clientId.ToString())).ToList();
  24750. if (clientHotelInfos != null && clientHotelInfos.Count > 0)
  24751. {
  24752. //创建表格
  24753. Document hotelDoc = new Document();
  24754. DocumentBuilder HotelBuilder = new DocumentBuilder(hotelDoc);
  24755. GeneralMethod.SetupDocumentStyles(HotelBuilder);
  24756. GeneralMethod.AddTitle(HotelBuilder, $"{guestName} - 酒店信息");
  24757. GeneralMethod.AddHotelInfoSections(HotelBuilder, clientHotelInfos, "酒店信息");
  24758. var hotelRandomStr = Guid.NewGuid().ToString("N").Substring(0, 8);
  24759. var hotelFileName = $"{guestName}_酒店信息_{hotelRandomStr}.docx";
  24760. hotelDoc.Save($"{path}/{hotelFileName}");
  24761. }
  24762. #endregion
  24763. }
  24764. #endregion
  24765. //打包文件夹
  24766. var sourceDirectory = $"{sourceDirectoryPath}/{dirName}";
  24767. var zipFilePath = $"{sourceDirectoryPath}/{dirName}.zip";
  24768. if (System.IO.File.Exists(zipFilePath))
  24769. {
  24770. System.IO.File.Delete(zipFilePath);
  24771. }
  24772. ZipFile.CreateFromDirectory(sourceDirectory, zipFilePath, CompressionLevel.Fastest, false);
  24773. // 等待并验证
  24774. await Task.Delay(300); // 给系统时间完成文件操作
  24775. if (System.IO.File.Exists(zipFilePath))
  24776. {
  24777. var fileInfo = new FileInfo(zipFilePath);
  24778. var url = $"{rootRrl}GrpFile/VisaProcessFiles/{groupName}/{dirName}.zip";
  24779. return Ok(JsonView(url));
  24780. }
  24781. return Ok(JsonView(false));
  24782. }
  24783. #endregion
  24784. #region 团组总览进程
  24785. /// <summary>
  24786. /// 团组总览进程 - 流程创建测试
  24787. /// </summary>
  24788. /// <returns></returns>
  24789. [HttpPost]
  24790. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  24791. public async Task<IActionResult> GroupProcessInitTest()
  24792. {
  24793. return Ok(await _processOverviewRep.ProcessInitAsync(2732, 208));
  24794. }
  24795. /// <summary>
  24796. /// 团组总览进程 - 流程详情
  24797. /// </summary>
  24798. /// <returns></returns>
  24799. [HttpGet]
  24800. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  24801. public async Task<IActionResult> GroupProcessDetails(int groupId)
  24802. {
  24803. var res = await _processOverviewRep.ProcessesDetailsAsync(groupId);
  24804. if (res.Code == StatusCodes.Status200OK)
  24805. {
  24806. return Ok(JsonView(res.Data));
  24807. }
  24808. return Ok(JsonView(false, res.Msg));
  24809. }
  24810. /// <summary>
  24811. /// 团组总览进程 - 更新节点状态
  24812. /// </summary>
  24813. /// <returns></returns>
  24814. [HttpPost]
  24815. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  24816. public async Task<IActionResult> GroupProcessUpdateNodeStatus(GroupProcessUpdateNodeStatusDto dto)
  24817. {
  24818. var res = await _processOverviewRep.UpdateNodeStatusAsync(dto.NodeId, dto.CurrUserId);
  24819. if (res.Code == StatusCodes.Status200OK)
  24820. {
  24821. return Ok(JsonView(res.Data));
  24822. }
  24823. return Ok(JsonView(false, res.Msg));
  24824. }
  24825. /// <summary>
  24826. /// 团组总览进程 - 更新签证节点信息
  24827. /// </summary>
  24828. /// <returns></returns>
  24829. [HttpPost]
  24830. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  24831. public async Task<IActionResult> GroupProcessUpdateVisaNodeDetails(GroupProcessUpdateVisaNodeDetailsDto dto)
  24832. {
  24833. //验证签证信息
  24834. if (dto.VisaSubNodes.Count < 1) return Ok(JsonView(false, "请传入有效的签证节点信息。"));
  24835. var res = await _processOverviewRep.UpdateVisaNodeDetailsAsync(dto);
  24836. if (res.Code == StatusCodes.Status200OK)
  24837. {
  24838. return Ok(JsonView(res.Data));
  24839. }
  24840. return Ok(JsonView(false, res.Msg));
  24841. }
  24842. #endregion
  24843. /// <summary>
  24844. /// 123132123
  24845. /// </summary>
  24846. /// <param name="_dto"></param>
  24847. /// <returns></returns>
  24848. [HttpPost]
  24849. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  24850. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  24851. {
  24852. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  24853. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  24854. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  24855. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  24856. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  24857. dicDetail.Add(789, 1034);
  24858. dicDetail.Add(790, 1035);
  24859. dicDetail.Add(791, 1036);
  24860. dicDetail.Add(792, 1037);
  24861. dicDetail.Add(793, 1038);
  24862. dicDetail.Add(794, 1039);
  24863. dicDetail.Add(795, 1040);
  24864. dicDetail.Add(796, 1041);
  24865. dicDetail.Add(797, 1042);
  24866. dicDetail.Add(798, 1043);
  24867. dicDetail.Add(801, 1044);
  24868. dicDetail.Add(802, 1045);
  24869. dicDetail.Add(803, 1046);
  24870. Dictionary<int, int> dic = new Dictionary<int, int>();
  24871. dic.Add(806, 1027);
  24872. dic.Add(807, 1028);
  24873. dic.Add(808, 1029);
  24874. dic.Add(809, 1030);
  24875. dic.Add(810, 1031);
  24876. dic.Add(811, 1032);
  24877. dic.Add(812, 1033);
  24878. foreach (var item in list_visa)
  24879. {
  24880. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  24881. temp.Coefficient = item.coefficient;
  24882. DateTime dtCrt;
  24883. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  24884. if (b1)
  24885. {
  24886. temp.CreateTime = dtCrt;
  24887. }
  24888. else
  24889. {
  24890. temp.CreateTime = DateTime.Now;
  24891. }
  24892. temp.CreateUserId = item.Operators;
  24893. temp.DeleteTime = "";
  24894. temp.DeleteUserId = 0;
  24895. temp.DiId = int.Parse(item.DIID);
  24896. temp.FilePath = item.FilePath;
  24897. temp.IsDel = item.IsDel;
  24898. temp.Price = item.Price;
  24899. temp.PriceCount = 1;
  24900. temp.PriceCurrency = item.Currency;
  24901. int detailId = 0;
  24902. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  24903. {
  24904. detailId = dicDetail[item.PriceTypeDetail];
  24905. }
  24906. temp.PriceDetailType = detailId;
  24907. temp.PriceDt = DateTime.Now;
  24908. temp.PriceName = item.PriceName;
  24909. temp.PriceSum = item.Price;
  24910. int tid = 0;
  24911. if (dic.ContainsKey(item.PriceType))
  24912. {
  24913. tid = dic[item.PriceType];
  24914. }
  24915. temp.PriceType = tid;
  24916. temp.Remark = item.Remark;
  24917. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  24918. }
  24919. return Ok(JsonView(true, "操作成功!"));
  24920. }
  24921. [HttpPost]
  24922. public IActionResult TimeTest()
  24923. {
  24924. var jw = JsonView(false, "error");
  24925. _sqlSugar.BeginTran();
  24926. try
  24927. {
  24928. var clientList = _sqlSugar.Queryable<Crm_NewClientData>()
  24929. .Select(x => new Crm_NewClientData
  24930. {
  24931. Id = x.Id,
  24932. Client = x.Client,
  24933. Contact = x.Contact,
  24934. Location = x.Location,
  24935. })
  24936. .ToList();
  24937. var ids = clientList.Where(x => !string.IsNullOrEmpty(x.Client) && x.Client.Contains("重庆")).Select(x => x.Id).ToList();
  24938. _sqlSugar.Queryable<Crm_NewClientData>().Where(x => ids.Contains(x.Id)).ToList();
  24939. Stopwatch stopwatch = new Stopwatch();
  24940. // 开始计时
  24941. stopwatch.Start();
  24942. foreach (var item in clientList)
  24943. {
  24944. EncryptionProcessor.DecryptProperties(item);
  24945. }
  24946. stopwatch.Stop();
  24947. jw.Code = 200;
  24948. jw.Data = stopwatch.ElapsedMilliseconds;
  24949. jw.Msg = "运算耗时: " + stopwatch.ElapsedMilliseconds + " 毫秒,解密条数: " + clientList.Count;
  24950. }
  24951. catch (Exception ex)
  24952. {
  24953. jw.Code = 400;
  24954. jw.Msg = ex.Message;
  24955. }
  24956. return Ok(jw);
  24957. }
  24958. [HttpPost]
  24959. public async Task<IActionResult> TimeTest1()
  24960. {
  24961. var infos = await _sqlSugar.Queryable<Crm_DeleClient>().ToListAsync();
  24962. return Ok(infos);
  24963. }
  24964. }
  24965. }