GroupsController.cs 1.2 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173
  1. using Aspose.Cells;
  2. using Aspose.Words;
  3. using Aspose.Words.Drawing;
  4. using Aspose.Words.Tables;
  5. using DiffMatchPatch;
  6. using Microsoft.AspNetCore.SignalR;
  7. using NPOI.SS.UserModel;
  8. using NPOI.SS.Util;
  9. using NPOI.XSSF.UserModel;
  10. using OASystem.API.Middlewares;
  11. using OASystem.API.OAMethodLib;
  12. using OASystem.API.OAMethodLib.APNs;
  13. using OASystem.API.OAMethodLib.File;
  14. using OASystem.API.OAMethodLib.Hub.HubClients;
  15. using OASystem.API.OAMethodLib.Hub.Hubs;
  16. using OASystem.API.OAMethodLib.JuHeAPI;
  17. using OASystem.API.OAMethodLib.KiMiApi;
  18. using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
  19. using OASystem.Domain.AesEncryption;
  20. using OASystem.Domain.Attributes;
  21. using OASystem.Domain.Dtos.CRM;
  22. using OASystem.Domain.Dtos.FileDto;
  23. using OASystem.Domain.Dtos.Financial;
  24. using OASystem.Domain.Dtos.Groups;
  25. using OASystem.Domain.Entities.Customer;
  26. using OASystem.Domain.Entities.Financial;
  27. using OASystem.Domain.Entities.Groups;
  28. using OASystem.Domain.ViewModels.CRM;
  29. using OASystem.Domain.ViewModels.Financial;
  30. using OASystem.Domain.ViewModels.Groups;
  31. using OASystem.Domain.ViewModels.OCR;
  32. using OASystem.Infrastructure.Repositories.CRM;
  33. using OASystem.Infrastructure.Repositories.Financial;
  34. using OASystem.Infrastructure.Repositories.Groups;
  35. using Quartz.Util;
  36. using SqlSugar.Extensions;
  37. using System.Collections;
  38. using System.ComponentModel.DataAnnotations;
  39. using System.Data;
  40. using System.Diagnostics;
  41. using System.Globalization;
  42. using System.IO.Compression;
  43. using System.Text.Json;
  44. using System.Web;
  45. using static OASystem.API.OAMethodLib.JWTHelper;
  46. using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
  47. using Bookmark = Aspose.Words.Bookmark;
  48. using Cell = Aspose.Words.Tables.Cell;
  49. using Table = Aspose.Words.Tables.Table;
  50. namespace OASystem.API.Controllers
  51. {
  52. /// <summary>
  53. /// 团组相关
  54. /// </summary>
  55. //[Authorize]
  56. [Route("api/[controller]/[action]")]
  57. public class GroupsController : ControllerBase
  58. {
  59. private readonly ILogger<GroupsController> _logger;
  60. private readonly GrpScheduleRepository _grpScheduleRep;
  61. private readonly IMapper _mapper;
  62. private readonly DelegationInfoRepository _groupRepository;
  63. private readonly TaskAssignmentRepository _taskAssignmentRep;
  64. private readonly AirTicketResRepository _airTicketResRep;
  65. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  66. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  67. private readonly DelegationEnDataRepository _delegationEnDataRep;
  68. private readonly DelegationVisaRepository _delegationVisaRep;
  69. private readonly VisaPriceRepository _visaPriceRep;
  70. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  71. private readonly HotelPriceRepository _hotelPriceRep;
  72. private readonly CustomersRepository _customersRep;
  73. private readonly MessageRepository _message;
  74. private readonly SqlSugarClient _sqlSugar;
  75. private readonly TourClientListRepository _tourClientListRep;
  76. private readonly TeamRateRepository _teamRateRep;
  77. #region 成本相关
  78. private readonly CheckBoxsRepository _checkBoxs;
  79. private readonly GroupCostRepository _GroupCostRepository;
  80. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  81. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  82. #endregion
  83. private readonly SetDataRepository _setDataRep;
  84. private string url;
  85. private string path;
  86. private readonly EnterExitCostRepository _enterExitCostRep;
  87. private readonly IHubContext<ChatHub, IChatClient> _hubContext;
  88. private readonly UsersRepository _usersRep;
  89. private readonly IJuHeApiService _juHeApi;
  90. private readonly InvertedListRepository _invertedListRep;
  91. private readonly VisaFeeInfoRepository _visaFeeInfoRep;
  92. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  93. private readonly ThreeCodeRepository _threeCodeRepository;
  94. private readonly HotelInquiryRepository _hotelInquiryRep;
  95. private readonly FeeAuditRepository _feeAuditRep;
  96. private readonly VisaCommissionRepository _visaCommissionRep;
  97. private readonly ForeignReceivablesRepository _ffrRep; //对外收款账单仓库
  98. private readonly OpinionaireRepository _opinionaireRep; //对外收款账单仓库
  99. private readonly List<CurrencyInfo> _currencyInit;
  100. private readonly List<int> _portTypeData;
  101. private readonly TableOperationRecordRepository _tableorRep;
  102. private readonly EnterExitCostDraftRepository _enterExitCostDraftRep;
  103. private readonly RestaurantRepository _restaurantRep;
  104. private readonly EnterExitCostQuoteRepository _enterExitCostQuoteRep;
  105. private readonly GroupOrderPreInfoRepository _grpOrderPreInfoRep;
  106. /// <summary>
  107. /// 构造函数
  108. /// </summary>
  109. /// <param name="logger"></param>
  110. /// <param name="mapper"></param>
  111. /// <param name="hubContext"></param>
  112. /// <param name="sqlSugar"></param>
  113. /// <param name="grpScheduleRep"></param>
  114. /// <param name="groupRepository"></param>
  115. /// <param name="taskAssignmentRep"></param>
  116. /// <param name="airTicketResRep"></param>
  117. /// <param name="decreasePaymentsRep"></param>
  118. /// <param name="InvitationOfficialActivitiesRep"></param>
  119. /// <param name="delegationEnDataRep"></param>
  120. /// <param name="enterExitCostRep"></param>
  121. /// <param name="delegationVisaRep"></param>
  122. /// <param name="message"></param>
  123. /// <param name="visaPriceRep"></param>
  124. /// <param name="carTouristGuideGroundRep"></param>
  125. /// <param name="checkBoxs"></param>
  126. /// <param name="GroupCostRepository"></param>
  127. /// <param name="CostTypeHotelNumberRepository"></param>
  128. /// <param name="GroupCostParameterRepository"></param>
  129. /// <param name="hotelPriceRep"></param>
  130. /// <param name="customersRep"></param>
  131. /// <param name="setDataRep"></param>
  132. /// <param name="tourClientListRep"></param>
  133. /// <param name="teamRateRep"></param>
  134. /// <param name="usersRep"></param>
  135. /// <param name="juHeApi"></param>
  136. /// <param name="invertedListRep"></param>
  137. /// <param name="visaFeeInfoRep"></param>
  138. /// <param name="ticketBlackCodeRep"></param>
  139. /// <param name="hotelInquiryRep"></param>
  140. /// <param name="threeCodeRepository"></param>
  141. /// <param name="feeAuditRep"></param>
  142. /// <param name="visaCommissionRep"></param>
  143. /// <param name="ffrRep"></param>
  144. /// <param name="opinionaireRep"></param>
  145. /// <param name="tableorRep"></param>
  146. /// <param name="enterExitCostDraftRep"></param>
  147. /// <param name="restaurantRep"></param>
  148. /// <param name="enterExitCostQuoteRep"></param>
  149. /// <param name="grpOrderPreInfoRep"></param>
  150. public GroupsController(
  151. ILogger<GroupsController> logger,
  152. IMapper mapper,
  153. IHubContext<ChatHub, IChatClient> hubContext,
  154. SqlSugarClient sqlSugar,
  155. GrpScheduleRepository grpScheduleRep,
  156. DelegationInfoRepository groupRepository,
  157. TaskAssignmentRepository taskAssignmentRep,
  158. AirTicketResRepository airTicketResRep,
  159. DecreasePaymentsRepository decreasePaymentsRep,
  160. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep,
  161. DelegationEnDataRepository delegationEnDataRep,
  162. EnterExitCostRepository enterExitCostRep,
  163. DelegationVisaRepository delegationVisaRep,
  164. MessageRepository message,
  165. VisaPriceRepository visaPriceRep,
  166. CarTouristGuideGroundRepository carTouristGuideGroundRep,
  167. CheckBoxsRepository checkBoxs,
  168. GroupCostRepository GroupCostRepository,
  169. CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  170. GroupCostParameterRepository GroupCostParameterRepository,
  171. HotelPriceRepository hotelPriceRep,
  172. CustomersRepository customersRep,
  173. SetDataRepository setDataRep,
  174. TourClientListRepository tourClientListRep,
  175. TeamRateRepository teamRateRep,
  176. UsersRepository usersRep,
  177. IJuHeApiService juHeApi,
  178. InvertedListRepository invertedListRep,
  179. VisaFeeInfoRepository visaFeeInfoRep,
  180. TicketBlackCodeRepository ticketBlackCodeRep,
  181. HotelInquiryRepository hotelInquiryRep,
  182. ThreeCodeRepository threeCodeRepository,
  183. FeeAuditRepository feeAuditRep,
  184. VisaCommissionRepository visaCommissionRep,
  185. ForeignReceivablesRepository ffrRep,
  186. OpinionaireRepository opinionaireRep,
  187. TableOperationRecordRepository tableorRep,
  188. EnterExitCostDraftRepository enterExitCostDraftRep,
  189. RestaurantRepository restaurantRep,
  190. EnterExitCostQuoteRepository enterExitCostQuoteRep,
  191. GroupOrderPreInfoRepository grpOrderPreInfoRep
  192. )
  193. {
  194. _logger = logger;
  195. _mapper = mapper;
  196. _grpScheduleRep = grpScheduleRep;
  197. _groupRepository = groupRepository;
  198. _taskAssignmentRep = taskAssignmentRep;
  199. _airTicketResRep = airTicketResRep;
  200. _sqlSugar = sqlSugar;
  201. url = AppSettingsHelper.Get("ExcelBaseUrl");
  202. path = AppSettingsHelper.Get("ExcelBasePath");
  203. if (!System.IO.Directory.Exists(path))
  204. {
  205. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  206. }
  207. _decreasePaymentsRep = decreasePaymentsRep;
  208. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  209. _delegationEnDataRep = delegationEnDataRep;
  210. _enterExitCostRep = enterExitCostRep;
  211. _delegationVisaRep = delegationVisaRep;
  212. _message = message;
  213. _visaPriceRep = visaPriceRep;
  214. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  215. _checkBoxs = checkBoxs;
  216. _GroupCostRepository = GroupCostRepository;
  217. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  218. _GroupCostParameterRepository = GroupCostParameterRepository;
  219. _hotelPriceRep = hotelPriceRep;
  220. _customersRep = customersRep;
  221. _setDataRep = setDataRep;
  222. _tourClientListRep = tourClientListRep;
  223. _teamRateRep = teamRateRep;
  224. _hubContext = hubContext;
  225. _usersRep = usersRep;
  226. _juHeApi = juHeApi;
  227. _invertedListRep = invertedListRep;
  228. _visaFeeInfoRep = visaFeeInfoRep;
  229. _ticketBlackCodeRep = ticketBlackCodeRep;
  230. _hotelInquiryRep = hotelInquiryRep;
  231. _threeCodeRepository = threeCodeRepository;
  232. _feeAuditRep = feeAuditRep;
  233. _visaCommissionRep = visaCommissionRep;
  234. _ffrRep = ffrRep;
  235. _opinionaireRep = opinionaireRep;
  236. _currencyInit = new List<CurrencyInfo>()
  237. {
  238. new(){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  239. new(){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  240. new(){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  241. new(){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  242. new(){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  243. };
  244. _portTypeData = new List<int>() { 2, 3 };
  245. _tableorRep = tableorRep;
  246. _enterExitCostDraftRep = enterExitCostDraftRep;
  247. _restaurantRep = restaurantRep;
  248. _enterExitCostQuoteRep = enterExitCostQuoteRep;
  249. _grpOrderPreInfoRep = grpOrderPreInfoRep;
  250. }
  251. #region 流程管控
  252. /// <summary>
  253. /// 获取团组流程管控信息
  254. /// </summary>
  255. /// <param name="_jsonDto">查询参数</param>
  256. /// <returns></returns>
  257. [HttpPost]
  258. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  259. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  260. {
  261. if (string.IsNullOrEmpty(_jsonDto.Paras))
  262. {
  263. return Ok(JsonView(false, "参数为空"));
  264. }
  265. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  266. if (_ScheduleDto != null)
  267. {
  268. if (_ScheduleDto.SearchType == 2)//获取列表
  269. {
  270. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  271. return Ok(JsonView(_grpScheduleViewList));
  272. }
  273. else//获取对象
  274. {
  275. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  276. if (_grpScheduleView != null)
  277. {
  278. return Ok(JsonView(_grpScheduleView));
  279. }
  280. }
  281. }
  282. else
  283. {
  284. return Ok(JsonView(false, "参数反序列化失败"));
  285. }
  286. return Ok(JsonView(false, "暂无数据!"));
  287. }
  288. /// <summary>
  289. /// 修改团组流程管控详细表数据
  290. /// </summary>
  291. /// <param name="dto"></param>
  292. /// <returns></returns>
  293. [HttpPost]
  294. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  295. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  296. {
  297. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  298. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  299. .SetColumns(it => it.Duty == _detail.Duty)
  300. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  301. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  302. .SetColumns(it => it.JobContent == _detail.JobContent)
  303. .SetColumns(it => it.Remark == _detail.Remark)
  304. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  305. .Where(s => s.Id == dto.Id)
  306. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  307. .ExecuteCommandAsync();
  308. if (result > 0)
  309. {
  310. return Ok(JsonView(true, "保存成功!"));
  311. }
  312. return Ok(JsonView(false, "保存失败!"));
  313. }
  314. /// <summary>
  315. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  316. /// </summary>
  317. /// <param name="dto"></param>
  318. /// <returns></returns>
  319. [HttpPost]
  320. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  321. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  322. {
  323. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  324. _detail.IsDel = 1;
  325. _detail.DeleteUserId = dto.Duty;
  326. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  327. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  328. .SetColumns(it => it.IsDel == _detail.IsDel)
  329. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  330. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  331. .Where(it => it.Id == dto.Id)
  332. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  333. //.WhereColumns(s => s.Id == dto.Id)
  334. .ExecuteCommandAsync();
  335. if (result > 0)
  336. {
  337. return Ok(JsonView(true, "删除成功!"));
  338. }
  339. return Ok(JsonView(false, "删除失败!"));
  340. }
  341. /// <summary>
  342. /// 增加团组流程管控详细表数据
  343. /// </summary>
  344. /// <param name="dto"></param>
  345. /// <returns></returns>
  346. [HttpPost]
  347. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  348. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  349. {
  350. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  351. if (DateTime.Now < _detail.ExpectBeginDt)
  352. {
  353. _detail.StepStatus = 0;
  354. }
  355. else
  356. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  357. _detail.StepStatus = 1;
  358. }
  359. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  360. if (result > 0)
  361. {
  362. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  363. return Ok(JsonView(true, "添加成功!", _result));
  364. }
  365. return Ok(JsonView(false, "添加失败!"));
  366. }
  367. #endregion
  368. #region 团组前期信息
  369. /// <summary>
  370. /// 团组前期信息H5-URL(员工对应地址)
  371. /// </summary>
  372. /// <param name="name">用户名称</param>
  373. /// <returns></returns>
  374. [HttpGet]
  375. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  376. public async Task<IActionResult> GroupOrderPreInfoH5URLList([FromQuery] string name)
  377. {
  378. var userURLs = await _sqlSugar.Queryable<Sys_Users>()
  379. .Where(x => x.IsDel == 0)
  380. .WhereIF(!string.IsNullOrEmpty(name), x => x.CnName.Contains(name))
  381. .OrderBy(x => x.Id)
  382. .Select(x => new
  383. {
  384. name = x.CnName,
  385. url = $"http://oa.pan-american-intl.com:4399/#/MarketplacePick?userid={x.Id}",
  386. })
  387. .ToListAsync();
  388. return Ok(JsonView(true, "操作成功!", userURLs, userURLs.Count));
  389. }
  390. /// <summary>
  391. /// 团组前期信息 List
  392. /// </summary>
  393. /// <returns></returns>
  394. [HttpPost]
  395. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  396. public async Task<IActionResult> GroupOrderPreInfoList(GroupOrderPreInfoListDto dto)
  397. {
  398. var search = dto.Search;
  399. int[] nameTempIds = new int[] { 1, 12, 28 },
  400. countryTempIds = new int[] { 2, 13, 29 },
  401. daysTempIds = new int[] { 4, 15, 31 },
  402. ppNumTempIds = new int[] { 6 };
  403. var list = await _sqlSugar.Queryable<Grp_OrderPreInfo>()
  404. .LeftJoin<Sys_Users>((opi, u) => opi.CreateUserId == u.Id)
  405. .Where((opi, u) => opi.IsDel == 0)
  406. .OrderByDescending((opi, u) => opi.CreateTime)
  407. .Select((opi, u) => new GroupOrderPreInfoListView()
  408. {
  409. Id = opi.Id,
  410. Name = opi.Name,
  411. UnitName = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && nameTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  412. VisitCountryVal = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && countryTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  413. VisitDays = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && daysTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  414. VisiPpNum = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && ppNumTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  415. Operator = u.CnName,
  416. OperationTime = opi.CreateTime
  417. })
  418. //.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search) || x.UnitName.Contains(search) || x.VisitCountrys.Contains(search))
  419. //.ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  420. .ToListAsync();
  421. var listPageData = list.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search) || x.UnitName.Contains(search) || x.VisitCountrys.Contains(search)).ToList();
  422. int total = list.Count;
  423. int totalPageCount = (int)Math.Ceiling(list.Count / (double)dto.PageSize);
  424. var listPageData1 = listPageData
  425. .Skip((dto.PageIndex - 1) * dto.PageSize)
  426. .Take(dto.PageSize)
  427. .ToList();
  428. var infoIds = listPageData1.Select(x => x.Id).ToList();
  429. var typeDatas = await _sqlSugar.Queryable<Sys_SetData>()
  430. .Where(x => x.IsDel == 0 && x.STid == 109)
  431. .ToArrayAsync();
  432. var items = await _sqlSugar.Queryable<Grp_OrderPreItem>()
  433. .LeftJoin<Sys_FormTemp>((opi, ft) => opi.FormTempId == ft.Id)
  434. .Where((opi, ft) => opi.IsDel == 0 && infoIds.Contains(opi.ParentId))
  435. .Select((opi, ft) => new { opi.ParentId, opi.FormTempId, ft.TempId })
  436. .ToListAsync();
  437. foreach (var item in listPageData1)
  438. {
  439. var typeDatas1 = typeDatas.Select(x => new
  440. {
  441. x.Id,
  442. x.Name,
  443. IsNull = !items.Any(x1 => item.Id == x1.ParentId && x.Id == x1.TempId)
  444. }).ToArray();
  445. item.VersionDetails = typeDatas1;
  446. }
  447. return Ok(JsonView(listPageData1, listPageData1.Count));
  448. }
  449. /// <summary>
  450. /// 团组前期信息 Init
  451. /// </summary>
  452. /// <returns></returns>
  453. [HttpGet("{userId}")]
  454. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  455. public async Task<IActionResult> GroupOrderPreInfo(int userId)
  456. {
  457. return Ok(await _grpOrderPreInfoRep.DataInit(userId));
  458. }
  459. /// <summary>
  460. /// 国家数据源
  461. /// </summary>
  462. /// <param name="pageIndex">当前页码</param>
  463. /// <param name="pageSize">每页条数</param>
  464. /// <param name="search">查询条件</param>
  465. /// <returns></returns>
  466. [HttpGet]
  467. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  468. public async Task<IActionResult> CountryInit([FromQuery] int pageIndex, [FromQuery] int pageSize, [FromQuery] string search)
  469. {
  470. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => x.Country).Distinct().ToListAsync();
  471. if (pageIndex == 0 && pageSize == 0)
  472. {
  473. //所有数据
  474. return Ok(JsonView(countrys, countrys.Count));
  475. }
  476. //分页
  477. int skip = (pageIndex - 1) * pageSize;
  478. int take = pageSize;
  479. if (!string.IsNullOrEmpty(search))
  480. {
  481. IEnumerable<char> charSequence = search.Select(c => c);
  482. var pageResult1 = countrys.Where(x => charSequence.All(x1 => x.Contains(x1))).ToList();
  483. var pageData = pageResult1.Skip(skip).Take(take).ToList();
  484. return Ok(JsonView(pageData, pageResult1.Count));
  485. }
  486. var pageResult2 = countrys.Skip(skip).Take(take).ToList();
  487. return Ok(JsonView(pageResult2, countrys.Count));
  488. }
  489. /// <summary>
  490. /// 城市数据源
  491. /// </summary>
  492. /// <param name="countryLabel">国家名称 多个使用英文逗号隔开</param>
  493. /// <param name="pageIndex">当前页码</param>
  494. /// <param name="pageSize">每页条数</param>
  495. /// <param name="search">查询条件</param>
  496. /// <returns></returns>
  497. [HttpGet("{countryLabel}")]
  498. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  499. public async Task<IActionResult> CityByCountry(
  500. string countryLabel,
  501. [FromQuery] int pageIndex,
  502. [FromQuery] int pageSize,
  503. [FromQuery] string search)
  504. {
  505. countryLabel = HttpUtility.UrlDecode(countryLabel);
  506. var countryList = countryLabel.Split(',', StringSplitOptions.RemoveEmptyEntries).ToArray();
  507. var citys = Array.Empty<string?>();
  508. if (countryList.Any())
  509. {
  510. var cityDatas = await _sqlSugar
  511. .Queryable<Grp_NationalTravelFee>()
  512. .Where(x => x.IsDel == 0 && countryList.Contains(x.Country) && !string.IsNullOrEmpty(x.City))
  513. .ToArrayAsync();
  514. foreach (var item in cityDatas)
  515. {
  516. if (item.City.Contains("城市"))
  517. {
  518. item.City = item.Country + "-所有城市";
  519. }
  520. }
  521. var cityDatas1 = cityDatas.OrderBy(x => x.Country);
  522. citys = cityDatas1.Select(x => x.City).Distinct().ToArray();
  523. }
  524. if (pageIndex == 0 && pageSize == 0)
  525. {
  526. //所有数据
  527. return Ok(JsonView(citys, citys?.Length ?? 0));
  528. }
  529. //分页
  530. int skip = (pageIndex - 1) * pageSize;
  531. int take = pageSize;
  532. if (!string.IsNullOrEmpty(search))
  533. {
  534. IEnumerable<char> charSequence = search.Select(c => c);
  535. var pageResult1 = citys.Where(x => charSequence.All(x1 => x.Contains(x1))).ToList();
  536. var pageData = pageResult1.Skip(skip).Take(take).ToList();
  537. return Ok(JsonView(pageData, pageResult1.Count));
  538. }
  539. var pageResult2 = citys.Skip(skip).Take(take).ToList();
  540. return Ok(JsonView(pageResult2, citys?.Length ?? 0));
  541. }
  542. /// <summary>
  543. /// 团组前期信息 Info
  544. /// </summary>
  545. /// <param name="dto">Id</param>
  546. /// <returns></returns>
  547. [HttpGet("{Id}/{TempId}")]
  548. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  549. public async Task<IActionResult> GroupOrderPreInfo([FromRoute] GroupOrderPreInfoDto dto)
  550. {
  551. return Ok(await _grpOrderPreInfoRep.InfoAsync(dto.Id, dto.TempId));
  552. }
  553. /// <summary>
  554. /// 团组前期信息 移动端 Info
  555. /// </summary>
  556. /// <param name="dto">Id</param>
  557. /// <returns></returns>
  558. [HttpGet("{Id}/{TempId}")]
  559. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  560. public async Task<IActionResult> GroupOrderPreMobileInfo([FromRoute] GroupOrderPreInfoDto dto)
  561. {
  562. return Ok(await _grpOrderPreInfoRep.MobileInfoAsync(dto.Id, dto.TempId));
  563. }
  564. /// <summary>
  565. /// 团组前期信息 Save
  566. /// </summary>
  567. /// <param name="dto">Id</param>
  568. /// <returns></returns>
  569. [HttpPost]
  570. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  571. public async Task<IActionResult> GroupOrderPreInfoSave(GroupOrderPreInfoOpDto dto)
  572. {
  573. return Ok(await _grpOrderPreInfoRep.OpAsync(dto));
  574. }
  575. /// <summary>
  576. /// 团组前期信息 Del
  577. /// </summary>
  578. /// <param name="dto">Id</param>
  579. /// <returns></returns>
  580. [HttpPost]
  581. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  582. public async Task<IActionResult> GroupOrderPreInfoDel(GroupOrderPreInfoDelDto dto)
  583. {
  584. return Ok(await _grpOrderPreInfoRep.DelAsync(dto));
  585. }
  586. /// <summary>
  587. /// 团组前期信息 文件下载
  588. /// </summary>
  589. /// <param name="dto">Id</param>
  590. /// <returns></returns>
  591. [HttpGet("{Id}/{TempId}")]
  592. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  593. public async Task<IActionResult> GroupOrderPreInfoFileDownload([FromRoute] GroupOrderPreInfoDto dto)
  594. {
  595. int id = dto.Id, tempId = dto.TempId;
  596. var view = await _grpOrderPreInfoRep.InfoAsync(id, tempId);
  597. var data = view.Data as GrpOrderPreInfoView;
  598. #region Excel
  599. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  600. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  601. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "GroupOrderPreInfo/";
  602. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "GroupOrderPreInfo/";
  603. var fileNamePrefix = string.Empty;
  604. if (tempId == 1405)
  605. {
  606. tempPath += $"前期需客户提供信息_无商邀版Temp.xlsx";
  607. fileNamePrefix = $"{data.Name}_无商邀版";
  608. }
  609. else if (tempId == 1406)
  610. {
  611. tempPath += $"前期需客户提供信息_有商邀版Temp.xlsx";
  612. fileNamePrefix = $"{data.Name}_有商邀版";
  613. }
  614. else
  615. {
  616. //tempId == 1404 默认下载
  617. tempPath += $"前期需客户提供信息_单接送机Temp.xlsx";
  618. fileNamePrefix = $"{data.Name}_单接送机";
  619. }
  620. foreach (var item in data.Items)
  621. {
  622. var obj = item.NewValue;
  623. if (obj == null) item.OriginVal = "";
  624. else if (obj.Equals("有") || obj.Equals("无"))
  625. {
  626. item.OriginVal = obj.ToString();
  627. }
  628. else if (obj is object[] objArray)
  629. {
  630. string[] stringArray = Array.ConvertAll(objArray, item => item?.ToString() ?? string.Empty);
  631. item.OriginVal = string.Join("、", stringArray);
  632. }
  633. else if (obj is string[] stringArray)
  634. {
  635. item.OriginVal = string.Join("、", stringArray);
  636. }
  637. else if (obj.Equals("-"))
  638. {
  639. item.OriginVal = "";
  640. }
  641. }
  642. var fileName = $"{fileNamePrefix}{CommonFun.GUID}.xlsx";
  643. fileName = CommonFun.ValidFileName(fileName);
  644. //载入模板
  645. var designer = new WorkbookDesigner
  646. {
  647. Workbook = new Workbook(tempPath)
  648. };
  649. if (tempId == 1406)
  650. {
  651. var view1 = data.Items.Where(x => x.Index < 11).ToArray();
  652. var view2 = data.Items.Where(x => x.Index > 10).ToArray();
  653. for (int i = 1; i <= view2.Length; i++)
  654. {
  655. view2[i - 1].Index = i;
  656. }
  657. designer.SetDataSource("View1", view1);
  658. designer.SetDataSource("View2", view2);
  659. }
  660. else
  661. {
  662. designer.SetDataSource("View", data.Items);
  663. }
  664. designer.Process();
  665. if (!Directory.Exists(savePath))
  666. {
  667. Directory.CreateDirectory(savePath);
  668. }
  669. string serverPath = $"{savePath}{fileName}";
  670. designer.Workbook.Save(serverPath);
  671. string rst = $"{servicePath}{ftpPath}{fileName}";
  672. #endregion
  673. return Ok(JsonView(new { url = rst }));
  674. }
  675. #endregion
  676. #region 团组基本信息
  677. /// <summary>
  678. /// 接团信息列表
  679. /// </summary>
  680. /// <param name="dto">团组列表请求dto</param>
  681. /// <returns></returns>
  682. [HttpPost]
  683. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  684. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  685. {
  686. var groupData = await _groupRepository.GetGroupList(dto);
  687. if (groupData.Code != 0)
  688. {
  689. return Ok(JsonView(false, groupData.Msg));
  690. }
  691. return Ok(JsonView(groupData.Data));
  692. }
  693. /// <summary>
  694. /// 分页查询团组列表
  695. /// </summary>
  696. /// <param name="dto"></param>
  697. /// <returns></returns>
  698. [HttpPost]
  699. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  700. public async Task<IActionResult> QueryGroupListOffset(QueryGroupListOffsetDto dto)
  701. {
  702. var watch = new Stopwatch();
  703. watch.Start();
  704. RefAsync<int> total = 0;
  705. var countyDatas = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  706. .Where((di) => di.IsDel == 0 && !string.IsNullOrWhiteSpace(di.TeamName))
  707. .WhereIF(!string.IsNullOrEmpty(dto.Search), (di) => di.TeamName.Contains(dto.Search))
  708. .OrderBy((di) => new { id = SqlFunc.Desc(di.Id) })
  709. .Select((di) => new { id = di.Id, name = di.TeamName, di.ClientName, di.VisitPNumber, di.VisitCountry, di.VisitDays, di.VisitStartDate, di.VisitEndDate, di.TourCode })
  710. .Distinct()
  711. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  712. watch.Stop();
  713. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  714. }
  715. /// <summary>
  716. /// 接团信息列表 Page Init
  717. /// </summary>
  718. /// <returns></returns>
  719. [HttpPost]
  720. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  721. public async Task<IActionResult> PostGroupPageListInit()
  722. {
  723. var depDatas = await GeneralMethod.GroupOpAffiliationBranchInit();
  724. var rankDatas = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 56).Select(x => new { x.Id, x.Name }).ToListAsync();
  725. rankDatas.Insert(0, new { Id = 0, Name = "全部" });
  726. var _view = new
  727. {
  728. depData = depDatas,
  729. rankData = rankDatas
  730. };
  731. return Ok(JsonView(true, "查询成功!", _view));
  732. }
  733. /// <summary>
  734. /// 接团信息列表 Page
  735. /// </summary>
  736. /// <param name="dto">团组列表请求dto</param>
  737. /// <returns></returns>
  738. [HttpPost]
  739. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  740. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  741. {
  742. #region 参数验证
  743. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  744. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  745. #region 页面操作权限验证
  746. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  747. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  748. #endregion
  749. #endregion
  750. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  751. {
  752. string sqlWhere = string.Empty;
  753. if (dto.IsSure == 0) //未完成
  754. {
  755. sqlWhere += string.Format(@" And IsSure = 0");
  756. }
  757. else if (dto.IsSure == 1) //已完成
  758. {
  759. sqlWhere += string.Format(@" And IsSure = 1");
  760. }
  761. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  762. {
  763. string tj = dto.SearchCriteria;
  764. 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}%')",
  765. tj, tj, tj, tj, tj);
  766. }
  767. if (int.TryParse(dto.Rank, out int rankId))
  768. {
  769. if (rankId > 0) sqlWhere += string.Format("And gdi.TeamLevSId = {0}", rankId);
  770. }
  771. string sqlWhere1 = string.Empty;
  772. if (!string.IsNullOrEmpty(dto.Department) && !dto.Department.Equals("全部"))
  773. {
  774. sqlWhere1 = string.Format("Where Department = '{0}'", dto.Department);
  775. }
  776. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,Department,
  777. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  778. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  779. JietuanOperator,IsSure,CreateTime,IsBid
  780. From (
  781. Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
  782. CASE WHEN gdi.JietuanOperator = 4 OR gdi.JietuanOperator = 21 THEN '国交部'
  783. ELSE (Select DepName FROM OA2023DB.dbo.Sys_Department WHERE Id = su.DepId) END AS 'Department',
  784. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  785. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  786. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  787. su.CnName JietuanOperator,IsSure,gdi.CreateTime,gdi.IsBid
  788. From Grp_DelegationInfo gdi
  789. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  790. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  791. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  792. Where gdi.IsDel = 0 {0}
  793. ) temp {1}", sqlWhere, sqlWhere1);
  794. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  795. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  796. //处理 团组模块实际操作人
  797. _DelegationList.ForEach(async x =>
  798. {
  799. var operators = GeneralMethod.GetGroupModuleOperators(x.Id);
  800. var operatorNames = new StringBuilder();
  801. //operatorNames.AppendLine("各模块实际操作人:");
  802. if (operators.Any())
  803. {
  804. operators.ForEach(y =>
  805. {
  806. string label = string.Empty;
  807. if (y.OperationUsers.Any())
  808. {
  809. var users = y.OperationUsers.Select(x => x.UserName).ToList();
  810. label = string.Join('、', users);
  811. }
  812. else label = "暂未指定";
  813. operatorNames.AppendLine($"{y.CTableName}:{label}");
  814. operatorNames.AppendLine();
  815. });
  816. }
  817. x.OperatorLabel = operatorNames.ToString().TrimEnd('\n', '\r');
  818. });
  819. var _view = new
  820. {
  821. PageFuncAuth = pageFunAuthView,
  822. Data = _DelegationList
  823. };
  824. return Ok(JsonView(true, "查询成功!", _view, total));
  825. }
  826. else
  827. {
  828. return Ok(JsonView(false, "查询失败"));
  829. }
  830. }
  831. /// <summary>
  832. /// 团组列表
  833. /// </summary>
  834. /// <returns></returns>
  835. [HttpPost]
  836. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  837. {
  838. #region 参数验证
  839. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  840. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  841. #region 页面操作权限验证
  842. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  843. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  844. #endregion
  845. #endregion
  846. if (dto.PortType != 1 && dto.PortType != 2)
  847. {
  848. return Ok(JsonView(false, "查询失败!"));
  849. }
  850. string orderbyStr = "order by gdi.CreateTime Desc";
  851. string sqlWhere = string.Empty;
  852. if (dto.IsSure == 0) //未完成
  853. {
  854. sqlWhere += string.Format(@" And IsSure = 0");
  855. }
  856. else if (dto.IsSure == 1) //已完成
  857. {
  858. sqlWhere += string.Format(@" And IsSure = 1");
  859. }
  860. //团组类型
  861. if (dto.TeamDid > 0)
  862. {
  863. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  864. }
  865. //团组名称
  866. if (!string.IsNullOrEmpty(dto.TeamName))
  867. {
  868. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  869. }
  870. //客户名称
  871. if (!string.IsNullOrEmpty(dto.ClientName))
  872. {
  873. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  874. }
  875. //客户单位
  876. if (!string.IsNullOrEmpty(dto.ClientUnit))
  877. {
  878. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  879. }
  880. //出访时间
  881. if (!string.IsNullOrEmpty(dto.visitDataTime))
  882. {
  883. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  884. orderbyStr = "order by gdi.VisitDate";
  885. }
  886. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  887. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  888. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  889. JietuanOperator,IsSure,CreateTime
  890. From (
  891. Select row_number() over({0}) as Row_Number,
  892. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  893. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  894. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  895. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  896. From Grp_DelegationInfo gdi
  897. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  898. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  899. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  900. Where gdi.IsDel = 0 {1}
  901. ) temp ", orderbyStr, sqlWhere);
  902. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  903. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  904. #region 处理所属部门
  905. /*
  906. * 1.sq 和 gyy 等显示 市场部
  907. * 2.王鸽和主管及张总还有管理员号统一国交部
  908. * 2-1. 4 管理员 ,21 张海麟
  909. */
  910. var userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  911. var userIds1 = new List<int>() { 4, 21 };
  912. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  913. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  914. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  915. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  916. .ToList();
  917. foreach (var item in _DelegationList)
  918. {
  919. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  920. }
  921. #endregion
  922. var _view = new
  923. {
  924. PageFuncAuth = pageFunAuthView,
  925. Data = _DelegationList
  926. };
  927. return Ok(JsonView(true, "查询成功!", _view, total));
  928. }
  929. /// <summary>
  930. /// 接团信息详情
  931. /// </summary>
  932. /// <param name="dto">团组info请求dto</param>
  933. /// <returns></returns>
  934. [HttpPost]
  935. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  936. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  937. {
  938. var groupData = await _groupRepository.GetGroupInfo(dto);
  939. if (groupData.Code != 0)
  940. {
  941. return Ok(JsonView(false, groupData.Msg));
  942. }
  943. return Ok(JsonView(groupData.Data));
  944. }
  945. /// <summary>
  946. /// 接团信息 编辑添加
  947. /// 基础信息数据源
  948. /// </summary>
  949. /// <param name="dto"></param>
  950. /// <returns></returns>
  951. [HttpPost]
  952. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  953. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  954. {
  955. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  956. if (groupData.Code != 0)
  957. {
  958. return Ok(JsonView(false, groupData.Msg));
  959. }
  960. return Ok(JsonView(groupData.Data));
  961. }
  962. /// <summary>
  963. /// 成本修改团组信息
  964. /// </summary>
  965. /// <param name="dto"></param>
  966. /// <returns></returns>
  967. [HttpPost]
  968. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  969. public async Task<IActionResult> GroupCostEditGroupInfo(GroupCostEditGroupInfoDto dto)
  970. {
  971. var jw = JsonView(false, "操作失败");
  972. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  973. if (di == null)
  974. {
  975. jw.Msg = "参数有误!";
  976. return Ok(jw);
  977. }
  978. #region 添加出访起止时间
  979. var startTime = new DateTime();
  980. var endTime = new DateTime();
  981. if (DateTime.TryParse(dto.VisitDate, out startTime))
  982. {
  983. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  984. }
  985. else
  986. {
  987. jw.Msg = "参数有误!";
  988. return Ok(jw);
  989. }
  990. #endregion
  991. di.VisitDate = startTime;
  992. di.VisitPNumber = dto.VisitPNumber;
  993. di.VisitDays = dto.VisitDays;
  994. di.VisitStartDate = startTime;
  995. di.VisitEndDate = endTime;
  996. var count = _sqlSugar.Updateable(di)
  997. .UpdateColumns(x => new { x.VisitDate, x.VisitPNumber, x.VisitDays, x.VisitStartDate, x.VisitEndDate })
  998. .ExecuteCommand();
  999. return Ok(count > 0 ? JsonView(true, "操作成功") : jw);
  1000. }
  1001. /// <summary>
  1002. /// 接团信息 编辑添加
  1003. /// 省份-城市 基础信息数据源
  1004. /// </summary>
  1005. /// <param name="dto"></param>
  1006. /// <returns></returns>
  1007. [HttpPost]
  1008. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1009. public async Task<IActionResult> GroupProvCityBasicSource(GroupProvCityBasicSourceDto dto)
  1010. {
  1011. int pageIndex = dto.PageIndex, pageSize = dto.PageSize;
  1012. string search = dto.Search;
  1013. var data = await _groupRepository.CityBasicSource();
  1014. int total = data.Length;
  1015. data = data.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search))
  1016. .Skip((pageIndex - 1) * pageSize)
  1017. .Take(pageSize)
  1018. .ToArray();
  1019. return Ok(JsonView(data, total));
  1020. }
  1021. /// <summary>
  1022. /// 接团信息 操作(增改)
  1023. /// </summary>
  1024. /// <param name="dto"></param>
  1025. /// <returns></returns>
  1026. [HttpPost]
  1027. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1028. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  1029. {
  1030. // 创建 Stopwatch 实例
  1031. Stopwatch stopwatch = Stopwatch.StartNew();
  1032. decimal ffrPrice = 0.00M;
  1033. DateTime? visitDt = null;
  1034. if (dto.Status == 2)
  1035. {
  1036. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1037. if (groupInfo != null)
  1038. {
  1039. ffrPrice = groupInfo.PaymentMoney;
  1040. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1041. }
  1042. }
  1043. var groupData = await _groupRepository.GroupOperation(dto);
  1044. if (groupData.Code != 0)
  1045. {
  1046. return Ok(JsonView(false, groupData.Msg));
  1047. }
  1048. int diId = 0;
  1049. try
  1050. {
  1051. //添加时 默认加入团组汇率
  1052. if (dto.Status == 1) //添加
  1053. {
  1054. diId = groupData.Data;
  1055. //添加默认币种
  1056. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1057. //默认分配权限
  1058. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1059. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1060. var _managerIds = new List<int>() { 22, 32, 21 };
  1061. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1062. if (userIds.Count > 0)
  1063. {
  1064. userIds.Add(208);
  1065. //创建团组管控
  1066. GroupStepForDelegation.CreateWorkStep(diId);
  1067. //发送消息
  1068. string groupName = dto.TeamName;
  1069. string createGroupUser = string.Empty;
  1070. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1071. if (userInfo != null) createGroupUser = userInfo.CnName;
  1072. string title = $"系统通知";
  1073. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1074. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1075. }
  1076. //默认创建倒推表
  1077. await _invertedListRep._Create(dto.UserId, diId);
  1078. }
  1079. else if (dto.Status == 2)
  1080. {
  1081. diId = dto.Id;
  1082. }
  1083. #region 签证人员团组时间通知
  1084. #region 计算出访起止时间
  1085. var startTime = new DateTime();
  1086. var endTime = new DateTime();
  1087. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1088. {
  1089. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1090. }
  1091. #endregion
  1092. #endregion
  1093. #region 团组操作默认添加/修改收款账单
  1094. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1095. {
  1096. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1097. .Where(x => x.IsDel == 0 &&
  1098. x.Diid == diId &&
  1099. x.Remark.Equals("预付款")
  1100. )
  1101. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1102. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1103. .FirstAsync();
  1104. ffrInfo = new Fin_ForeignReceivables()
  1105. {
  1106. Diid = diId,
  1107. PriceName = dto.ClientUnit,
  1108. Price = dto.PaymentMoney,
  1109. Count = 1,
  1110. Unit = $"元",
  1111. ItemSumPrice = dto.PaymentMoney,
  1112. Rate = 1.0000M,
  1113. Currency = 836,
  1114. AddingWay = 0,
  1115. CreateUserId = dto.UserId,
  1116. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1117. Remark = $"预付款"
  1118. };
  1119. if (ffrInfo == null) //Add
  1120. {
  1121. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1122. }
  1123. else //修改
  1124. {
  1125. await _sqlSugar.Updateable(ffrInfo)
  1126. .UpdateColumns(x => new
  1127. {
  1128. x.PriceName,
  1129. x.Price,
  1130. x.ItemSumPrice,
  1131. x.CreateTime,
  1132. x.CreateUserId
  1133. })
  1134. .WhereColumns(x => x.Id)
  1135. .ExecuteCommandAsync();
  1136. }
  1137. }
  1138. #endregion
  1139. if (diId > 0)
  1140. {
  1141. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1142. }
  1143. // 停止计时
  1144. stopwatch.Stop();
  1145. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  1146. }
  1147. catch (Exception ex)
  1148. {
  1149. // 停止计时
  1150. stopwatch.Stop();
  1151. Logs("[response]" + JsonConvert.SerializeObject(dto));
  1152. Logs(ex.Message);
  1153. //return Ok(JsonView(false, $"{ex.Message}[{stopwatch.ElapsedMilliseconds}ms]"));
  1154. }
  1155. // 停止计时
  1156. stopwatch.Stop();
  1157. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  1158. }
  1159. /// <summary>
  1160. /// 接团流程操作(增改)
  1161. /// 安卓端使用 建团时添加客户名单
  1162. /// </summary>
  1163. /// <param name="dto"></param>
  1164. /// <returns></returns>
  1165. [HttpPost]
  1166. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1167. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  1168. {
  1169. #region 参数验证
  1170. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  1171. #region 页面操作权限验证
  1172. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  1173. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  1174. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  1175. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  1176. #endregion
  1177. #endregion
  1178. try
  1179. {
  1180. //_sqlSugar.BeginTran();
  1181. decimal ffrPrice = 0.00M;
  1182. DateTime? visitDt = null;
  1183. if (dto.Status == 2)
  1184. {
  1185. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1186. if (groupInfo != null)
  1187. {
  1188. ffrPrice = groupInfo.PaymentMoney;
  1189. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1190. }
  1191. }
  1192. var _dto = new GroupOperationDto();
  1193. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  1194. var groupData = await _groupRepository.GroupOperation(_dto);
  1195. if (groupData.Code != 0)
  1196. {
  1197. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  1198. }
  1199. int diId = 0;
  1200. //添加时 默认加入团组汇率
  1201. if (dto.Status == 1) //添加
  1202. {
  1203. diId = groupData.Data;
  1204. //添加默认币种
  1205. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1206. //默认分配权限
  1207. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1208. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1209. var _managerIds = new List<int>() { 21, 22, 32 };
  1210. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1211. if (userIds.Count > 0)
  1212. {
  1213. userIds.Add(208);
  1214. //创建团组管控
  1215. GroupStepForDelegation.CreateWorkStep(diId);
  1216. //发送消息
  1217. string groupName = dto.TeamName;
  1218. string createGroupUser = string.Empty;
  1219. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1220. if (userInfo != null) createGroupUser = userInfo.CnName;
  1221. string title = $"系统通知";
  1222. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1223. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1224. }
  1225. #region 应用推送
  1226. try
  1227. {
  1228. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1229. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1230. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1231. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1232. {
  1233. var userList = new List<string>() { users.QiyeChatUserId };
  1234. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1235. }
  1236. }
  1237. catch (Exception ex)
  1238. {
  1239. }
  1240. #endregion
  1241. //默认创建倒推表
  1242. await _invertedListRep._Create(dto.UserId, diId);
  1243. }
  1244. if (dto.Status == 2)
  1245. {
  1246. diId = dto.Id;
  1247. if (diId == 0)
  1248. {
  1249. //_sqlSugar.RollbackTran();
  1250. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  1251. }
  1252. }
  1253. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1254. if (viewData.Code != 0)
  1255. {
  1256. //_sqlSugar.RollbackTran();
  1257. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1258. }
  1259. #region 团组操作默认添加/修改收款账单
  1260. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1261. {
  1262. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1263. .Where(x => x.IsDel == 0 &&
  1264. x.Diid == diId &&
  1265. x.Remark.Equals("预付款")
  1266. )
  1267. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1268. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1269. .FirstAsync();
  1270. ffrInfo = new Fin_ForeignReceivables()
  1271. {
  1272. Diid = diId,
  1273. PriceName = dto.ClientUnit,
  1274. Price = dto.PaymentMoney,
  1275. Count = 1,
  1276. Unit = $"元",
  1277. ItemSumPrice = dto.PaymentMoney,
  1278. Rate = 1.0000M,
  1279. Currency = 836,
  1280. AddingWay = 0,
  1281. CreateUserId = dto.UserId,
  1282. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1283. Remark = $"预付款"
  1284. };
  1285. if (ffrInfo == null) //Add
  1286. {
  1287. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1288. }
  1289. else //修改
  1290. {
  1291. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1292. .UpdateColumns(x => new
  1293. {
  1294. x.PriceName,
  1295. x.Price,
  1296. x.ItemSumPrice,
  1297. x.CreateTime,
  1298. x.CreateUserId
  1299. })
  1300. .WhereColumns(x => x.Id)
  1301. .ExecuteCommandAsync();
  1302. }
  1303. }
  1304. #endregion
  1305. #region 签证人员团组时间通知
  1306. #region 计算出访起止时间
  1307. var startTime = new DateTime();
  1308. var endTime = new DateTime();
  1309. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1310. {
  1311. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1312. }
  1313. #endregion
  1314. if (diId > 0)
  1315. {
  1316. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1317. }
  1318. #endregion
  1319. //_sqlSugar.CommitTran();
  1320. return Ok(JsonView(true, "添加成功"));
  1321. }
  1322. catch (Exception ex)
  1323. {
  1324. _sqlSugar.RollbackTran();
  1325. return Ok(JsonView(false, ex.Message));
  1326. }
  1327. }
  1328. /// <summary>
  1329. /// 接团流程操作(增改)
  1330. /// 安卓端使用 建团时添加客户名单
  1331. /// </summary>
  1332. /// <param name="dto"></param>
  1333. /// <returns></returns>
  1334. [HttpPost]
  1335. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1336. public async Task<IActionResult> GroupProcessOperation1(GroupProcessOperationDto dto)
  1337. {
  1338. #region 参数验证
  1339. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  1340. #region 页面操作权限验证
  1341. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  1342. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  1343. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  1344. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  1345. #endregion
  1346. #endregion
  1347. _sqlSugar.BeginTran();
  1348. decimal ffrPrice = 0.00M;
  1349. DateTime? visitDt = null;
  1350. if (dto.Status == 2)
  1351. {
  1352. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1353. if (groupInfo != null)
  1354. {
  1355. ffrPrice = groupInfo.PaymentMoney;
  1356. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1357. }
  1358. }
  1359. var _dto = new GroupOperationDto();
  1360. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  1361. var groupData = await _groupRepository.GroupOperation(_dto);
  1362. if (groupData.Code != 0)
  1363. {
  1364. _sqlSugar.RollbackTran();
  1365. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  1366. }
  1367. try
  1368. {
  1369. int diId = 0;
  1370. //添加时 默认加入团组汇率
  1371. if (dto.Status == 1) //添加
  1372. {
  1373. diId = groupData.Data;
  1374. //添加默认币种
  1375. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1376. //默认分配权限
  1377. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1378. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1379. var _managerIds = new List<int>() { 21, 22, 32 };
  1380. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1381. if (userIds.Count > 0)
  1382. {
  1383. userIds.Add(208);
  1384. //创建团组管控
  1385. GroupStepForDelegation.CreateWorkStep(diId);
  1386. //发送消息
  1387. string groupName = dto.TeamName;
  1388. string createGroupUser = string.Empty;
  1389. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1390. if (userInfo != null) createGroupUser = userInfo.CnName;
  1391. string title = $"系统通知";
  1392. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1393. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1394. }
  1395. #region 应用推送
  1396. try
  1397. {
  1398. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1399. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1400. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1401. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1402. {
  1403. var userList = new List<string>() { users.QiyeChatUserId };
  1404. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1405. }
  1406. }
  1407. catch (Exception ex)
  1408. {
  1409. _sqlSugar.CommitTran();
  1410. return Ok(JsonView(true, "操作成功! 应用推送异常:" + groupData.Msg));
  1411. }
  1412. #endregion
  1413. //默认创建倒推表
  1414. await _invertedListRep._Create(dto.UserId, diId);
  1415. }
  1416. else if (dto.Status == 2)
  1417. {
  1418. diId = dto.Id;
  1419. if (diId == 0)
  1420. {
  1421. _sqlSugar.RollbackTran();
  1422. return Ok(JsonView(false, "操作失败! 未添加团组id" + groupData.Msg));
  1423. }
  1424. }
  1425. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1426. if (viewData.Code != 0)
  1427. {
  1428. _sqlSugar.RollbackTran();
  1429. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1430. }
  1431. #region 团组操作默认添加/修改收款账单
  1432. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1433. {
  1434. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1435. .Where(x => x.IsDel == 0 &&
  1436. x.Diid == diId &&
  1437. x.Remark.Equals("预付款")
  1438. )
  1439. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1440. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1441. .FirstAsync();
  1442. ffrInfo = new Fin_ForeignReceivables()
  1443. {
  1444. Diid = diId,
  1445. PriceName = dto.ClientUnit,
  1446. Price = dto.PaymentMoney,
  1447. Count = 1,
  1448. Unit = $"元",
  1449. ItemSumPrice = dto.PaymentMoney,
  1450. Rate = 1.0000M,
  1451. Currency = 836,
  1452. AddingWay = 0,
  1453. CreateUserId = dto.UserId,
  1454. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1455. Remark = $"预付款"
  1456. };
  1457. if (ffrInfo == null) //Add
  1458. {
  1459. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1460. }
  1461. else //修改
  1462. {
  1463. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1464. .UpdateColumns(x => new
  1465. {
  1466. x.PriceName,
  1467. x.Price,
  1468. x.ItemSumPrice,
  1469. x.CreateTime,
  1470. x.CreateUserId
  1471. })
  1472. .WhereColumns(x => x.Id)
  1473. .ExecuteCommandAsync();
  1474. }
  1475. }
  1476. #endregion
  1477. #region 签证人员团组时间通知
  1478. #region 计算出访起止时间
  1479. var startTime = new DateTime();
  1480. var endTime = new DateTime();
  1481. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1482. {
  1483. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1484. }
  1485. #endregion
  1486. if (diId > 0)
  1487. {
  1488. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1489. }
  1490. #endregion
  1491. _sqlSugar.CommitTran();
  1492. return Ok(JsonView(true));
  1493. }
  1494. catch (Exception ex)
  1495. {
  1496. _sqlSugar.RollbackTran();
  1497. return Ok(JsonView(false, ex.Message));
  1498. }
  1499. }
  1500. /// <summary>
  1501. /// 接团信息 操作(删除)
  1502. /// </summary>
  1503. /// <param name="dto"></param>
  1504. /// <returns></returns>
  1505. [HttpPost]
  1506. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1507. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  1508. {
  1509. var diId = dto.Id;
  1510. if (diId < 1) return Ok(JsonView(false, MsgTips.Id));
  1511. #region 删除 验证
  1512. /*
  1513. * 1、收款账单数据:0 条
  1514. * 2、收款退还数据:0 条
  1515. * 3、机票费用数据:0 条
  1516. * 4、签证费用数据:0 条
  1517. * 5、保险费用数据:0 条
  1518. * 6、酒店费用数据:0 条
  1519. * 7、公务出访数据:1 条
  1520. * 8、邀请公务活动费用数据:1 条
  1521. * 9、OP费用数据:5 条
  1522. * 10、其他费用数据:0 条
  1523. * 11、团组日付报销费用数据:0 条
  1524. *
  1525. * 温馨提示:该团组已产生费用,不允许删除;如需删除,请先删除对应版块费用,谢谢!
  1526. */
  1527. //收款账单
  1528. int frCount = _sqlSugar.Queryable<Fin_ForeignReceivables>().Where(x => x.IsDel == 0 && x.Diid == diId).Count();
  1529. //收款退还
  1530. int fraomCount = _sqlSugar.Queryable<Fin_PaymentRefundAndOtherMoney>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1531. //机票费用
  1532. int arCount = _sqlSugar.Queryable<Grp_AirTicketReservations>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
  1533. //签证费用
  1534. int viCount = _sqlSugar.Queryable<Grp_VisaInfo>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
  1535. //保险费用
  1536. int cCount = _sqlSugar.Queryable<Grp_Customers>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1537. //酒店费用
  1538. int hrCount = _sqlSugar.Queryable<Grp_HotelReservations>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1539. //公务出访
  1540. int oaCount = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1541. //邀请公务活动费用
  1542. int ioaCount = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1543. //OP费用
  1544. int ctggrCount = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1545. //其他费用
  1546. int dpCount = _sqlSugar.Queryable<Grp_DecreasePayments>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1547. //团组日付报销费用
  1548. int dfpCount = _sqlSugar.Queryable<Fin_DailyFeePayment>().Where(x => x.IsDel == 0 && x.GroupId == diId).Count();
  1549. var feeCount = frCount + fraomCount + arCount + viCount + cCount + hrCount + oaCount + ioaCount + ctggrCount + dpCount + dfpCount;
  1550. if (feeCount > 0)
  1551. {
  1552. var delMsgTips = new StringBuilder();
  1553. delMsgTips.AppendLine($"1、收款账单数据:{frCount} 条");
  1554. delMsgTips.AppendLine($"2、收款退换数据:{fraomCount} 条");
  1555. delMsgTips.AppendLine($"3、机票费用数据:{arCount} 条");
  1556. delMsgTips.AppendLine($"4、签证费用数据:{viCount} 条");
  1557. delMsgTips.AppendLine($"5、保险费用数据:{cCount} 条");
  1558. delMsgTips.AppendLine($"6、酒店费用数据:{hrCount} 条");
  1559. delMsgTips.AppendLine($"7、公务出访数据:{oaCount} 条");
  1560. delMsgTips.AppendLine($"8、邀请公务活动费用数据:{ioaCount} 条");
  1561. delMsgTips.AppendLine($"9、OP费用数据:{ctggrCount} 条");
  1562. delMsgTips.AppendLine($"10、其他费用数据:{dpCount} 条");
  1563. delMsgTips.AppendLine($"11、团组日付报销费用数据:{dfpCount} 条");
  1564. delMsgTips.AppendLine($"");
  1565. delMsgTips.AppendLine($"温馨提示:该团组已产生费用,不允许删除;如需删除,请先删除对应版块费用,谢谢!");
  1566. return Ok(JsonView(false, delMsgTips.ToString()));
  1567. }
  1568. #endregion
  1569. var groupData = await _groupRepository.GroupDel(dto);
  1570. if (groupData.Code != 0)
  1571. {
  1572. return Ok(JsonView(false, groupData.Msg));
  1573. }
  1574. return Ok(JsonView(true));
  1575. }
  1576. /// <summary>
  1577. /// 获取团组销售报价号
  1578. /// 团组添加时 使用
  1579. /// </summary>
  1580. /// <returns></returns>
  1581. [HttpPost]
  1582. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1583. public async Task<IActionResult> GetGroupSalesQuoteNo()
  1584. {
  1585. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  1586. if (groupData.Code != 0)
  1587. {
  1588. return Ok(JsonView(false, groupData.Msg));
  1589. }
  1590. object salesQuoteNo = new
  1591. {
  1592. SalesQuoteNo = groupData.Data
  1593. };
  1594. return Ok(JsonView(salesQuoteNo));
  1595. }
  1596. /// <summary>
  1597. /// 设置确认出团
  1598. /// </summary>
  1599. /// <param name="dto"></param>
  1600. /// <returns></returns>
  1601. [HttpPost]
  1602. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1603. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  1604. {
  1605. var groupData = await _groupRepository.ConfirmationGroup(dto);
  1606. if (groupData.Code != 0)
  1607. {
  1608. return Ok(JsonView(false, groupData.Msg));
  1609. }
  1610. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  1611. #region OA消息推送
  1612. try
  1613. {
  1614. string groupName = groupInfo.TeamName;
  1615. var userIds = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).Select(x => x.Id).ToList();
  1616. string title = $"系统通知";
  1617. string content = $"团组[{groupName}]已确认出团!";
  1618. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  1619. }
  1620. catch (Exception ex)
  1621. {
  1622. }
  1623. #endregion
  1624. #region 应用推送
  1625. try
  1626. {
  1627. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  1628. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  1629. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1630. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1631. {
  1632. var userList = new List<string>() { users.QiyeChatUserId };
  1633. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  1634. }
  1635. }
  1636. catch (Exception ex)
  1637. {
  1638. }
  1639. #endregion
  1640. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  1641. return Ok(JsonView(true, "操作成功!", groupData.Data));
  1642. }
  1643. /// <summary>
  1644. /// 获取团组名称data And 签证国别Data
  1645. /// </summary>
  1646. /// <param name="dto"></param>
  1647. /// <returns></returns>
  1648. [HttpPost]
  1649. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1650. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  1651. {
  1652. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  1653. if (groupData.Code != 0)
  1654. {
  1655. return Ok(JsonView(false, groupData.Msg));
  1656. }
  1657. return Ok(JsonView(groupData.Data));
  1658. }
  1659. /// <summary>
  1660. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  1661. /// </summary>
  1662. /// <returns></returns>
  1663. [HttpPost]
  1664. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1665. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  1666. {
  1667. try
  1668. {
  1669. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  1670. if (groupData.Code != 0)
  1671. {
  1672. return Ok(JsonView(false, groupData.Msg));
  1673. }
  1674. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1675. }
  1676. catch (Exception ex)
  1677. {
  1678. return Ok(JsonView(false, ex.Message));
  1679. throw;
  1680. }
  1681. }
  1682. /// <summary>
  1683. /// 团组清单 Excel
  1684. /// </summary>
  1685. /// <param name="beginDt">开始时间 EG:“2024-01-01”</param>
  1686. /// <param name="endDt">结束时间 EG;“2024-12-31”</param>
  1687. /// <returns></returns>
  1688. [HttpGet]
  1689. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1690. public async Task<IActionResult> GroupListFile([FromQuery] string beginDt, [FromQuery] string endDt)
  1691. {
  1692. bool beginBool = DateTime.TryParse($"{beginDt} 00:00:00", out DateTime _beginDt),
  1693. endBool = DateTime.TryParse($"{endDt} 23:59:59", out DateTime _endDt);
  1694. if (!beginBool && !endBool)
  1695. {
  1696. return Ok(JsonView(false, "开始或结束时间不正确!"));
  1697. }
  1698. string sql = string.Format(@"
  1699. SELECT
  1700. ROW_NUMBER,
  1701. Id,
  1702. SalesQuoteNo,
  1703. TourCode,
  1704. TeamTypeId,
  1705. TeamType,
  1706. TeamLevId,
  1707. TeamLev,
  1708. TeamName,
  1709. ClientName,
  1710. ClientUnit,
  1711. VisitDate,
  1712. VisitDays,
  1713. VisitPNumber,
  1714. JietuanOperatorId,
  1715. JietuanOperator,
  1716. IsSure,
  1717. CreateUserName,
  1718. IsBid
  1719. FROM
  1720. (
  1721. SELECT
  1722. ROW_NUMBER() OVER(
  1723. ORDER BY
  1724. gdi.VisitDate Desc
  1725. ) AS ROW_NUMBER,
  1726. gdi.Id,
  1727. SalesQuoteNo,
  1728. TourCode,
  1729. ssd.Id TeamTypeId,
  1730. ssd.Name TeamType,
  1731. ssd1.Id TeamLevId,
  1732. ssd1.Name TeamLev,
  1733. TeamName,
  1734. ClientName,
  1735. ClientUnit,
  1736. VisitDate,
  1737. VisitDays,
  1738. VisitPNumber,
  1739. JietuanOperator JietuanOperatorId,
  1740. su.CnName JietuanOperator,
  1741. IsSure,
  1742. gdi.CreateTime,
  1743. su1.CnName As CreateUserName,
  1744. gdi.IsBid
  1745. FROM
  1746. Grp_DelegationInfo gdi
  1747. LEFT JOIN Sys_SetData ssd ON gdi.TeamDid = ssd.Id
  1748. LEFT JOIN Sys_SetData ssd1 ON gdi.TeamLevSId = ssd1.Id
  1749. LEFT JOIN Sys_Users su ON gdi.JietuanOperator = su.Id
  1750. LEFT JOIN Sys_Users su1 ON gdi.CreateUserId = su1.Id
  1751. WHERE
  1752. gdi.IsDel = 0
  1753. AND gdi.IsBid = 0
  1754. AND gdi.VisitDate BETWEEN '{0}' AND '{1}'
  1755. ) temp", _beginDt.ToString("yyyy-MM-dd HH:mm:ss"), _endDt.ToString("yyyy-MM-dd HH:mm:ss"));
  1756. var groupList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToListAsync();
  1757. #region 处理所属部门
  1758. /*
  1759. * 1.sq 和 gyy 等显示 市场部
  1760. * 2.王鸽和主管及张总还有管理员号统一国交部
  1761. * 2-1. 4 管理员 ,21 张海麟
  1762. */
  1763. var userIds = groupList.Select(it => it.JietuanOperatorId).ToList();
  1764. var userIds1 = new List<int>() { 4, 21 };
  1765. var userDepDatas = await _sqlSugar.Queryable<Sys_Users>()
  1766. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  1767. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  1768. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  1769. .ToListAsync();
  1770. var droupIds = groupList.Select(it => it.Id).ToList();
  1771. var deleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  1772. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  1773. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  1774. .Where((tcl, dc, cc) => tcl.IsDel == 0 && droupIds.Contains(tcl.DiId))
  1775. .Select((tcl, dc, cc) => new ClientInfoInfo_Group
  1776. {
  1777. DiId = tcl.DiId,
  1778. LastName = dc.LastName,
  1779. FirstName = dc.FirstName,
  1780. Sex = dc.Sex,
  1781. Birthday = dc.BirthDay,
  1782. Company = cc.CompanyFullName,
  1783. Job = dc.Job,
  1784. CreateTime = tcl.CreateTime,
  1785. })
  1786. .ToList();
  1787. foreach (var item in groupList)
  1788. {
  1789. item.Department = userDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  1790. string groupFirstName = "";
  1791. var currDatas = deleClientList.Where(x => x.DiId == item.Id).ToList();
  1792. if (currDatas.Any())
  1793. {
  1794. groupFirstName = AesEncryptionHelper.Decrypt(currDatas[0].LastName) + AesEncryptionHelper.Decrypt(currDatas[0].FirstName);
  1795. }
  1796. item.GroupFirst = groupFirstName;
  1797. }
  1798. #endregion
  1799. #region Excel
  1800. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  1801. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  1802. var savePath = AppSettingsHelper.Get("GrpListFileBasePath");
  1803. var ftpPath = AppSettingsHelper.Get("GrpListFileFtpPath");
  1804. var fileName = $"团组清单({beginDt}~{endDt}){DateTime.Now:yyyyMMddHHmmss}.xlsx";
  1805. //载入模板
  1806. var designer = new WorkbookDesigner
  1807. {
  1808. Workbook = new Workbook($"{tempPath}团组清单模板.xlsx")
  1809. };
  1810. designer.SetDataSource("Titel", $"团组清单({beginDt}~{endDt})");
  1811. DataTable dt = CommonFun.GetDataTableFromIList<DelegationListView>(groupList); ;
  1812. dt.TableName = "GroupList";
  1813. designer.SetDataSource(dt);
  1814. designer.Process();
  1815. if (!Directory.Exists(savePath))
  1816. {
  1817. Directory.CreateDirectory(savePath);
  1818. }
  1819. string serverPath = $"{savePath}{fileName}";
  1820. designer.Workbook.Save(serverPath);
  1821. string rst = $"{servicePath}{ftpPath}{fileName}";
  1822. #endregion
  1823. return Ok(JsonView(true, "操作成功!", rst));
  1824. }
  1825. /// <summary>
  1826. /// 团组合同下载(1.付款80% 2.付全款)
  1827. /// </summary>
  1828. /// <param name="dto"></param>
  1829. /// <returns></returns>
  1830. /// <exception cref="Exception"></exception>
  1831. [HttpPost]
  1832. public async Task<IActionResult> DownGroupContractFile(DownGroupContractFileDto dto)
  1833. {
  1834. var jw = JsonView(false);
  1835. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  1836. .FirstAsync(x => x.Id == dto.GroupId && x.IsDel == 0);
  1837. if (di == null)
  1838. {
  1839. jw.Msg = "团组Id有误!";
  1840. return Ok(jw);
  1841. }
  1842. #region 权限校验
  1843. var allDownFile = new List<int>() { 21 };
  1844. try
  1845. {
  1846. var setting = _sqlSugar.Queryable<Sys_SetData>()
  1847. .First(x => x.Id == 1418 && x.IsDel == 0);
  1848. allDownFile.AddRange(JsonConvert.DeserializeObject<List<int>>(setting.Remark));
  1849. }
  1850. catch (Exception)
  1851. { }
  1852. var guojiaoDownFile = new List<int>() { 330 };
  1853. var shichangDownFile = new List<int>() { 95 };
  1854. if (allDownFile.Contains(dto.UserId))
  1855. {
  1856. }
  1857. else if (guojiaoDownFile.Contains(dto.UserId))
  1858. {
  1859. var guojiaobuDi = new List<int>() { 4, 21 };
  1860. var departmentStr = _sqlSugar.Queryable<Sys_Department>()
  1861. .LeftJoin<Sys_Users>((d, u) => d.Id == u.DepId && u.IsDel == 0)
  1862. .Where((d, u) => u.Id == di.JietuanOperator)
  1863. .Select((d, u) => d.DepName)
  1864. .First();
  1865. if (!guojiaobuDi.Contains(di.JietuanOperator) && departmentStr != "策划部" && departmentStr != "国交部")
  1866. {
  1867. jw.Msg = "暂无下载权限!";
  1868. return Ok(jw);
  1869. }
  1870. }
  1871. else if (shichangDownFile.Contains(dto.UserId))
  1872. {
  1873. var dic = new Dictionary<int, int[]>()
  1874. {
  1875. { 95, new int []{ 95 , 337 , 302, 350, 355, 357, 353 , 359 , 361, 368, 364, 366, 369} }
  1876. };
  1877. try
  1878. {
  1879. var sqSetting = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1417);
  1880. if (sqSetting != null)
  1881. {
  1882. Dictionary<int, int[]> result = JsonConvert.DeserializeObject<Dictionary<int, int[]>>(sqSetting.Remark);
  1883. foreach (var item in result.Keys)
  1884. {
  1885. if (dic.ContainsKey(item))
  1886. {
  1887. int[] dilatation = new int[dic[item].Length + result[item].Length];
  1888. Array.Copy(dic[item], dilatation, dic[item].Length);
  1889. Array.Copy(result[item], 0, dilatation, dic[item].Length, result[item].Length);
  1890. dic[item] = dilatation;
  1891. }
  1892. else
  1893. {
  1894. dic.Add(item, result[item]);
  1895. }
  1896. }
  1897. }
  1898. if (!dic[95].Contains(di.CreateUserId))
  1899. {
  1900. jw.Msg = "暂无下载权限!";
  1901. return Ok(jw);
  1902. }
  1903. }
  1904. catch (Exception)
  1905. { }
  1906. }
  1907. else if (dto.UserId == di.CreateUserId)
  1908. {
  1909. }
  1910. else
  1911. {
  1912. jw.Msg = "暂无下载权限!";
  1913. return Ok(jw);
  1914. }
  1915. #endregion
  1916. var blackCodeList = await _sqlSugar.Queryable<Air_TicketBlackCode>()
  1917. .Where(x => x.DiId == dto.GroupId && x.IsDel == 0)
  1918. .ToListAsync();
  1919. if (!blackCodeList.Any())
  1920. {
  1921. jw.Msg = "该团无机票行程代码!";
  1922. return Ok(jw);
  1923. }
  1924. var groupEnterExitCost = await _sqlSugar.Queryable<Grp_EnterExitCost>()
  1925. .FirstAsync(x => x.DiId == dto.GroupId && x.IsDel == 0);
  1926. if (groupEnterExitCost == null)
  1927. {
  1928. jw.Msg = "暂无三公费用信息!";
  1929. return Ok(jw);
  1930. }
  1931. var rateList = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(groupEnterExitCost.CurrencyRemark);
  1932. rateList ??= new List<CurrencyInfo>();
  1933. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == di.Id).ToList();
  1934. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  1935. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  1936. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  1937. .Where((x, a, b) => x.IsDel == 0 && x.Diid == di.Id)
  1938. .Select((x, a, b) => new
  1939. {
  1940. x.Index,
  1941. itemName = a.Name,
  1942. CurrencyStr = b.Name,
  1943. x.Cost,
  1944. x.SubTotal,
  1945. x.Remark
  1946. })
  1947. .OrderBy((x) => x.Index)
  1948. .ToList();
  1949. decimal stayFeeTotal = groupEnterExitCost.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  1950. decimal mealsFeeTotal = groupEnterExitCost.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  1951. decimal miscellaneousFeeTotal = groupEnterExitCost.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  1952. decimal tainFeeTotal = groupEnterExitCost.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  1953. decimal otherPriceTotal = groupEnterExitCost.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  1954. decimal insidePayTotal = groupEnterExitCost.ChoiceOne == 1 ? groupEnterExitCost.InsidePay : 0.00M;
  1955. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  1956. decimal subJJC = 0.00M,
  1957. subGWC = 0.00M,
  1958. subTDC = 0.00M;
  1959. //经济舱
  1960. if (groupEnterExitCost.SumJJC == 1)
  1961. {
  1962. subJJC = otherFeeTotal + groupEnterExitCost.OutsideJJPay;
  1963. }
  1964. //公务舱
  1965. if (groupEnterExitCost.SumGWC == 1)
  1966. {
  1967. subGWC = otherFeeTotal + groupEnterExitCost.OutsideGWPay;
  1968. }
  1969. //头等舱
  1970. if (groupEnterExitCost.SumTDC == 1)
  1971. {
  1972. subTDC = otherFeeTotal + groupEnterExitCost.OutsideTDPay;
  1973. }
  1974. var groupClints = await _sqlSugar.Queryable<Grp_TourClientList>()
  1975. .LeftJoin<Sys_SetData>((x, s) => s.Id == x.ShippingSpaceTypeId && s.IsDel == 0)
  1976. .LeftJoin<Crm_DeleClient>((x, s, dc) => x.ClientId == dc.Id && dc.IsDel == 0)
  1977. .LeftJoin<Crm_CustomerCompany>((x, s, dc, cc) => dc.CrmCompanyId == cc.Id && cc.IsDel == 0)
  1978. .Where((x, s, dc, cc) => x.DiId == dto.GroupId && x.IsDel == 0)
  1979. .Select((x, s, dc, cc) => new GroupClints
  1980. {
  1981. Id = x.Id,
  1982. Name = s.Name,
  1983. IsAccompany = x.IsAccompany,
  1984. CompanyFullName = cc.CompanyFullName
  1985. })
  1986. .ToListAsync();
  1987. groupClints.ForEach(x => x.CompanyFullName = AesEncryptionHelper.Decrypt(x.CompanyFullName));
  1988. //获取舱位人数
  1989. var cabinCount = groupClints.Where(x => x.IsAccompany != 2 && !x.CompanyFullName.Contains("泛美国际"))
  1990. .GroupBy(x => x.Name)
  1991. .Select(x => new { Cabin = x.Key, Count = x.Count() })
  1992. .ToList();
  1993. string cityPath = string.Empty;
  1994. string startCity = string.Empty;
  1995. string endCity = string.Empty;
  1996. foreach (var item in blackCodeList)
  1997. {
  1998. string city = GeneralMethod.GetGroupCityLine(item, "-");
  1999. cityPath += city + "\r\n";
  2000. if (item.Equals(blackCodeList.First()))
  2001. {
  2002. var sp = city.Split('-');
  2003. startCity = sp[0];
  2004. endCity = sp[^1];
  2005. }
  2006. }
  2007. var bookMarkDic = new Dictionary<string, string>
  2008. {
  2009. { "ClientUnit", di.ClientUnit },
  2010. { "VisitCountry", di.VisitCountry },
  2011. { "VisitDate", di.VisitDate.ToString("yyyy年MM月dd日") },
  2012. { "VisitPNumber", di.VisitPNumber.ToString() },
  2013. { "CityPath", cityPath },
  2014. { "StartCity", startCity },
  2015. { "EndCity", endCity },
  2016. { "StayDays", $"{di.VisitDays}天{di.VisitDays - 1}晚" }
  2017. };
  2018. Document doc = null;
  2019. var percentage = 0.8M;
  2020. var fileNameadd = "预付";
  2021. if (dto.FileType == 1)
  2022. {
  2023. doc = new Document($"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Template/团组合同bookmarkFormat.doc");
  2024. }
  2025. else if (dto.FileType == 2)
  2026. {
  2027. doc = new Document($"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Template/团组合同全款无表格.doc");
  2028. percentage = 1;
  2029. fileNameadd = "全款";
  2030. }
  2031. else
  2032. {
  2033. throw new Exception("FileType有误!");
  2034. }
  2035. var builder = new DocumentBuilder(doc);
  2036. decimal totalPrice = 0.00M;
  2037. Table firstTable = (Table)doc.GetChild(NodeType.Table, 0, true);
  2038. if (firstTable != null)
  2039. {
  2040. // 遍历表格的行和单元格
  2041. foreach (Aspose.Words.Tables.Row row in firstTable.Rows)
  2042. {
  2043. for (int i = 0; i < row.Cells.Count; i++)
  2044. {
  2045. var cell = row.Cells[i];
  2046. // 读取单元格内容
  2047. string cellTextFirst = row.Cells[0].FirstParagraph.ToString(Aspose.Words.SaveFormat.Text).Trim();
  2048. if (cellTextFirst.Contains("舱位"))
  2049. {
  2050. break;
  2051. }
  2052. if (cellTextFirst == "经济舱" || cellTextFirst == "公务舱")
  2053. {
  2054. if (i == 2)
  2055. {
  2056. if (cellTextFirst == "经济舱")
  2057. {
  2058. // 设置单元格内容
  2059. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2060. cell.FirstParagraph.AppendChild(new Run(doc, subJJC.ToString())); // 添加
  2061. }
  2062. else
  2063. {
  2064. // 设置单元格内容
  2065. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2066. cell.FirstParagraph.AppendChild(new Run(doc, subGWC.ToString())); // 添加
  2067. }
  2068. }
  2069. if (i == 3)
  2070. {
  2071. var count = cabinCount.Find(x => x.Cabin == cellTextFirst)?.Count;
  2072. if (count != null)
  2073. {
  2074. // 设置单元格内容
  2075. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2076. cell.FirstParagraph.AppendChild(new Run(doc, count.ToString())); // 添加
  2077. }
  2078. }
  2079. if (i == 4)
  2080. {
  2081. var rowPrice = 0.00M;
  2082. var count = cabinCount.Find(x => x.Cabin == cellTextFirst)?.Count;
  2083. count ??= 0;
  2084. if (cellTextFirst == "经济舱")
  2085. {
  2086. rowPrice = subJJC * (int)count;
  2087. }
  2088. else
  2089. {
  2090. rowPrice = subGWC * (int)count;
  2091. }
  2092. totalPrice += rowPrice;
  2093. // 设置单元格内容
  2094. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2095. cell.FirstParagraph.AppendChild(new Run(doc, rowPrice.ToString())); // 添加
  2096. }
  2097. }
  2098. }
  2099. }
  2100. }
  2101. bookMarkDic.Add("TotalPrice", (totalPrice).ToString("#0.00"));
  2102. bookMarkDic.Add("TotalPrice1", (totalPrice * percentage).ToString("#0.00"));
  2103. bookMarkDic.Add("TotalPriceChinese", decimal.Parse((totalPrice * percentage).ToString("#0.00")).ConvertCNYUpper());
  2104. //--合同表格部分
  2105. bookMarkDic.Add("TimeNowDate", DateTime.Now.ToString("yyyy年MM月dd日"));
  2106. bookMarkDic.Add("ClientUnit1", di.ClientUnit);
  2107. bookMarkDic.Add("VisitCountry1", di.VisitCountry);
  2108. bookMarkDic.Add("DayCount", di.VisitDays.ToString());
  2109. bookMarkDic.Add("VisitingArea", di.VisitDate.ToString("yyyy年MM月dd日") + "-" + di.VisitEndDate.ToString("yyyy年MM月dd日"));
  2110. bookMarkDic.Add("CityPath1", cityPath);
  2111. bookMarkDic.Add("CityPath2", cityPath);
  2112. Table contractTable = (Table)doc.GetChild(NodeType.Table, 1, true);
  2113. if (contractTable != null)
  2114. {
  2115. //数据源
  2116. var _DayAndCostsAndCity = _sqlSugar.Queryable<Grp_DayAndCost>()
  2117. .LeftJoin<Grp_NationalTravelFee>((it, y) => it.NationalTravelFeeId == y.Id && y.IsDel == 0)
  2118. .LeftJoin<Sys_SetData>((it, y, s) => s.IsDel == 0 && s.Id == it.Currency)
  2119. .Where((it, y, s) => it.IsDel == 0 && it.DiId == di.Id)
  2120. .Select((it, y, s) => new
  2121. {
  2122. it.Cost,
  2123. it.SubTotal,
  2124. it.Type,
  2125. y.Id,
  2126. y.City,
  2127. s.Name,
  2128. CurrencyCodeCn = s.Remark
  2129. })
  2130. .ToList()
  2131. .Select(x => new
  2132. {
  2133. CurrencyCode = x.Name,
  2134. CityId = x.Id,
  2135. x.City,
  2136. di.VisitPNumber,
  2137. x.Type,
  2138. x.Cost,
  2139. x.SubTotal,
  2140. rateList.Find(y => y.CurrencyCode == x.Name)?.Rate,
  2141. x.CurrencyCodeCn,
  2142. });
  2143. var dac1 = _DayAndCostsAndCity.Where(it => it.Type == 1).GroupBy(x => x.CityId).ToList(); //住宿费
  2144. var dac2 = _DayAndCostsAndCity.Where(it => it.Type == 2).GroupBy(x => x.CityId).ToList(); //伙食费
  2145. var dac3 = _DayAndCostsAndCity.Where(it => it.Type == 3).GroupBy(x => x.CityId).ToList(); //公杂费
  2146. var dac4 = _DayAndCostsAndCity.Where(it => it.Type == 4).GroupBy(x => x.CityId).ToList(); //培训费
  2147. var tableSettings = new List<tableSetting>()
  2148. {
  2149. new(){ Index = 1 , Property = "City"},
  2150. new(){ Index = 2 , Property = "CurrencyCodeCn"},
  2151. new(){ Index = 3 , Property = "Cost"},
  2152. new(){ Index = 4 , Property = "VisitPNumber"},
  2153. //new tableSetting{ Index = 5 , Property = ""},
  2154. //new tableSetting{ Index = 6 , Property = ""},
  2155. new(){ Index = 7 , Property = "Rate"},
  2156. //new tableSetting{ Index = 8 , Property = ""},
  2157. };
  2158. //1.住宿费
  2159. int cloneRow = 8;
  2160. int startDayPrice = 8; //写入index
  2161. decimal ZSPriceSum = 0.00M, HSPriceSum = 0.00M, GZPriceSum = 0.00M;
  2162. foreach (var dac in dac1)
  2163. {
  2164. var first = dac.First();
  2165. var dayCount = dac.Count();
  2166. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2167. for (int i = 1; i < row.Cells.Count; i++)
  2168. {
  2169. var cell = row.Cells[i];
  2170. var findProperty = tableSettings.Find(x => x.Index == i);
  2171. if (findProperty != null)
  2172. {
  2173. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2174. // 设置单元格内容
  2175. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2176. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2177. }
  2178. else
  2179. {
  2180. switch (i)
  2181. {
  2182. case 5:
  2183. cell.FirstParagraph.Runs.Clear();
  2184. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2185. break;
  2186. case 6:
  2187. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2188. cell.FirstParagraph.Runs.Clear();
  2189. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2190. break;
  2191. case 8:
  2192. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2193. cell.FirstParagraph.Runs.Clear();
  2194. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2195. ZSPriceSum += xiaojiRMB;
  2196. break;
  2197. default:
  2198. break;
  2199. }
  2200. }
  2201. }
  2202. startDayPrice++;
  2203. if (!dac1.Last().Equals(dac))
  2204. {
  2205. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2206. // 将克隆的行追加到原行后面
  2207. contractTable.Rows.Insert(startDayPrice, newRow);
  2208. }
  2209. else
  2210. {
  2211. cloneRow += dac1.Count + 1;
  2212. startDayPrice = cloneRow;
  2213. }
  2214. }
  2215. //2.伙食费
  2216. foreach (var dac in dac2)
  2217. {
  2218. var first = dac.First();
  2219. var dayCount = dac.Count();
  2220. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2221. for (int i = 1; i < row.Cells.Count; i++)
  2222. {
  2223. var cell = row.Cells[i];
  2224. var findProperty = tableSettings.Find(x => x.Index == i);
  2225. if (findProperty != null)
  2226. {
  2227. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2228. // 设置单元格内容
  2229. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2230. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2231. }
  2232. else
  2233. {
  2234. switch (i)
  2235. {
  2236. case 5:
  2237. cell.FirstParagraph.Runs.Clear();
  2238. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2239. break;
  2240. case 6:
  2241. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2242. cell.FirstParagraph.Runs.Clear();
  2243. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2244. break;
  2245. case 8:
  2246. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2247. cell.FirstParagraph.Runs.Clear();
  2248. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2249. HSPriceSum += xiaojiRMB;
  2250. break;
  2251. default:
  2252. break;
  2253. }
  2254. }
  2255. }
  2256. startDayPrice++;
  2257. if (!dac2.Last().Equals(dac))
  2258. {
  2259. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2260. // 将克隆的行追加到原行后面
  2261. contractTable.Rows.Insert(startDayPrice, newRow);
  2262. }
  2263. else
  2264. {
  2265. cloneRow += dac2.Count + 1;
  2266. startDayPrice = cloneRow;
  2267. }
  2268. }
  2269. //3.公杂费
  2270. foreach (var dac in dac3)
  2271. {
  2272. var first = dac.First();
  2273. var dayCount = dac.Count();
  2274. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2275. for (int i = 1; i < row.Cells.Count; i++)
  2276. {
  2277. var cell = row.Cells[i];
  2278. var findProperty = tableSettings.Find(x => x.Index == i);
  2279. if (findProperty != null)
  2280. {
  2281. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2282. // 设置单元格内容
  2283. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2284. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2285. }
  2286. else
  2287. {
  2288. switch (i)
  2289. {
  2290. case 5:
  2291. cell.FirstParagraph.Runs.Clear();
  2292. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2293. break;
  2294. case 6:
  2295. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2296. cell.FirstParagraph.Runs.Clear();
  2297. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2298. break;
  2299. case 8:
  2300. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2301. cell.FirstParagraph.Runs.Clear();
  2302. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2303. GZPriceSum += xiaojiRMB;
  2304. break;
  2305. default:
  2306. break;
  2307. }
  2308. }
  2309. }
  2310. startDayPrice++;
  2311. if (!dac3.Last().Equals(dac))
  2312. {
  2313. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2314. // 将克隆的行追加到原行后面
  2315. contractTable.Rows.Insert(startDayPrice, newRow);
  2316. }
  2317. else
  2318. {
  2319. cloneRow += dac3.Count + 1;
  2320. startDayPrice = cloneRow;
  2321. }
  2322. }
  2323. //合并单元格
  2324. for (int i = 8; i < contractTable.Rows.Count - 1; i++)
  2325. {
  2326. var currentRow = contractTable.Rows[i];
  2327. var nextRow = contractTable.Rows[i + 1];
  2328. // 获取当前行和下一行的第一个单元格
  2329. Cell currentCell = currentRow.Cells[0];
  2330. Cell nextCell = nextRow.Cells[0];
  2331. // 检查单元格内容是否一致(去除尾部的换行符)
  2332. string currentText = currentCell.GetText().Trim();
  2333. string nextText = nextCell.GetText().Trim();
  2334. if (currentText == nextText)
  2335. {
  2336. // 如果当前单元格已经被合并,找到合并的起始单元格
  2337. if (currentCell.CellFormat.VerticalMerge == CellMerge.Previous)
  2338. {
  2339. // 找到合并的起始单元格
  2340. int mergeStartIndex = FindMergeStartRowIndex(contractTable, i);
  2341. // 将下一行的单元格设置为合并的后续单元格
  2342. nextCell.CellFormat.VerticalMerge = CellMerge.Previous;
  2343. }
  2344. else
  2345. {
  2346. // 如果当前单元格是合并的起始单元格
  2347. currentCell.CellFormat.VerticalMerge = CellMerge.First;
  2348. // 将下一行的单元格设置为合并的后续单元格
  2349. nextCell.CellFormat.VerticalMerge = CellMerge.Previous;
  2350. }
  2351. }
  2352. else
  2353. {
  2354. // 如果内容不一致,重置当前单元格的合并属性
  2355. if (currentCell.CellFormat.VerticalMerge == CellMerge.Previous)
  2356. {
  2357. // 如果当前单元格是合并的后续单元格,找到合并的起始单元格并重置
  2358. int mergeStartIndex = FindMergeStartRowIndex(contractTable, i);
  2359. contractTable.Rows[mergeStartIndex].Cells[0].CellFormat.VerticalMerge = CellMerge.First;
  2360. }
  2361. else
  2362. {
  2363. currentCell.CellFormat.VerticalMerge = CellMerge.None;
  2364. }
  2365. }
  2366. }
  2367. bookMarkDic.Add("ZSPriceSum", ZSPriceSum.ToString("F2"));
  2368. bookMarkDic.Add("HSPriceSum", HSPriceSum.ToString("F2"));
  2369. bookMarkDic.Add("GZPriceSum", GZPriceSum.ToString("F2"));
  2370. }
  2371. foreach (var bookmarkName in bookMarkDic.Keys)
  2372. {
  2373. Bookmark bookmark = doc.Range.Bookmarks[bookmarkName];
  2374. if (bookmark != null)
  2375. {
  2376. if (bookmarkName == "ClientUnit")
  2377. {
  2378. // 移动到书签位置
  2379. builder.MoveTo(bookmark.BookmarkStart);
  2380. // 设置字体样式为下划线
  2381. builder.Font.Underline = Aspose.Words.Underline.Single;
  2382. // 插入书签值
  2383. builder.Write(bookMarkDic[bookmarkName]);
  2384. // 清除字体格式,避免影响后续文本
  2385. builder.Font.ClearFormatting();
  2386. }
  2387. else
  2388. {
  2389. builder.MoveToBookmark(bookmarkName);
  2390. builder.Write(bookMarkDic[bookmarkName]);
  2391. }
  2392. }
  2393. }
  2394. string savePaht = $"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Export/{di.TeamName}_{fileNameadd}版本合同文件.doc";
  2395. doc.Save(savePaht);
  2396. jw.Msg = "生成成功!";
  2397. jw.Code = 200;
  2398. jw.Data = new { Url = AppSettingsHelper.Get("WordBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("WordBasePath"), AppSettingsHelper.Get("WordFtpPath")) };
  2399. return Ok(jw);
  2400. }
  2401. static int FindMergeStartRowIndex(Table table, int rowIndex)
  2402. {
  2403. int index = rowIndex;
  2404. while (index > 0 && table.Rows[index].Cells[0].CellFormat.VerticalMerge == CellMerge.Previous)
  2405. {
  2406. index--;
  2407. }
  2408. return index;
  2409. }
  2410. #endregion
  2411. #region 团组&签证
  2412. #region 团组&签证 New
  2413. /// <summary>
  2414. /// 团组&签证 New
  2415. /// 上传签证文件(客户填写签证文件),新增或更新 签证信息
  2416. /// </summary>
  2417. /// <param name="file">请求dto</param>
  2418. /// <returns></returns>
  2419. [HttpPost]
  2420. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2421. public async Task<IActionResult> VisaFileUploadAndUpdate(IFormFile file, int fileTypeId)
  2422. {
  2423. //文件验证
  2424. if (file.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  2425. //var visaFiles = new VisaUploadFileTypeView();
  2426. var filetypes = VisaUploadFileTypeView.GetVisaUploadFileTypeViewItemInit();
  2427. if (!filetypes.Any(x => x.FileId == fileTypeId)) return Ok(JsonView(false, "请选择文件类型!"));
  2428. //服务器存储文件
  2429. var fileServerPath = $"D:/FTP/File/OA2023/Office/Word/VisaClientData/Uploads";
  2430. if (!Directory.Exists(fileServerPath)) Directory.CreateDirectory(fileServerPath);
  2431. var filePath = Path.Combine(fileServerPath, file.FileName);
  2432. using (var stream = new FileStream(filePath, FileMode.Create))
  2433. {
  2434. await file.CopyToAsync(stream);
  2435. }
  2436. //日志记录-上传文件
  2437. _logger.LogInformation("【签证上传文件操作信息】签证文件存储成功!路径:{fileServerPath} 文件名称:{fileName}", fileServerPath, file.FileName);
  2438. //kimi AI 识别文档返回json结果
  2439. int kimiAI_API_Index = 0; //KIMI-AI-API 访问计次
  2440. var KiMiApi = new KiMiApiClient();
  2441. var files = new List<IFormFile>() { file };
  2442. var seedConter = await KiMiApi.UploadFilesAsync(files);
  2443. if (seedConter.Count == 0) return Ok(JsonView(false, "Kimi AI 文件上传结果为空!"));
  2444. var seedMessage = filetypes.Where(x => x.FileId == fileTypeId).FirstOrDefault()?.KimiAITips;
  2445. var messages = new List<SeedMessages>
  2446. {
  2447. new() { Role = KimiRole.system, Content = "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长识别文件为Json格式的对话。你会为用户提供安全,有帮助,准确的回答。同时,你会拒绝一切涉及恐怖主义,种族歧视,黄色暴力等问题的回答。Moonshot AI 为专有名词,不可翻译成其他语言。" },
  2448. new() { Role = KimiRole.user, Content = seedMessage }
  2449. };
  2450. messages.InsertRange(1, seedConter);
  2451. string jsonString = string.Empty;
  2452. bool isJson = false; // 是否是json格式 不是json格式继续访问AI
  2453. while (!isJson)
  2454. {
  2455. kimiAI_API_Index++;
  2456. var kimiApiResult = await KiMiApi.SeedMessage(messages);
  2457. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  2458. jsonString += kimiApiResult_JObject["content"].ToString();
  2459. string startStr = "```json", endStr = "```";
  2460. // 判断并清除开头部分
  2461. if (jsonString.StartsWith(startStr))
  2462. {
  2463. jsonString = jsonString.Replace(startStr, "");
  2464. }
  2465. // 判断并清除结尾部分
  2466. if (jsonString.EndsWith(endStr))
  2467. {
  2468. jsonString = jsonString.Replace(endStr, "");
  2469. }
  2470. //验证json格式是否正确
  2471. try
  2472. {
  2473. JsonDocument.Parse(jsonString);
  2474. isJson = true; // 如果解析成功,则是json格式
  2475. }
  2476. catch (Exception)
  2477. {
  2478. //messages = new List<SeedMessages>() { new() { Role = KimiRole.user, Content = "接着说" } };
  2479. messages.Add(new() { Role = KimiRole.user, Content = "接着上一个话题继续完成未完成的内容。" });
  2480. }
  2481. }
  2482. var clientInfo = new Crm_DeleClient(); //客户资料表
  2483. var clientFamily = new Crm_VisaCustomerFamily(); //客户家庭表
  2484. var clientCompany = new Crm_CustomerCompany(); //客户公司表
  2485. var clientCert = new Crm_CustomerCert(); //客户证件表
  2486. var clientSchool = new Crm_VisaCustomerSchool(); //客户学历表
  2487. //按照表格类型分别进行参数处理
  2488. switch (fileTypeId)
  2489. {
  2490. //澳新签证个人申请表
  2491. case 1:
  2492. _logger.LogInformation("【签证上传文件操作信息】【澳新签证个人申请表】【KIMI-AI-API访问计次】{count} 次", kimiAI_API_Index);
  2493. VisaApplication resInfo = System.Text.Json.JsonSerializer.Deserialize<VisaApplication>(jsonString);
  2494. break;
  2495. default:
  2496. break;
  2497. }
  2498. return Ok(JsonView(true, jsonString));
  2499. }
  2500. #endregion
  2501. /// <summary>
  2502. /// 根据团组Id获取签证客户信息List
  2503. /// </summary>
  2504. /// <param name="dto">请求dto</param>
  2505. /// <returns></returns>
  2506. [HttpPost]
  2507. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2508. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  2509. {
  2510. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  2511. if (groupData.Code != 0)
  2512. {
  2513. return Ok(JsonView(false, groupData.Msg));
  2514. }
  2515. return Ok(JsonView(groupData.Data));
  2516. }
  2517. /// <summary>
  2518. /// IOS获取团组签证拍照上传进度01(团组列表)
  2519. /// </summary>
  2520. /// <param name="dto">请求dto</param>
  2521. /// <returns></returns>
  2522. [HttpPost]
  2523. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2524. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  2525. {
  2526. if (dto == null)
  2527. {
  2528. return Ok(JsonView(false, "参数为空"));
  2529. }
  2530. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  2531. return Ok(JsonView(visaList));
  2532. }
  2533. /// <summary>
  2534. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  2535. /// </summary>
  2536. /// <returns></returns>
  2537. [HttpPost]
  2538. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2539. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  2540. {
  2541. if (dto == null)
  2542. {
  2543. return Ok(JsonView(false, "请求错误:"));
  2544. }
  2545. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  2546. return Ok(JsonView(list));
  2547. }
  2548. /// <summary>
  2549. /// IOS获取团组签证拍照上传进度03(相册)
  2550. /// </summary>
  2551. /// <returns></returns>
  2552. [HttpPost]
  2553. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2554. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  2555. {
  2556. if (dto == null)
  2557. {
  2558. return Ok(JsonView(false, "请求错误:"));
  2559. }
  2560. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  2561. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  2562. list.ForEach(s => s.url = url);
  2563. return Ok(JsonView(list));
  2564. }
  2565. /// <summary>
  2566. /// IOS获取团组签证拍照上传进度04(图片上传)
  2567. /// </summary>
  2568. /// <param name="dto"></param>
  2569. /// <returns></returns>
  2570. [HttpPost]
  2571. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2572. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  2573. {
  2574. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  2575. //if (!string.IsNullOrEmpty(result))
  2576. //{
  2577. //}
  2578. //else {
  2579. // return Ok(JsonView(false, "上传失败"));
  2580. //}
  2581. var dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  2582. int sucNum = 0;
  2583. try
  2584. {
  2585. foreach (var item in dto.base64DataList)
  2586. {
  2587. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  2588. string result = DecodeBase64ToImage(item, imageName);
  2589. if (!string.IsNullOrEmpty(result))
  2590. {
  2591. var pic = new Grp_VisaProgressCustomerPicture
  2592. {
  2593. CreateUserId = dto.CreateUserId,
  2594. PicName = imageName,
  2595. PicPath = result,
  2596. VisaProgressCustomerId = dto.visaProgressCustomerId
  2597. };
  2598. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  2599. if (insertResult > 0)
  2600. {
  2601. sucNum++;
  2602. }
  2603. }
  2604. }
  2605. }
  2606. catch (Exception ex)
  2607. {
  2608. return Ok(JsonView(false, ex.Message));
  2609. }
  2610. string msg = string.Format(@"成功上传{0}张", sucNum);
  2611. return Ok(JsonView(true, msg));
  2612. }
  2613. private string DecodeBase64ToImage(string base64DataURL, string imgName)
  2614. {
  2615. string filename = "";//声明一个string类型的相对路径
  2616. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  2617. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  2618. try//会有异常抛出,try,catch一下
  2619. {
  2620. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  2621. var ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  2622. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  2623. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  2624. //文件名称
  2625. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  2626. //上传的文件的路径
  2627. string filePath = "";
  2628. if (!Directory.Exists(fileDir))
  2629. {
  2630. Directory.CreateDirectory(fileDir);
  2631. }
  2632. //上传的文件的路径
  2633. filePath = fileDir + filename;
  2634. //string url = HttpRuntime.AppDomainAppPath.ToString();
  2635. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  2636. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  2637. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  2638. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  2639. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  2640. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  2641. ms.Close();//关闭当前流,并释放所有与之关联的资源
  2642. bitmap.Dispose();
  2643. }
  2644. catch (Exception e)
  2645. {
  2646. string massage = e.Message;
  2647. Logs("IOS图片上传Error:" + massage);
  2648. //filename = e.Message;
  2649. }
  2650. return filename;//返回相对路径
  2651. }
  2652. /// <summary>
  2653. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  2654. /// </summary>
  2655. /// <param name="dto"></param>
  2656. /// <returns></returns>
  2657. [HttpPost]
  2658. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2659. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  2660. {
  2661. if (dto == null)
  2662. {
  2663. return Ok(JsonView(false, "请求错误:"));
  2664. }
  2665. string msg = "参数错误";
  2666. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  2667. {
  2668. try
  2669. {
  2670. //_delegationVisaRep.BeginTran();
  2671. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  2672. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  2673. .Where(s => s.Id == dto.visaProgressCustomerId)
  2674. .ExecuteCommandAsync();
  2675. if (updCount > 0 && dto.publishCode == 1)
  2676. {
  2677. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  2678. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  2679. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  2680. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  2681. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  2682. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  2683. if (groupData == null)
  2684. {
  2685. _delegationVisaRep.RollbackTran();
  2686. }
  2687. string title = string.Format(@"[签证进度更新]");
  2688. string content = string.Format(@"测试文本");
  2689. bool rst = await _message.AddMsg(new MessageDto()
  2690. {
  2691. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  2692. IssuerId = dto.publisher,
  2693. Title = title,
  2694. Content = content,
  2695. ReleaseTime = DateTime.Now,
  2696. UIdList = new List<int> {
  2697. 234
  2698. }
  2699. });
  2700. if (rst)
  2701. {
  2702. return Ok(JsonView(true, "发送通知成功"));
  2703. }
  2704. }
  2705. //_delegationVisaRep.CommitTran();
  2706. }
  2707. catch (Exception)
  2708. {
  2709. //_delegationVisaRep.RollbackTran();
  2710. }
  2711. }
  2712. return Ok(JsonView(true, msg));
  2713. }
  2714. #endregion
  2715. #region 团组任务分配
  2716. /// <summary>
  2717. /// 团组任务分配初始化
  2718. /// </summary>
  2719. /// <returns></returns>
  2720. [HttpPost]
  2721. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2722. public async Task<IActionResult> GetTaskAssignmen()
  2723. {
  2724. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  2725. if (groupData.Code != 0)
  2726. {
  2727. return Ok(JsonView(false, groupData.Msg));
  2728. }
  2729. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2730. }
  2731. /// <summary>
  2732. /// 团组任务分配查询
  2733. /// </summary>
  2734. /// <param name="dto"></param>
  2735. /// <returns></returns>
  2736. [HttpPost]
  2737. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2738. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  2739. {
  2740. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  2741. if (groupData.Code != 0)
  2742. {
  2743. return Ok(JsonView(false, groupData.Msg));
  2744. }
  2745. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2746. }
  2747. /// <summary>
  2748. /// 团组任务分配操作
  2749. /// </summary>
  2750. /// <param name="dto"></param>
  2751. /// <returns></returns>
  2752. [HttpPost]
  2753. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2754. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  2755. {
  2756. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  2757. if (groupData.Code != 0)
  2758. {
  2759. return Ok(JsonView(false, groupData.Msg));
  2760. }
  2761. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2762. }
  2763. /// <summary>
  2764. /// 团组任务分配
  2765. /// 批量分配
  2766. /// 查询团组
  2767. /// </summary>
  2768. /// <param name="dto"></param>
  2769. /// <returns></returns>
  2770. [HttpPost]
  2771. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2772. public async Task<IActionResult> TaskAllocationGroupSelect(TaskAllocationGroupSelectDto dto)
  2773. {
  2774. //参数验证
  2775. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  2776. if (!DateTime.TryParse(dto.VisitBeginDt, out _) || !DateTime.TryParse(dto.VisitEndDt, out _))
  2777. return Ok(JsonView(false, "团组出访开始/结束日期格式不正确!"));
  2778. return Ok(await _taskAssignmentRep.TaskAllocationGroupSelect(dto));
  2779. }
  2780. /// <summary>
  2781. /// 团组任务分配
  2782. /// 批量分配
  2783. /// </summary>
  2784. /// <param name="dto"></param>
  2785. /// <returns></returns>
  2786. [HttpPost]
  2787. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2788. public async Task<IActionResult> TaskAllocationBulkAdd(TaskAllocationBulkAddDto dto)
  2789. {
  2790. //参数验证
  2791. if (dto.UserIds.Length < 1) return Ok(JsonView(false, $"请选择分配人员!"));
  2792. if (dto.PermissionTypeIds.Length < 1) return Ok(JsonView(false, $"请选择分配类型!"));
  2793. if (dto.GroupIds.Length < 1) return Ok(JsonView(false, "请选择分配团组Id"));
  2794. if (dto.CurrUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId数组参数"));
  2795. return Ok(await _taskAssignmentRep.TaskAllocationBulkAdd(dto));
  2796. }
  2797. #endregion
  2798. #region 团组费用审核
  2799. /// <summary>
  2800. /// 费用审核
  2801. /// 团组列表 Page
  2802. /// </summary>
  2803. /// <param name="_dto">团组列表请求dto</param>
  2804. /// <returns></returns>
  2805. [HttpPost]
  2806. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2807. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  2808. {
  2809. #region 参数验证
  2810. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2811. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2812. #region 页面操作权限验证
  2813. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2814. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  2815. #endregion
  2816. #endregion
  2817. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  2818. {
  2819. string sqlWhere = string.Empty;
  2820. if (_dto.IsSure == 0) //未完成
  2821. {
  2822. sqlWhere += string.Format(@" And IsSure = 0");
  2823. }
  2824. else if (_dto.IsSure == 1) //已完成
  2825. {
  2826. sqlWhere += string.Format(@" And IsSure = 1");
  2827. }
  2828. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  2829. {
  2830. string tj = _dto.SearchCriteria;
  2831. 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}%')",
  2832. tj, tj, tj, tj, tj);
  2833. }
  2834. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  2835. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  2836. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  2837. From (
  2838. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  2839. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  2840. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  2841. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  2842. From Grp_DelegationInfo gdi
  2843. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  2844. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  2845. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  2846. Where gdi.IsDel = 0 {0}
  2847. ) temp ", sqlWhere);
  2848. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  2849. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  2850. var _view = new
  2851. {
  2852. PageFuncAuth = pageFunAuthView,
  2853. Data = _DelegationList
  2854. };
  2855. return Ok(JsonView(true, "查询成功!", _view, total));
  2856. }
  2857. else
  2858. {
  2859. return Ok(JsonView(false, "查询失败"));
  2860. }
  2861. }
  2862. /// <summary>
  2863. /// 获取团组费用审核
  2864. /// </summary>
  2865. /// <param name="_dto"></param>
  2866. /// <returns></returns>
  2867. [HttpPost]
  2868. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2869. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  2870. {
  2871. try
  2872. {
  2873. #region 参数验证
  2874. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2875. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2876. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  2877. #region 页面操作权限验证
  2878. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2879. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  2880. #endregion
  2881. #endregion
  2882. var _view = new Grp_CreditCardPaymentView();
  2883. var clientNameList = GetSimplClientList(_dto.DiId);
  2884. #region 费用清单
  2885. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  2886. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  2887. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  2888. var entityList = _groupRepository.Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0).Where(exp.ToExpression()).ToList();
  2889. var detailList = new List<Grp_CreditCardPaymentDetailView>();
  2890. var ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  2891. /*
  2892. * 76://酒店预订
  2893. */
  2894. var _HotelReservations = await _groupRepository.Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2895. var _HotelReservationsContents = await _groupRepository.Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2896. /*
  2897. * 79://车/导游地接
  2898. */
  2899. var _CarTouristGuideGroundReservations = await _groupRepository.Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2900. var _CarTouristGuideGroundReservationsContent = await _groupRepository.Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2901. /*
  2902. * 80: //签证
  2903. */
  2904. var _VisaInfos = await _groupRepository.Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2905. /*
  2906. *81: //邀请/公务活动
  2907. */
  2908. var _InvitationOfficialActivities = await _groupRepository.Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2909. /*
  2910. * 82: //团组客户保险
  2911. */
  2912. var _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2913. /*
  2914. * Lable = 85 机票预订
  2915. */
  2916. var p_AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2917. /*
  2918. * 85 机票预定
  2919. */
  2920. var _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2921. /*
  2922. * 98 其他款项
  2923. */
  2924. var _DecreasePayments = await _groupRepository.Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2925. /*
  2926. * 285:收款退还
  2927. */
  2928. var _PaymentRefundAndOtherMoneys = await _groupRepository.Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2929. /*
  2930. * 1015: //超支费用
  2931. */
  2932. var _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2933. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  2934. /*
  2935. * 币种信息
  2936. */
  2937. var currencyItems = initDatas.Where(s => s.STid == 66).ToList();
  2938. /*
  2939. * 车/导游地接 费用类型
  2940. */
  2941. var carFeeTypeItems = initDatas.Where(s => s.STid == 17).ToList();
  2942. /*
  2943. * 车/导游地接 费用类型
  2944. */
  2945. var carFeeItems = initDatas.Where(s => s.STid == 83).ToList();
  2946. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  2947. /*
  2948. * 用户信息
  2949. */
  2950. var userItems = await _groupRepository._sqlSugar.Queryable<Sys_Users>().ToListAsync();
  2951. /*
  2952. * 费用模块
  2953. */
  2954. var sdPriceName = initDatas.Where(s => s.Id == _dto.Label).First();
  2955. string priceModule = string.Empty;
  2956. if (sdPriceName != null)
  2957. {
  2958. priceModule = sdPriceName.Name;
  2959. }
  2960. /*
  2961. * 成本信息
  2962. */
  2963. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  2964. decimal _groupRate = 0.0000M;
  2965. string _groupCurrencyCode = "-";
  2966. if (groupCost != null)
  2967. {
  2968. _groupRate = groupCost.Rate;
  2969. if (int.TryParse(groupCost.Currency, out int _currency))
  2970. {
  2971. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  2972. }
  2973. else _groupCurrencyCode = groupCost.Currency;
  2974. }
  2975. string costContentSql = $"Select * From Grp_GroupCost";
  2976. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  2977. //处理日期为空的天数
  2978. for (int i = 0; i < groupCostDetails.Count; i++)
  2979. if (i != 0)
  2980. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  2981. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  2982. /*
  2983. * 处理详情数据
  2984. */
  2985. foreach (var entity in entityList)
  2986. {
  2987. var _detail = new Grp_CreditCardPaymentDetailView
  2988. {
  2989. Id = entity.Id,
  2990. PriceName = priceModule,
  2991. PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-"
  2992. };
  2993. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  2994. else _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  2995. //处理金额
  2996. if (entity.CTable == 1015)
  2997. {
  2998. var czInfo = _GroupExtraCosts.Find(x => entity.CId == x.Id);
  2999. if (czInfo != null)
  3000. {
  3001. entity.PayMoney = czInfo.Price * czInfo.PriceCount;
  3002. entity.RMBPrice = czInfo.Price * czInfo.PriceCount * entity.DayRate;
  3003. }
  3004. }
  3005. /*
  3006. * 应付款金额
  3007. */
  3008. var sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  3009. string PaymentCurrency_WaitPay = "Unknown";
  3010. string hotelCurrncyCode = "Unknown";
  3011. string hotelCurrncyName = "Unknown";
  3012. if (sdPaymentCurrency_WaitPay != null)
  3013. {
  3014. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  3015. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  3016. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  3017. if (hotelCurrncyCode.Equals("CNY"))
  3018. {
  3019. entity.DayRate = 1.0000M;
  3020. }
  3021. }
  3022. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  3023. /*
  3024. * 此次付款金额
  3025. */
  3026. decimal CurrPayStr = 0.00M,
  3027. OriginalCurrPay = 0.00M;
  3028. if (entity.PayPercentage == 0)
  3029. {
  3030. if (entity.PayThenMoney != 0)
  3031. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  3032. }
  3033. else
  3034. {
  3035. if (entity.PayMoney != 0)
  3036. {
  3037. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  3038. }
  3039. }
  3040. //if (_dto.Label == 79)
  3041. //{
  3042. // string original = string.Empty;
  3043. // if (hotelCurrncyCode.Equals("CNY"))
  3044. // {
  3045. // OriginalCurrPay = CurrPayStr;
  3046. // _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  3047. // }
  3048. // else
  3049. // {
  3050. // OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  3051. // //760 EUR(7600.00 CNY)
  3052. // _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  3053. // }
  3054. //}
  3055. //else _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  3056. string original = string.Empty;
  3057. if (hotelCurrncyCode.Equals("CNY"))
  3058. {
  3059. OriginalCurrPay = CurrPayStr;
  3060. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  3061. }
  3062. else
  3063. {
  3064. OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  3065. //760 EUR(7600.00 CNY)
  3066. _detail.CurrPay = $"{OriginalCurrPay:#0.00} {hotelCurrncyCode}({CurrPayStr:#0.00} CNY)";
  3067. }
  3068. /*
  3069. * 剩余尾款
  3070. */
  3071. decimal BalanceStr = 0;
  3072. if (CurrPayStr != 0)
  3073. {
  3074. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  3075. BalanceStr = 0;
  3076. else
  3077. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  3078. }
  3079. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  3080. /*
  3081. * Bus名称
  3082. */
  3083. _detail.BusName = "待增加";
  3084. /*
  3085. *费用所属
  3086. */
  3087. switch (entity.CTable)
  3088. {
  3089. case 76://酒店预订
  3090. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  3091. if (hotelReservations != null)
  3092. {
  3093. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  3094. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  3095. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  3096. string roomFeeStr = "", roomFeestr1 = "";
  3097. //是否比较房型价格
  3098. //bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  3099. //roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  3100. roomFeeStr += $"<br/>";
  3101. var roomTotal = 0.00M;
  3102. if (hotelReservations.SingleRoomPrice > 0)
  3103. {
  3104. var fee = hotelReservations.SingleRoomPrice * hotelReservations.SingleRoomCount * hotel_days;
  3105. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice:#0.00} * {hotelReservations.SingleRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  3106. //__isSingle = true;
  3107. roomTotal += fee;
  3108. }
  3109. if (hotelReservations.DoubleRoomPrice > 0)
  3110. {
  3111. var fee = hotelReservations.DoubleRoomPrice * hotelReservations.DoubleRoomCount * hotel_days;
  3112. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice:#0.00} * {hotelReservations.DoubleRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  3113. // __isDouble = true;
  3114. roomTotal += fee;
  3115. }
  3116. if (hotelReservations.SuiteRoomPrice > 0)
  3117. {
  3118. var fee = hotelReservations.SuiteRoomPrice * hotelReservations.SuiteRoomCount * hotel_days;
  3119. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice:#0.00} * {hotelReservations.SuiteRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  3120. //__isSuite = true;
  3121. roomTotal += fee;
  3122. }
  3123. if (hotelReservations.OtherRoomPrice > 0)
  3124. {
  3125. var fee = hotelReservations.OtherRoomPrice * hotelReservations.OtherRoomCount * hotel_days;
  3126. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice:#0.00} * {hotelReservations.OtherRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  3127. //__isOther = true;
  3128. roomTotal += fee;
  3129. }
  3130. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1 + $"<span style='width:70px;display: inline-block;'></span>房费总金额:{roomTotal:#0.00}";
  3131. else roomFeeStr += " 0.00 * 0";
  3132. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  3133. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  3134. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  3135. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  3136. /*
  3137. * 费用类型
  3138. * 1:房费
  3139. * 2:早餐
  3140. * 3:地税
  3141. * 4:城市税
  3142. * </summary>
  3143. */
  3144. //地税
  3145. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  3146. if (governmentRentData != null)
  3147. {
  3148. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  3149. governmentRentFee = governmentRentData.Price;
  3150. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  3151. if (governmentRentCurrData != null)
  3152. {
  3153. governmentRentCode = governmentRentCurrData.Name;
  3154. governmentRentName = $"({governmentRentCurrData.Remark})";
  3155. }
  3156. }
  3157. //城市税
  3158. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  3159. if (cityTaxData != null)
  3160. {
  3161. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  3162. cityTaxFee = cityTaxData.Price;
  3163. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  3164. if (cityTaxCurrData != null)
  3165. {
  3166. cityTaxCode = cityTaxCurrData.Name;
  3167. cityTaxName = $"({cityTaxCurrData.Remark})";
  3168. }
  3169. }
  3170. //酒店早餐
  3171. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  3172. if (breakfastData != null)
  3173. {
  3174. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  3175. breakfastFee = breakfastData.Price;
  3176. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  3177. if (breakfastCurrData != null)
  3178. {
  3179. breakfastCode = breakfastCurrData.Name;
  3180. breakfastName = $"({breakfastCurrData.Remark})";
  3181. }
  3182. }
  3183. //房间费用
  3184. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  3185. if (roomData != null)
  3186. {
  3187. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  3188. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  3189. else _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  3190. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  3191. roomFee = roomData.Price;
  3192. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  3193. if (roomCurrData != null)
  3194. {
  3195. roomCode = roomCurrData.Name;
  3196. roomName = $"({roomCurrData.Remark})";
  3197. }
  3198. }
  3199. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  3200. string hotelCostStr = "";
  3201. decimal hotelCsotTotal = 0.00M;
  3202. if (groupCost != null)
  3203. {
  3204. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  3205. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate:#0.0000})<br/>";
  3206. }
  3207. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  3208. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  3209. string hotelCost_day = "";
  3210. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  3211. foreach (var item in hotelCostDetails1)
  3212. {
  3213. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  3214. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  3215. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee):#0.00}";
  3216. //else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  3217. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee):#0.00}";
  3218. //else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  3219. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee):#0.00}";
  3220. //else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  3221. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee):#0.00}";
  3222. //else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  3223. hotelCost_day += @$"<br/>";
  3224. }
  3225. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  3226. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee:#0.00} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate:#0.0000} <br/>是否由地接或其他人代付:{breakfastBool}<br/><br/>";
  3227. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee:#0.00} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate:#0.0000} <br/>是否由地接或其他人代付:{governmentRentBool}<br/><br/>";
  3228. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee:#0.00} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate:#0.0000)} <br/>是否由地接或其他人代付:{cityTaxBool}<br/>";
  3229. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  3230. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  3231. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  3232. $"酒店费用总额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  3233. $"房间说明: {hotelReservations.Remark} <br/>" +
  3234. $"房间费用: {roomCode} {roomName} 当时汇率:{roomData?.Rate.ToString("#0.0000")}{roomFeeStr} <br/>是否由地接或其他人代付:{roomBool}<br/><br/>" +
  3235. $"{hotelBreakfastStr}" +
  3236. $"{hotelGovernmentRentStr}" +
  3237. $"{hotelCityTaxStr}";
  3238. _detail.PriceNameContent = hotelReservations.HotelName;
  3239. }
  3240. break;
  3241. case 79://车/导游地接
  3242. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  3243. if (touristGuideGroundReservations != null)
  3244. {
  3245. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  3246. {
  3247. _detail.BusName = touristGuideGroundReservations.BusName;
  3248. }
  3249. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  3250. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  3251. //if (isInt)
  3252. //{
  3253. // var cityInfo = cityData.Find(it => it.Id == cityId);
  3254. // if (cityInfo != null)
  3255. // {
  3256. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  3257. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  3258. // if (carFeeItem != null)
  3259. // {
  3260. // nameContent += $@"({carFeeItem.Name})";
  3261. // }
  3262. // _detail.PriceNameContent = nameContent;
  3263. // }
  3264. //}
  3265. //else
  3266. //{
  3267. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  3268. //}
  3269. var touristGuideGroundReservationsContents =
  3270. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  3271. var opContent_sb = new StringBuilder();
  3272. string contetTitle = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  3273. opContent_sb.AppendLine(contetTitle);
  3274. foreach (var item in touristGuideGroundReservationsContents)
  3275. {
  3276. string typeName = "Unknown";
  3277. string carCurrencyCode = "Unknown";
  3278. string carCurrencyName = "Unknown";
  3279. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  3280. if (carTypeData != null) typeName = carTypeData.Name;
  3281. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  3282. if (currencyData != null)
  3283. {
  3284. carCurrencyCode = currencyData.Name;
  3285. carCurrencyName = currencyData.Remark;
  3286. }
  3287. //op、成本 币种是否一致 (币种一致只比较金额:2025-04-18)
  3288. bool IsCurrencyAgreement = false;
  3289. if (carCurrencyCode.Equals(_groupCurrencyCode)) IsCurrencyAgreement = true;
  3290. string opCostStr = string.Empty;
  3291. decimal opCostTypePrice = 0.00M;
  3292. #region 处理成本各项费用
  3293. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  3294. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  3295. decimal aduitOPFeeCNY = 0.00M, //费用审核 op费用
  3296. costOPFeeCNY = 0.00M, //团组成本 op费用
  3297. opPayPercentage = entity.PayPercentage == 0.00M ? 1.00M : entity.PayPercentage / 100M; //费用审核 op付款百分比
  3298. if (opCost.Count > 0)
  3299. {
  3300. switch (item.SId)
  3301. {
  3302. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  3303. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  3304. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  3305. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  3306. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  3307. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  3308. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  3309. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  3310. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  3311. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  3312. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  3313. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  3314. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  3315. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  3316. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  3317. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  3318. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  3319. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  3320. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  3321. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  3322. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  3323. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  3324. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  3325. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  3326. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  3327. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  3328. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  3329. }
  3330. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice:#0.00} {_groupCurrencyCode}(汇率:{_groupRate:#0.0000})";
  3331. costOPFeeCNY = opCostTypePrice * _groupRate;
  3332. if (!IsCurrencyAgreement) opCostStr += $" ≈ {costOPFeeCNY:#0.00} CNY";
  3333. }
  3334. #endregion
  3335. string opTypeStr = $"{typeName}:{item.Price:#0.00} {carCurrencyCode}(汇率:{entity.DayRate:#0.0000})";
  3336. aduitOPFeeCNY = item.Price * entity.DayRate;
  3337. if (!IsCurrencyAgreement) opTypeStr += $" ≈ {aduitOPFeeCNY:#0.0000} CNY";
  3338. var opContent = $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  3339. $"{opTypeStr} {opCostStr}<br/>" +
  3340. $"明细:{item.PriceContent ?? "-"}<br/>" +
  3341. $"备注:{item.Remark ?? "-"}<br/><br/>";
  3342. if (entity.IsAuditGM != 3) //状态 != 自动审核
  3343. {
  3344. if (IsCurrencyAgreement)
  3345. {
  3346. if (item.Price > opCostTypePrice)
  3347. {
  3348. opContent_sb.Append("<span style='color:red;'>");
  3349. opContent_sb.Append(opContent);
  3350. opContent_sb.Append("</span>");
  3351. opContent_sb.AppendLine();
  3352. }
  3353. else
  3354. {
  3355. opContent_sb.Append(opContent);
  3356. opContent_sb.AppendLine();
  3357. }
  3358. }
  3359. else
  3360. {
  3361. //验证是否超成本 按付款比例计算
  3362. if (aduitOPFeeCNY * opPayPercentage > costOPFeeCNY * opPayPercentage)
  3363. {
  3364. opContent_sb.Append("<span style='color:red;'>");
  3365. opContent_sb.Append(opContent);
  3366. opContent_sb.Append("</span>");
  3367. opContent_sb.AppendLine();
  3368. }
  3369. else
  3370. {
  3371. opContent_sb.Append(opContent);
  3372. opContent_sb.AppendLine();
  3373. }
  3374. }
  3375. }
  3376. else
  3377. {
  3378. opContent_sb.Append(opContent);
  3379. opContent_sb.AppendLine();
  3380. }
  3381. }
  3382. _detail.PriceMsgContent = opContent_sb.ToString();
  3383. }
  3384. break;
  3385. case 80: //签证
  3386. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  3387. if (visaInfo != null)
  3388. {
  3389. string visaName = GetClientNameStr1(clientNameList, visaInfo.VisaClient);
  3390. _detail.PriceNameContent = visaInfo.VisaDescription;
  3391. _detail.PriceMsgContent = $"签证描述:{visaName}<br/> 备注:{visaInfo.Remark}";
  3392. }
  3393. break;
  3394. case 81: //邀请/公务活动
  3395. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  3396. if (_ioa != null)
  3397. {
  3398. string inviteCurrName = "Unknown", //邀请费用币种 Name
  3399. inviteCurrCode = "Unknown", //邀请费用币种 Code
  3400. sendCurrName = "Unknown", //快递费用币种 Name
  3401. sendCurrCode = "Unknown", //快递费用币种 Code
  3402. eventsCurrName = "Unknown", //公务活动费币种 Name
  3403. eventsCurrCode = "Unknown", //公务活动费币种 Code
  3404. translateCurrName = "Unknown", //公务翻译费 Name
  3405. translateCurrCode = "Unknown"; //公务翻译费 Code
  3406. #region 处理费用币种
  3407. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  3408. if (inviteCurrData != null)
  3409. {
  3410. inviteCurrName = inviteCurrData.Remark;
  3411. inviteCurrCode = inviteCurrData.Name;
  3412. }
  3413. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  3414. if (sendCurrData != null)
  3415. {
  3416. sendCurrName = sendCurrData.Remark;
  3417. sendCurrCode = sendCurrData.Name;
  3418. }
  3419. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  3420. if (eventsCurrData != null)
  3421. {
  3422. eventsCurrName = eventsCurrData.Remark;
  3423. eventsCurrCode = eventsCurrData.Name;
  3424. }
  3425. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  3426. if (translateCurrData != null)
  3427. {
  3428. translateCurrName = translateCurrData.Remark;
  3429. translateCurrCode = translateCurrData.Name;
  3430. }
  3431. #endregion
  3432. _detail.PriceNameContent = _ioa.InviterArea;
  3433. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost:#0.00} {inviteCurrCode}({inviteCurrName})<br/>" +
  3434. $@"快递费用:{_ioa.SendCost:#0.00} {sendCurrCode}({sendCurrName})<br/>" +
  3435. $@"公务活动费:{_ioa.EventsCost:#0.00} {eventsCurrCode}({eventsCurrName})<br/>" +
  3436. $@"公务翻译费:{_ioa.TranslateCost:#0.00} {translateCurrCode}({translateCurrName})<br/>" +
  3437. $@"备注:" + _ioa.Remark + "<br/>";
  3438. }
  3439. break;
  3440. case 82: //团组客户保险
  3441. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  3442. if (customers != null)
  3443. {
  3444. _detail.PriceNameContent = GetClientNameStr(clientNameList, customers.ClientName);
  3445. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  3446. }
  3447. break;
  3448. case 85: //机票预订
  3449. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  3450. if (jpRes != null)
  3451. {
  3452. string FlightsDescription = jpRes.FlightsDescription;
  3453. string PriceDescription = jpRes.PriceDescription;
  3454. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  3455. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  3456. }
  3457. break;
  3458. case 98://其他款项
  3459. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  3460. if (gdpRes != null)
  3461. {
  3462. //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/";
  3463. //if (!string.IsNullOrEmpty(gdpRes.FilePath))
  3464. //{
  3465. // _detail.FileUrl = $"{urlBase}{gdpRes.FilePath}";
  3466. //}
  3467. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  3468. _detail.PriceNameContent = gdpRes.PriceName;
  3469. }
  3470. break;
  3471. case 285://收款退还
  3472. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  3473. if (refundAndOtherMoney != null)
  3474. {
  3475. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  3476. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  3477. }
  3478. break;
  3479. case 751://酒店早餐
  3480. break;
  3481. case 1015://超支费用
  3482. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  3483. if (groupExtraCost != null)
  3484. {
  3485. _detail.PriceNameContent = groupExtraCost.PriceName;
  3486. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  3487. }
  3488. break;
  3489. default:
  3490. break;
  3491. }
  3492. /*
  3493. * 申请人
  3494. */
  3495. string operatorName = " - ";
  3496. var _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  3497. if (_opUser != null)
  3498. {
  3499. operatorName = _opUser.CnName;
  3500. }
  3501. _detail.OperatorName = operatorName;
  3502. /*
  3503. * 审核人
  3504. */
  3505. string auditOperatorName = " - ";
  3506. if (entity.IsAuditGM != 0)
  3507. {
  3508. if (entity.AuditGMOperate == 0) auditOperatorName = " - ";
  3509. else if (entity.AuditGMOperate == 4) auditOperatorName = "自动审核";
  3510. else
  3511. {
  3512. var _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  3513. if (_adUser != null)
  3514. {
  3515. auditOperatorName = _adUser.CnName;
  3516. }
  3517. }
  3518. }
  3519. _detail.AuditOperatorName = auditOperatorName;
  3520. /*
  3521. * 超预算比例
  3522. */
  3523. string overBudgetStr = "";
  3524. if (entity.ExceedBudget == -1) overBudgetStr = sdPriceName.Name + "尚无预算";
  3525. else if (entity.ExceedBudget == 0)
  3526. {
  3527. if (entity.CTable == 76 || entity.CTable == 79)
  3528. {
  3529. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  3530. else overBudgetStr = _feeAuditRep.IsOverBudget(entity.CTable, entity.DIId, entity.CId);
  3531. }
  3532. else
  3533. {
  3534. overBudgetStr = "未超预算";
  3535. }
  3536. }
  3537. else overBudgetStr = entity.ExceedBudget.ToString("P");
  3538. _detail.OverBudget = overBudgetStr;
  3539. decimal auditFee = 0.00M; //已审核金额 人名币
  3540. decimal auditedFeeOriginal = 0.00M; ////已审核金额 原始
  3541. decimal unAuditFeeCNY = 0.00M; //未审核款项 原始
  3542. decimal unAuditFeeOriginal = 0.00M; //未审核款项 人名币
  3543. if (entity.IsAuditGM == 1 || entity.IsAuditGM == 3)
  3544. {
  3545. auditedFeeOriginal = entity.PayMoney;
  3546. auditFee = CurrPayStr;
  3547. }
  3548. else if (entity.IsAuditGM == 0)
  3549. {
  3550. unAuditFeeCNY = CurrPayStr;
  3551. unAuditFeeOriginal = OriginalCurrPay;
  3552. OriginalCurrPay = 0.00M;
  3553. }
  3554. /*
  3555. * 费用总计
  3556. */
  3557. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  3558. {
  3559. CurrencyId = entity.PaymentCurrency,
  3560. CurrencyName = PaymentCurrency_WaitPay,
  3561. AmountPayable = entity.PayMoney,
  3562. ThisPayment = OriginalCurrPay,
  3563. BalancePayment = BalanceStr,
  3564. AuditedFunds = auditFee,
  3565. AuditedFundsOriginal = auditedFeeOriginal,
  3566. UnAuditFundsCNY = unAuditFeeCNY,
  3567. UnAuditFundsOriginal = unAuditFeeOriginal
  3568. });
  3569. _detail.IsAuditGM = entity.IsAuditGM;
  3570. detailList.Add(_detail);
  3571. }
  3572. #endregion
  3573. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  3574. /*
  3575. * 下方描述处理
  3576. */
  3577. var nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  3578. var ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  3579. if (ccpCurrencyPrice != null)
  3580. {
  3581. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  3582. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  3583. }
  3584. else
  3585. {
  3586. nonDuplicat = nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  3587. }
  3588. string amountPayableStr = string.Format(@"应付款总金额: ");
  3589. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  3590. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  3591. string auditedFundsStr = string.Format(@"已审费用总额: ");
  3592. string unAuditedFundsStr = string.Format(@"未审费用总额: ");
  3593. foreach (var item in nonDuplicat)
  3594. {
  3595. var currencyName = item.CurrencyName;
  3596. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  3597. if (strs.Count > 0)
  3598. {
  3599. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  3600. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  3601. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  3602. amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), currencyName);
  3603. //单独处理此次付款金额
  3604. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  3605. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), currencyName);
  3606. //单独处理已审核费用
  3607. //if (item.CurrencyId == 836) //人民币
  3608. //{
  3609. // decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  3610. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), currencyName);
  3611. //}
  3612. //else
  3613. //{
  3614. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.AmountPayable), currencyName);
  3615. //}
  3616. if (currencyName.Equals("CNY"))
  3617. {
  3618. //已审核费用
  3619. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  3620. //未审核费用
  3621. unAuditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.UnAuditFundsOriginal).ToString("#0.00"), currencyName);
  3622. }
  3623. else
  3624. {
  3625. //已审核费用
  3626. 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"));
  3627. //未审核费用
  3628. 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"));
  3629. }
  3630. }
  3631. }
  3632. _view.TotalStr1 = amountPayableStr[..^1];
  3633. _view.TotalStr2 = thisPaymentStr[..^1];
  3634. _view.TotalStr3 = balancePaymentStr[..^1];
  3635. _view.TotalStr4 = $"{auditedFundsStr[..^1]}<br/>{unAuditedFundsStr[..^1]}";
  3636. //_view.TotalStr5 = unAuditedFundsStr.Substring(0, unAuditedFundsStr.Length - 1);
  3637. var _view1 = new
  3638. {
  3639. PageFuncAuth = pageFunAuthView,
  3640. Data = _view
  3641. };
  3642. return Ok(JsonView(_view1));
  3643. }
  3644. catch (Exception ex)
  3645. {
  3646. return Ok(JsonView(false, ex.Message));
  3647. }
  3648. }
  3649. /// <summary>
  3650. /// 费用审核
  3651. /// 修改团组费用审核状态
  3652. /// </summary>
  3653. /// <param name="_dto">参数Json字符串</param>
  3654. /// <returns></returns>
  3655. [HttpPost]
  3656. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3657. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  3658. {
  3659. #region 参数验证
  3660. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  3661. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  3662. #endregion
  3663. #region 页面操作权限验证
  3664. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  3665. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  3666. #endregion
  3667. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  3668. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  3669. DateTime dtNow = DateTime.Now;
  3670. _groupRepository.BeginTran();
  3671. int rst = 0;
  3672. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  3673. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  3674. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  3675. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  3676. var msgDatas = new List<dynamic>();
  3677. var dic_ccp_user = new Dictionary<int, int>() { };
  3678. foreach (var item in idList)
  3679. {
  3680. int CreditId = int.Parse(item);
  3681. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  3682. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  3683. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  3684. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  3685. .Where(s => s.Id == CreditId)
  3686. .ExecuteCommandAsync();
  3687. if (result < 1)
  3688. {
  3689. rst = -1;
  3690. _groupRepository.RollbackTran();
  3691. return Ok(JsonView(false, "操作失败并回滚!"));
  3692. }
  3693. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  3694. if (creditData != null)
  3695. {
  3696. #region 应用通知配置
  3697. try
  3698. {
  3699. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  3700. }
  3701. catch (Exception ex)
  3702. {
  3703. }
  3704. #endregion
  3705. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  3706. string groupNameStr = string.Empty;
  3707. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  3708. if (groupData != null) groupNameStr = groupData.TeamName;
  3709. string creditTypeStr = string.Empty;
  3710. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  3711. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  3712. string creditCurrency = string.Empty;
  3713. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  3714. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  3715. if (creditCurrency.Equals("CNY"))
  3716. {
  3717. creditData.DayRate = 1.0000M;
  3718. }
  3719. if (creditData.PayPercentage == 0.00M)
  3720. {
  3721. creditData.PayPercentage = 100M;
  3722. }
  3723. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  3724. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  3725. string msgContent = "";
  3726. if (creditCurrency.Equals("CNY"))
  3727. {
  3728. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice:0.00} CNY) {auditStr}!";
  3729. }
  3730. else
  3731. {
  3732. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice:0.00} CNY({creditData.PayMoney:0.00} {creditCurrency})) {auditStr}!";
  3733. }
  3734. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  3735. }
  3736. }
  3737. if (rst == 0)
  3738. {
  3739. _groupRepository.CommitTran();
  3740. foreach (var item in msgDatas)
  3741. {
  3742. //发送消息
  3743. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  3744. }
  3745. #region 应用推送
  3746. try
  3747. {
  3748. foreach (var ccpId in dic_ccp_user.Keys)
  3749. {
  3750. var templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  3751. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  3752. }
  3753. }
  3754. catch (Exception)
  3755. {
  3756. }
  3757. #endregion
  3758. return Ok(JsonView(true, "操作成功!"));
  3759. }
  3760. return Ok(JsonView(false, "操作失败!"));
  3761. }
  3762. /// <summary>
  3763. /// 费用审核
  3764. /// 其他款项 文件下载
  3765. /// </summary>
  3766. /// <param name="id">其他款项 主键编号</param>
  3767. /// <returns></returns>
  3768. [HttpGet("{id}")]
  3769. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3770. public async Task<IActionResult> FeeAuditOtherFileDownlaod([Range(1,int.MaxValue,ErrorMessage ="")]int id)
  3771. {
  3772. var otherInfo = await _decreasePaymentsRep.Query(x => x.Id == id && x.IsDel == 0).FirstAsync();
  3773. string url = "暂无附件!";
  3774. if (otherInfo != null)
  3775. {
  3776. url = $"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/{otherInfo.FilePath}";
  3777. return Ok(JsonView(true, "操作成功!", url));
  3778. }
  3779. return Ok(JsonView(false, url));
  3780. }
  3781. #endregion
  3782. #region 机票费用录入
  3783. /// <summary>
  3784. /// 机票录入当前登录人可操作团组
  3785. /// </summary>
  3786. /// <param name="dto"></param>
  3787. /// <returns></returns>
  3788. [HttpPost]
  3789. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3790. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  3791. {
  3792. try
  3793. {
  3794. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  3795. if (groupData.Code != 0)
  3796. {
  3797. return Ok(JsonView(false, groupData.Msg));
  3798. }
  3799. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3800. }
  3801. catch (Exception ex)
  3802. {
  3803. return Ok(JsonView(false, ex.Message));
  3804. }
  3805. }
  3806. /// <summary>
  3807. /// 机票费用录入列表
  3808. /// </summary>
  3809. /// <param name="dto"></param>
  3810. /// <returns></returns>
  3811. [HttpPost]
  3812. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3813. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  3814. {
  3815. try
  3816. {
  3817. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  3818. if (groupData.Code != 0)
  3819. {
  3820. return Ok(JsonView(false, groupData.Msg));
  3821. }
  3822. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3823. }
  3824. catch (Exception ex)
  3825. {
  3826. return Ok(JsonView(false, ex.Message));
  3827. throw;
  3828. }
  3829. }
  3830. /// <summary>
  3831. /// 根据id查询费用录入信息
  3832. /// </summary>
  3833. /// <param name="dto"></param>
  3834. /// <returns></returns>
  3835. [HttpPost]
  3836. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3837. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  3838. {
  3839. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  3840. if (groupData.Code != 0)
  3841. {
  3842. return Ok(JsonView(false, groupData.Msg));
  3843. }
  3844. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3845. }
  3846. /// <summary>
  3847. /// 机票费用录入操作(Status:1.新增,2.修改)
  3848. /// </summary>
  3849. /// <param name="dto"></param>
  3850. /// <returns></returns>
  3851. [HttpPost]
  3852. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3853. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  3854. {
  3855. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  3856. if (groupData.Code != 0)
  3857. {
  3858. return Ok(JsonView(false, groupData.Msg));
  3859. }
  3860. #region 应用推送
  3861. try
  3862. {
  3863. var diId = dto.AirTicketResOpData.DiId;
  3864. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3865. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3866. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  3867. //自动审核
  3868. //var autoAdit1 = await _feeAuditRep.FeeAutomaticAudit(5, diId, dataId); //机票费用合计方式
  3869. (bool status, string auditMsg) = await AirTicketResAutoAudit(diId, dataId); //KIMI-AI识别INIT方式
  3870. _logger.LogInformation("【机票费用自动审核(KIMI-AI识别INIT)】请求参数:{RequstData} 返回结果:是否执行:{IsExecute}; 结果消息:{ResponseMsg};",
  3871. $"GroupId:{diId};airId:{dataId};",
  3872. status,
  3873. auditMsg);
  3874. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3875. //2024-10-21 新增LZ UID
  3876. var userIds = new List<int>() { 21 };
  3877. string title = $"系统通知";
  3878. string content = "";
  3879. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  3880. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  3881. if (dto.Status == 1) content = $"[新增-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3882. else if (dto.Status == 2) content = $"[更新-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3883. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  3884. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "85" };
  3885. await APNsTools.iOS_PushNotifications1("051", $"机票费用审核", "", content, true, "ExpenseAuditWebView", h5);
  3886. }
  3887. catch (Exception ex)
  3888. {
  3889. }
  3890. #endregion
  3891. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3892. }
  3893. /// <summary>
  3894. /// 机票费用自动审核 AI识别方式
  3895. /// </summary>
  3896. /// <returns></returns>
  3897. private async Task<(bool, string)> AirTicketResAutoAudit(int diId, int dataId)
  3898. {
  3899. var ecoTypeIds = new List<int>() {
  3900. 459, //超经舱
  3901. 460, //经济舱
  3902. 1430, //公务舱(实际经济舱)
  3903. 1432, //头等舱(实际经济舱)
  3904. };
  3905. var bizTypeIds = new List<int>() {
  3906. 457, //头等舱
  3907. 458, //公务舱
  3908. 1431, //头等舱(实际公务舱)
  3909. };
  3910. var auditFeeTypeIds = new List<int>() { };
  3911. auditFeeTypeIds.AddRange(ecoTypeIds);
  3912. auditFeeTypeIds.AddRange(bizTypeIds);
  3913. int currModule = 85;
  3914. var airInfo = await _sqlSugar.Queryable<Grp_AirTicketReservations>()
  3915. .InnerJoin<Grp_CreditCardPayment>((x, y) => x.Id == y.CId && y.CTable == currModule && y.IsDel == 0)
  3916. .Where((x, y) => x.Id == dataId && x.IsDel == 0 && auditFeeTypeIds.Contains(x.CType))
  3917. .Select((x, y) => new
  3918. {
  3919. x.Id,
  3920. CcpId = y.Id,
  3921. x.FlightsDate,
  3922. x.PrePrice,
  3923. x.CType,
  3924. x.ClientNum,
  3925. x.DIId
  3926. })
  3927. .FirstAsync();
  3928. if (airInfo == null) return (false, "机票信息为空或费用类型不在自动审核范围内,不可自动审核!");
  3929. var groupDetails = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.IsDel == 0 && x.Id == diId);
  3930. if (groupDetails == null) return (false, "团组信息为空,不可自动审核!");
  3931. var groupCostInfo = await _sqlSugar.Queryable<Grp_GroupCostParameter>().FirstAsync(x => x.IsDel == 0 && x.DiId == diId);
  3932. if (groupCostInfo == null) return (false, "团组成本信息未填写!");
  3933. var groupCostContents = await _sqlSugar
  3934. .SqlQueryable<GroupCostAuditView>($"Select * From Grp_GroupCost")
  3935. .Where(x => x.IsDel == 0 && x.Diid == diId)
  3936. .ToListAsync();
  3937. if (groupCostContents.Count < 1) return (false, "团组成本信息未填写!");
  3938. //处理 成本详细信息日期为空 填装费用信息
  3939. var airFeeLabel = new StringBuilder();
  3940. airFeeLabel.AppendLine("费用成本:");
  3941. for (int i = 0; i < groupCostContents.Count; i++)
  3942. {
  3943. if (string.IsNullOrEmpty(groupCostContents[i].Date))
  3944. {
  3945. int index = i - 1;
  3946. if (index >= 0)
  3947. {
  3948. groupCostContents[i].Date = groupCostContents[index].Date;
  3949. var dtBool = DateTime.TryParse(groupCostContents[i].Date, out DateTime _dateTime);
  3950. if (dtBool) groupCostContents[i].CurrTime = _dateTime;
  3951. }
  3952. }
  3953. else
  3954. {
  3955. var dtBool = DateTime.TryParse(groupCostContents[i].Date, out DateTime _dateTime);
  3956. if (dtBool) groupCostContents[i].CurrTime = _dateTime;
  3957. }
  3958. var item = groupCostContents[i];
  3959. airFeeLabel.AppendLine($"{item.Date}");
  3960. airFeeLabel.AppendLine($"{item.ITIN.Replace("\n", " ")}");
  3961. }
  3962. airFeeLabel.AppendLine($"注:费用:位置:航班号或者航班时间后面; 组成:经济舱/公务舱;");
  3963. airFeeLabel.AppendLine($"取出“{airInfo.FlightsDate}”费用金额,按照经济舱/公务舱格式返回,如果不存在的话则返回0.00/0.00,只返回金额格式文本;不需要其他文字描述;");
  3964. //访问Kimi AI 返回价格结果
  3965. var msgs = new List<SeedMessages>()
  3966. {
  3967. new ()
  3968. {
  3969. Role = KimiRole.user,
  3970. Content = airFeeLabel.ToString()
  3971. }
  3972. };
  3973. var client = new KiMiApiClient();
  3974. var kimiApiResult = await client.SeedMessage(msgs);
  3975. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  3976. string clients = kimiApiResult_JObject["content"].ToString();
  3977. decimal ecoPri_kimiAI = 0.00M,
  3978. bizPri_kimiAI = 0.00M;
  3979. //单个价格: 经济舱价格
  3980. if (decimal.TryParse(clients, out ecoPri_kimiAI)) { }
  3981. //价格文本包含/:/前经济舱价格 /后公务舱价格
  3982. if (clients.Contains('/'))
  3983. {
  3984. var priArray = clients.Split('/');
  3985. decimal.TryParse(priArray[0], out ecoPri_kimiAI); //
  3986. decimal.TryParse(priArray[1], out bizPri_kimiAI); //经济舱价格
  3987. }
  3988. else return (false, "价格文本不存在价格或KIMI-AI未识别出价格,不可自动审核!");
  3989. var isAutoAudit = false;
  3990. //价格验证处理
  3991. //经济舱
  3992. if (ecoTypeIds.Contains(airInfo.CType))
  3993. {
  3994. if (airInfo.PrePrice <= ecoPri_kimiAI) isAutoAudit = true;
  3995. }
  3996. //公务舱
  3997. else if (bizTypeIds.Contains(airInfo.CType))
  3998. {
  3999. if (airInfo.PrePrice <= bizPri_kimiAI) isAutoAudit = true;
  4000. }
  4001. else return (false, "该舱位类型不在自动审核范围内,不可自动审核!");
  4002. //是否执行自动审核
  4003. if (isAutoAudit)
  4004. {
  4005. var auditStatus = await _sqlSugar.Updateable<Grp_CreditCardPayment>()
  4006. .SetColumns(x => x.IsAuditGM == 3)
  4007. .SetColumns(x => x.AuditGMOperate == 4)
  4008. .SetColumns(x => x.AuditGMDate == DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
  4009. .Where(x => x.Id == airInfo.CcpId)
  4010. .ExecuteCommandAsync();
  4011. if (auditStatus > 0) return (true, "机票自动审核(KIMI-AI识别方式)执行成功!");
  4012. }
  4013. return (false, "当前费用超过成本费用,不可自动审核!");
  4014. }
  4015. /// <summary>
  4016. /// 机票费用录入
  4017. /// 自动审核测试 - AI 识别
  4018. /// </summary>
  4019. /// <param name="groupId"></param>
  4020. /// <param name="Id"></param>
  4021. /// <returns></returns>
  4022. [HttpPost]
  4023. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4024. public async Task<IActionResult> AirTicketResAutoAuditTest(int groupId, int Id)
  4025. {
  4026. (bool status, string msg) = await AirTicketResAutoAudit(groupId, Id);
  4027. return Ok(JsonView(status, msg));
  4028. }
  4029. /// <summary>
  4030. /// 根据舱位类型查询接团客户名单信息
  4031. /// </summary>
  4032. /// <param name="dto"></param>
  4033. /// <returns></returns>
  4034. [HttpPost]
  4035. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4036. public async Task<IActionResult> TankType(AirTicketResByIdDto dto)
  4037. {
  4038. try
  4039. {
  4040. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  4041. if (crm_Groups.Count != 0)
  4042. {
  4043. var Customer = new List<dynamic>();
  4044. foreach (var item in crm_Groups)
  4045. {
  4046. var data = new
  4047. {
  4048. item.Id,
  4049. item.Pinyin,
  4050. Name = item.LastName + item.FirstName
  4051. };
  4052. Customer.Add(data);
  4053. }
  4054. return Ok(JsonView(true, "查询成功!", Customer));
  4055. }
  4056. return Ok(JsonView(true, "暂无数据", crm_Groups));
  4057. }
  4058. catch (Exception ex)
  4059. {
  4060. return Ok(JsonView(false, "程序错误!"));
  4061. throw;
  4062. }
  4063. }
  4064. /// <summary>
  4065. /// 根据团号获取客户信息
  4066. /// </summary>
  4067. /// <param name="dto"></param>
  4068. /// <returns></returns>
  4069. [HttpPost]
  4070. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4071. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  4072. {
  4073. var jw = JsonView(false);
  4074. if (dto.DIID < 1)
  4075. {
  4076. jw.Msg += "请输入正确的diid";
  4077. return Ok(jw);
  4078. }
  4079. var arr = GetSimplClientList(dto.DIID);
  4080. jw = JsonView(true, "获取成功!", arr);
  4081. return Ok(jw);
  4082. }
  4083. private List<SimplClientInfo> GetSimplClientList(int diId)
  4084. {
  4085. 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);
  4086. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  4087. foreach (var item in arr)
  4088. {
  4089. EncryptionProcessor.DecryptProperties(item);
  4090. }
  4091. return arr;
  4092. }
  4093. private static string GetClientNameStr(List<SimplClientInfo> list, string origin)
  4094. {
  4095. string result = origin;
  4096. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  4097. {
  4098. string[] temparr = origin.Split(',');
  4099. string fistrStr = temparr[0];
  4100. int count = temparr.Length;
  4101. bool success = int.TryParse(fistrStr, out int tempId);
  4102. if (success)
  4103. {
  4104. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  4105. if (tempInfo != null)
  4106. {
  4107. if (count > 1)
  4108. {
  4109. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  4110. }
  4111. else
  4112. {
  4113. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  4114. }
  4115. }
  4116. }
  4117. }
  4118. return result;
  4119. }
  4120. private static string GetClientNameStr1(List<SimplClientInfo> list, string origin)
  4121. {
  4122. string result = origin;
  4123. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  4124. {
  4125. string[] temparr = origin.Split(',');
  4126. result = "";
  4127. foreach (var item in temparr)
  4128. {
  4129. bool success = int.TryParse(item, out int tempId);
  4130. if (success)
  4131. {
  4132. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  4133. if (tempInfo != null)
  4134. {
  4135. result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
  4136. }
  4137. }
  4138. }
  4139. }
  4140. if (result.Length > 0) result = result.Substring(0, result.Length - 1);
  4141. return result;
  4142. }
  4143. /// <summary>
  4144. /// 机票费用录入,删除
  4145. /// </summary>
  4146. /// <param name="dto"></param>
  4147. /// <returns></returns>
  4148. [HttpPost]
  4149. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4150. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  4151. {
  4152. try
  4153. {
  4154. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  4155. if (res)
  4156. {
  4157. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  4158. {
  4159. IsDel = 1,
  4160. DeleteUserId = dto.DeleteUserId,
  4161. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4162. }).ExecuteCommandAsync();
  4163. return Ok(JsonView(true, "删除成功!"));
  4164. }
  4165. return Ok(JsonView(false, "删除失败!"));
  4166. }
  4167. catch (Exception ex)
  4168. {
  4169. return Ok(JsonView(false, "程序错误!"));
  4170. throw;
  4171. }
  4172. }
  4173. /// <summary>
  4174. /// 导出机票录入报表
  4175. /// </summary>
  4176. /// <param name="dto"></param>
  4177. /// <returns></returns>
  4178. [HttpPost]
  4179. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4180. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  4181. {
  4182. try
  4183. {
  4184. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  4185. if (groupData.Code != 0)
  4186. {
  4187. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  4188. }
  4189. else
  4190. {
  4191. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  4192. if (AirTicketReservations.Count != 0)
  4193. {
  4194. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  4195. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  4196. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  4197. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  4198. var designer = new WorkbookDesigner
  4199. {
  4200. Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx")
  4201. };
  4202. decimal countCost = 0;
  4203. foreach (var item in AirTicketReservations)
  4204. {
  4205. #region 处理客人姓名
  4206. string clientNames = _tourClientListRep.ResolveCustomerName(item.ClientName);
  4207. item.ClientName = clientNames;
  4208. #endregion
  4209. if (item.BankType == "其他")
  4210. {
  4211. item.BankNo = "--";
  4212. }
  4213. else
  4214. {
  4215. if (!string.IsNullOrEmpty(item.BankType))
  4216. {
  4217. item.BankNo = item.BankType + ":" + item.BankNo?.Substring(0, 3);
  4218. }
  4219. }
  4220. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  4221. item.Price = System.Decimal.Round(item.Price, 2);
  4222. countCost += Convert.ToDecimal(item.Price);
  4223. }
  4224. designer.SetDataSource("Export", AirTicketReservations);
  4225. designer.SetDataSource("ExportDiCode", diCode);
  4226. designer.SetDataSource("ExportDiName", diName);
  4227. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  4228. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  4229. designer.Process();
  4230. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  4231. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  4232. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  4233. return Ok(JsonView(true, "成功", url = rst));
  4234. }
  4235. else
  4236. {
  4237. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  4238. }
  4239. }
  4240. }
  4241. catch (Exception ex)
  4242. {
  4243. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  4244. throw;
  4245. }
  4246. }
  4247. Dictionary<string, string> transDic = new Dictionary<string, string>();
  4248. /// <summary>
  4249. /// 行程单导出
  4250. /// </summary>
  4251. /// <param name="dto"></param>
  4252. /// <returns></returns>
  4253. [HttpPost]
  4254. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4255. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  4256. {
  4257. try
  4258. {
  4259. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  4260. if (groupData.Code != 0)
  4261. {
  4262. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  4263. }
  4264. else
  4265. {
  4266. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  4267. if (dto.Language == "CN")
  4268. {
  4269. var doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  4270. var builder = new DocumentBuilder(doc);
  4271. int tableIndex = 0;//表格索引
  4272. //得到文档中的第一个表格
  4273. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  4274. foreach (var item in _AirTicketReservations)
  4275. {
  4276. #region 处理固定数据
  4277. string[] FlightsCode = item.FlightsCode.Split('/');
  4278. if (FlightsCode.Length != 0)
  4279. {
  4280. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4281. if (_AirCompany != null)
  4282. {
  4283. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  4284. }
  4285. else
  4286. {
  4287. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  4288. }
  4289. }
  4290. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4291. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4292. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4293. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4294. string name = "";
  4295. foreach (string clientName in nameArray)
  4296. {
  4297. if (!name.Contains(clientName))
  4298. {
  4299. name += clientName + ",";
  4300. }
  4301. }
  4302. if (!string.IsNullOrWhiteSpace(name))
  4303. {
  4304. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  4305. }
  4306. else
  4307. {
  4308. table.Range.Bookmarks["ClientName"].Text = "--";
  4309. }
  4310. table.Range.Bookmarks["TicketNumber"].Text = "--";
  4311. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  4312. table.Range.Bookmarks["JointTicket"].Text = "--";
  4313. table.Range.Bookmarks["TimeIssue"].Text = "--";
  4314. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  4315. table.Range.Bookmarks["NavigationCode"].Text = "--";
  4316. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  4317. table.Range.Bookmarks["AgentPhone"].Text = "--";
  4318. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  4319. #endregion
  4320. #region 循环数据处理
  4321. var airs = new List<AirInfo>();
  4322. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  4323. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  4324. for (int i = 0; i < FlightsCode.Length; i++)
  4325. {
  4326. var air = new AirInfo();
  4327. string[] tempstr = DayArray[i]
  4328. .Replace("\r\n", string.Empty)
  4329. .Replace("\\r\\n", string.Empty)
  4330. .TrimStart().TrimEnd()
  4331. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  4332. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  4333. string starCity = "";
  4334. if (star_Three != null)
  4335. {
  4336. starCity = star_Three.AirPort;
  4337. }
  4338. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  4339. string EndCity = "";
  4340. if (End_Three != null)
  4341. {
  4342. EndCity = End_Three.AirPort;
  4343. }
  4344. air.Destination = starCity + "/" + EndCity;
  4345. air.Flight = FlightsCode[i];
  4346. air.SeatingClass = item.CTypeName;
  4347. string dateTime = tempstr[2];
  4348. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  4349. air.FlightDate = DateTemp;
  4350. air.DepartureTime = tempstr[5];
  4351. air.LandingTime = tempstr[6];
  4352. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  4353. air.TicketStatus = "--";
  4354. air.Luggage = "--";
  4355. air.DepartureTerminal = "--";
  4356. air.LandingTerminal = "--";
  4357. airs.Add(air);
  4358. }
  4359. int row = 13;
  4360. for (int i = 0; i < airs.Count; i++)
  4361. {
  4362. if (airs.Count > 2)
  4363. {
  4364. for (int j = 0; j < airs.Count - 2; j++)
  4365. {
  4366. var CopyRow = table.Rows[12].Clone(true);
  4367. table.Rows.Add(CopyRow);
  4368. }
  4369. }
  4370. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  4371. int index = 0;
  4372. foreach (PropertyInfo property in properties)
  4373. {
  4374. string value = property.GetValue(airs[i]).ToString();
  4375. Cell ishcel0 = table.Rows[row].Cells[index];
  4376. var p = new Paragraph(doc);
  4377. string s = value;
  4378. p.AppendChild(new Run(doc, s));
  4379. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  4380. ishcel0.AppendChild(p);
  4381. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  4382. index++;
  4383. }
  4384. row++;
  4385. }
  4386. #endregion
  4387. var lastParagraph = new Paragraph(doc);
  4388. //第一个表格末尾加段落
  4389. table.ParentNode.InsertAfter(lastParagraph, table);
  4390. //复制第一个表格
  4391. Table cloneTable = (Table)table.Clone(true);
  4392. //在文档末尾段落后面加入复制的表格
  4393. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  4394. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  4395. {
  4396. int rownewsIndex = 13;
  4397. for (int i = 0; i < 2; i++)
  4398. {
  4399. var CopyRow = table.Rows[12].Clone(true);
  4400. table.Rows.RemoveAt(13);
  4401. table.Rows.Add(CopyRow);
  4402. rownewsIndex++;
  4403. }
  4404. }
  4405. else
  4406. {
  4407. table.Rows.RemoveAt(12);
  4408. }
  4409. cloneTable.Rows.RemoveAt(12);
  4410. }
  4411. if (_AirTicketReservations.Count != 0)
  4412. {
  4413. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  4414. if (FlightsCode.Length != 0)
  4415. {
  4416. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4417. if (_AirCompany != null)
  4418. {
  4419. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  4420. }
  4421. else
  4422. {
  4423. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  4424. }
  4425. }
  4426. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4427. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4428. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4429. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4430. string name = "";
  4431. foreach (string clientName in nameArray)
  4432. {
  4433. if (!name.Contains(clientName))
  4434. {
  4435. name += clientName + ",";
  4436. }
  4437. }
  4438. if (!string.IsNullOrWhiteSpace(name))
  4439. {
  4440. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  4441. }
  4442. else
  4443. {
  4444. table.Range.Bookmarks["ClientName"].Text = "--";
  4445. }
  4446. table.Range.Bookmarks["TicketNumber"].Text = "--";
  4447. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  4448. table.Range.Bookmarks["JointTicket"].Text = "--";
  4449. table.Range.Bookmarks["TimeIssue"].Text = "--";
  4450. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  4451. table.Range.Bookmarks["NavigationCode"].Text = "--";
  4452. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  4453. table.Range.Bookmarks["AgentPhone"].Text = "--";
  4454. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  4455. }
  4456. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  4457. //保存合并后的文档
  4458. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  4459. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  4460. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  4461. return Ok(JsonView(true, "成功!", rst));
  4462. }
  4463. else
  4464. {
  4465. var doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  4466. var builder = new DocumentBuilder(doc);
  4467. int tableIndex = 0;//表格索引
  4468. //得到文档中的第一个表格
  4469. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  4470. var texts = new List<string>();
  4471. foreach (var item in _AirTicketReservations)
  4472. {
  4473. string[] FlightsCode = item.FlightsCode.Split('/');
  4474. if (FlightsCode.Length != 0)
  4475. {
  4476. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4477. if (_AirCompany != null)
  4478. {
  4479. if (!transDic.ContainsKey(_AirCompany.CnName))
  4480. {
  4481. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  4482. }
  4483. }
  4484. else
  4485. {
  4486. if (!transDic.ContainsKey("--"))
  4487. {
  4488. transDic.Add("--", "--");
  4489. }
  4490. }
  4491. }
  4492. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4493. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4494. string name = "";
  4495. foreach (string clientName in nameArray)
  4496. {
  4497. name += clientName + ",";
  4498. }
  4499. if (!texts.Contains(name))
  4500. {
  4501. texts.Add(name);
  4502. }
  4503. var airs = new List<AirInfo>();
  4504. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  4505. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  4506. for (int i = 0; i < FlightsCode.Length; i++)
  4507. {
  4508. var air = new AirInfo();
  4509. string[] tempstr = DayArray[i]
  4510. .Replace("\r\n", string.Empty)
  4511. .Replace("\\r\\n", string.Empty)
  4512. .TrimStart().TrimEnd()
  4513. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  4514. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  4515. if (star_Three != null)
  4516. {
  4517. if (!transDic.ContainsKey(star_Three.AirPort))
  4518. {
  4519. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  4520. }
  4521. }
  4522. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  4523. if (End_Three != null)
  4524. {
  4525. if (!transDic.ContainsKey(End_Three.AirPort))
  4526. {
  4527. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  4528. }
  4529. }
  4530. if (!texts.Contains(item.CTypeName))
  4531. {
  4532. texts.Add(item.CTypeName);
  4533. }
  4534. }
  4535. }
  4536. List<TranslateResult> transData = await _airTicketResRep.ReTransBatch(texts, "en");
  4537. if (transData.Count > 0)
  4538. {
  4539. foreach (TranslateResult item in transData)
  4540. {
  4541. if (!transDic.ContainsKey(item.Query))
  4542. {
  4543. transDic.Add(item.Query, item.Translation);
  4544. }
  4545. }
  4546. }
  4547. foreach (var item in _AirTicketReservations)
  4548. {
  4549. #region 处理固定数据
  4550. string[] FlightsCode = item.FlightsCode.Split('/');
  4551. if (FlightsCode.Length != 0)
  4552. {
  4553. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4554. if (_AirCompany != null)
  4555. {
  4556. string str = "--";
  4557. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  4558. if (!string.IsNullOrEmpty(translateResult))
  4559. {
  4560. str = translateResult;
  4561. str = _airTicketResRep.Processing(str);
  4562. }
  4563. table.Range.Bookmarks["AirlineCompany"].Text = str;
  4564. }
  4565. else
  4566. {
  4567. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  4568. }
  4569. }
  4570. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4571. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4572. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4573. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4574. string names = "";
  4575. foreach (string clientName in nameArray)
  4576. {
  4577. names += clientName + ",";
  4578. }
  4579. if (!string.IsNullOrWhiteSpace(names))
  4580. {
  4581. string str = "--";
  4582. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  4583. if (!string.IsNullOrEmpty(translateResult))
  4584. {
  4585. str = translateResult;
  4586. str = _airTicketResRep.Processing(str);
  4587. }
  4588. table.Range.Bookmarks["ClientName"].Text = str;
  4589. }
  4590. else
  4591. {
  4592. table.Range.Bookmarks["ClientName"].Text = "--";
  4593. }
  4594. table.Range.Bookmarks["TicketNumber"].Text = "--";
  4595. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  4596. table.Range.Bookmarks["JointTicket"].Text = "--";
  4597. table.Range.Bookmarks["TimeIssue"].Text = "--";
  4598. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  4599. table.Range.Bookmarks["NavigationCode"].Text = "--";
  4600. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  4601. table.Range.Bookmarks["AgentPhone"].Text = "--";
  4602. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  4603. #endregion
  4604. #region 循环数据处理
  4605. var airs = new List<AirInfo>();
  4606. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  4607. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  4608. for (int i = 0; i < FlightsCode.Length; i++)
  4609. {
  4610. var air = new AirInfo();
  4611. string[] tempstr = DayArray[i]
  4612. .Replace("\r\n", string.Empty)
  4613. .Replace("\\r\\n", string.Empty)
  4614. .TrimStart().TrimEnd()
  4615. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  4616. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  4617. string starCity = "";
  4618. if (star_Three != null)
  4619. {
  4620. string str2 = "--";
  4621. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  4622. if (!string.IsNullOrEmpty(translateResult2))
  4623. {
  4624. str2 = translateResult2;
  4625. str2 = _airTicketResRep.Processing(str2);
  4626. }
  4627. starCity = str2;
  4628. }
  4629. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  4630. string EndCity = "";
  4631. if (End_Three != null)
  4632. {
  4633. string str1 = "--";
  4634. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  4635. if (!string.IsNullOrEmpty(translateResult1))
  4636. {
  4637. str1 = translateResult1;
  4638. str1 = _airTicketResRep.Processing(str1);
  4639. }
  4640. EndCity = str1;
  4641. }
  4642. air.Destination = starCity + "/" + EndCity;
  4643. air.Flight = FlightsCode[i];
  4644. string str = "--";
  4645. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  4646. if (!string.IsNullOrEmpty(translateResult))
  4647. {
  4648. str = translateResult;
  4649. str = _airTicketResRep.Processing(str);
  4650. }
  4651. air.SeatingClass = str;
  4652. string dateTime = tempstr[2];
  4653. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  4654. air.FlightDate = DateTemp;
  4655. air.DepartureTime = tempstr[5];
  4656. air.LandingTime = tempstr[6];
  4657. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  4658. air.TicketStatus = "--";
  4659. air.Luggage = "--";
  4660. air.DepartureTerminal = "--";
  4661. air.LandingTerminal = "--";
  4662. airs.Add(air);
  4663. }
  4664. int row = 13;
  4665. for (int i = 0; i < airs.Count; i++)
  4666. {
  4667. if (airs.Count > 2)
  4668. {
  4669. for (int j = 0; j < airs.Count - 2; j++)
  4670. {
  4671. var CopyRow = table.Rows[12].Clone(true);
  4672. table.Rows.Add(CopyRow);
  4673. }
  4674. }
  4675. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  4676. int index = 0;
  4677. foreach (PropertyInfo property in properties)
  4678. {
  4679. string value = property.GetValue(airs[i]).ToString();
  4680. Cell ishcel0 = table.Rows[row].Cells[index];
  4681. var p = new Paragraph(doc);
  4682. string s = value;
  4683. p.AppendChild(new Run(doc, s));
  4684. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  4685. ishcel0.AppendChild(p);
  4686. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  4687. //ishcel0.CellFormat.VerticalAlignment=
  4688. index++;
  4689. }
  4690. row++;
  4691. }
  4692. #endregion
  4693. var lastParagraph = new Paragraph(doc);
  4694. //第一个表格末尾加段落
  4695. table.ParentNode.InsertAfter(lastParagraph, table);
  4696. //复制第一个表格
  4697. Table cloneTable = (Table)table.Clone(true);
  4698. //在文档末尾段落后面加入复制的表格
  4699. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  4700. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  4701. {
  4702. int rownewsIndex = 13;
  4703. for (int i = 0; i < 2; i++)
  4704. {
  4705. var CopyRow = table.Rows[12].Clone(true);
  4706. table.Rows.RemoveAt(13);
  4707. table.Rows.Add(CopyRow);
  4708. rownewsIndex++;
  4709. }
  4710. }
  4711. else
  4712. {
  4713. table.Rows.RemoveAt(12);
  4714. }
  4715. cloneTable.Rows.RemoveAt(12);
  4716. }
  4717. if (_AirTicketReservations.Count != 0)
  4718. {
  4719. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  4720. if (FlightsCode.Length != 0)
  4721. {
  4722. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4723. if (_AirCompany != null)
  4724. {
  4725. string str = "--";
  4726. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  4727. if (!string.IsNullOrEmpty(translateResult))
  4728. {
  4729. str = translateResult;
  4730. str = _airTicketResRep.Processing(str);
  4731. }
  4732. table.Range.Bookmarks["AirlineCompany"].Text = str;
  4733. }
  4734. else
  4735. {
  4736. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  4737. }
  4738. }
  4739. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4740. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4741. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4742. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4743. string names = "";
  4744. foreach (string clientName in nameArray)
  4745. {
  4746. names += clientName + ",";
  4747. }
  4748. if (!string.IsNullOrWhiteSpace(names))
  4749. {
  4750. string str = "--";
  4751. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  4752. if (!string.IsNullOrEmpty(translateResult))
  4753. {
  4754. str = translateResult;
  4755. str = _airTicketResRep.Processing(str);
  4756. }
  4757. table.Range.Bookmarks["ClientName"].Text = str;
  4758. }
  4759. else
  4760. {
  4761. table.Range.Bookmarks["ClientName"].Text = "--";
  4762. }
  4763. table.Range.Bookmarks["TicketNumber"].Text = "--";
  4764. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  4765. table.Range.Bookmarks["JointTicket"].Text = "--";
  4766. table.Range.Bookmarks["TimeIssue"].Text = "--";
  4767. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  4768. table.Range.Bookmarks["NavigationCode"].Text = "--";
  4769. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  4770. table.Range.Bookmarks["AgentPhone"].Text = "--";
  4771. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  4772. }
  4773. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  4774. //保存合并后的文档
  4775. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  4776. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  4777. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  4778. return Ok(JsonView(true, "成功!", rst));
  4779. }
  4780. }
  4781. }
  4782. catch (Exception ex)
  4783. {
  4784. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  4785. throw;
  4786. }
  4787. }
  4788. #endregion
  4789. #region 团组增减款项 --> 其他款项
  4790. /// <summary>
  4791. /// 团组增减款项下拉框绑定
  4792. /// </summary>
  4793. /// <param name="dto"></param>
  4794. /// <returns></returns>
  4795. [HttpPost]
  4796. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4797. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  4798. {
  4799. #region 参数验证
  4800. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  4801. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  4802. #endregion
  4803. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  4804. }
  4805. /// <summary>
  4806. /// 根据团组Id查询团组增减款项
  4807. /// </summary>
  4808. /// <param name="dto"></param>
  4809. /// <returns></returns>
  4810. [HttpPost]
  4811. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4812. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  4813. {
  4814. #region 参数验证
  4815. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  4816. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  4817. #endregion
  4818. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  4819. }
  4820. /// <summary>
  4821. /// 团组增减款项操作(Status:1.新增,2.修改)
  4822. /// </summary>
  4823. /// <param name="dto"></param>
  4824. /// <returns></returns>
  4825. [HttpPost]
  4826. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4827. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  4828. {
  4829. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  4830. if (groupData.Code != 200)
  4831. {
  4832. return Ok(JsonView(false, groupData.Msg));
  4833. }
  4834. #region 应用推送
  4835. //int otherId = (int)groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  4836. //int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  4837. //int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  4838. int otherId = Convert.ToInt32(groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null) ?? 0);
  4839. int ccpId = Convert.ToInt32(groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null) ?? 0);
  4840. int sign = Convert.ToInt32(groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null) ?? 0);
  4841. //自动审核
  4842. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(3, dto.DiId, otherId);
  4843. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  4844. //2024-10-21 新增LZ UID
  4845. var userIds = new List<int>() { 21 };
  4846. string title = $"系统通知";
  4847. string content = "";
  4848. var diId = dto.DiId;
  4849. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  4850. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  4851. if (dto.Status == 1) content = $"[新增-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4852. else if (dto.Status == 2) content = $"[更新-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4853. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  4854. //await APNsTools.iOS_PushNotifications1("051", $"其他款项费用审核", "", content);
  4855. #endregion
  4856. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4857. }
  4858. /// <summary>
  4859. ///
  4860. /// 团组增减款项操作 删除
  4861. /// </summary>
  4862. /// <param name="dto"></param>
  4863. /// <returns></returns>
  4864. [HttpPost]
  4865. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4866. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  4867. {
  4868. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  4869. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  4870. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  4871. if (res.Code == 0) return Ok(JsonView(true, "删除成功!"));
  4872. return Ok(JsonView(false, res?.Msg ?? "删除失败!"));
  4873. }
  4874. /// <summary>
  4875. /// 根据团组增减款项Id查询
  4876. /// </summary>
  4877. /// <param name="dto"></param>
  4878. /// <returns></returns>
  4879. [HttpPost]
  4880. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4881. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  4882. {
  4883. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  4884. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  4885. }
  4886. /// <summary>
  4887. /// 查询供应商名称
  4888. /// </summary>
  4889. /// <param name="dto"></param>
  4890. /// <returns></returns>
  4891. [HttpPost]
  4892. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  4893. {
  4894. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  4895. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  4896. ?? new List<Grp_DecreasePayments>();
  4897. dbResult = dbResult.Distinct(new
  4898. ProductComparer()).ToList();
  4899. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  4900. {
  4901. x.Id,
  4902. x.SupplierAddress,
  4903. x.SupplierArea,
  4904. x.SupplierContact,
  4905. x.SupplierContactNumber,
  4906. x.SupplierEmail,
  4907. x.SupplierName,
  4908. x.SupplierSocialAccount,
  4909. x.SupplierTypeId,
  4910. }).ToList());
  4911. return Ok(jw);
  4912. }
  4913. /// <summary>
  4914. /// 团组增减款项 OTA匹配
  4915. /// </summary>
  4916. /// <param name="file"></param>
  4917. /// <returns></returns>
  4918. [HttpPost]
  4919. public async Task<IActionResult> DecreasePaymentsOTAMate(IFormFile file)
  4920. {
  4921. if (file.Length < 1) return Ok(JsonView(false, "请上传文件!"));
  4922. string fileName = file.FileName;
  4923. if (!fileName.EndsWith(".xlsx") && !fileName.EndsWith(".xls"))
  4924. {
  4925. return Ok(JsonView(false, "请上传Excel文件!"));
  4926. }
  4927. //D:\FTP\File\OA2023\Office\GrpFile\团组增减款项相关文件\团组其他款项(OTA)
  4928. var path = @$"{AppSettingsHelper.Get("GrpFileBasePath")}团组增减款项相关文件/团组其他款项(OTA)";
  4929. if (!Directory.Exists(path))
  4930. {
  4931. Directory.CreateDirectory(path);
  4932. }
  4933. var filePath = @$"{path}/{fileName}";
  4934. //保存文件
  4935. using (FileStream fs = System.IO.File.Create(filePath))
  4936. {
  4937. file.CopyTo(fs);
  4938. fs.Flush();
  4939. }
  4940. if (!System.IO.File.Exists(filePath)) return Ok(JsonView(false, "文件不存在!"));
  4941. //读取ExcelFile
  4942. DataTable dt = ConvertExcelToDataTable(filePath);
  4943. if (dt == null) return Ok(JsonView(false, $"您上传的Excel工作表没有内容,请检查!!!"));
  4944. dt.TableName = "TB";
  4945. //修改table列名
  4946. dt.Columns[0].ColumnName = "OrderNo"; // 订单号
  4947. dt.Columns[1].ColumnName = "OTAOrderNo"; // OTA订单号
  4948. dt.Columns[2].ColumnName = "PackageName"; // 套餐名
  4949. dt.Columns[3].ColumnName = "IsPay"; // 是否支付
  4950. dt.Columns[4].ColumnName = "IsShipments"; // 是否发货
  4951. dt.Columns[5].ColumnName = "IsSendBack"; // 是否寄回
  4952. dt.Columns[6].ColumnName = "OpUser"; // 使用人信息
  4953. dt.Columns[7].ColumnName = "OrderTime"; // 下单时间
  4954. dt.Columns[8].ColumnName = "UseTime"; // 使用时间
  4955. dt.Columns[9].ColumnName = "Quantity"; // 台数
  4956. dt.Columns[10].ColumnName = "Days"; // 租赁天数
  4957. dt.Columns[11].ColumnName = "QuantityShipped";// 发货数量
  4958. dt.Columns[12].ColumnName = "TotalPrice"; // 总金额
  4959. dt.Columns[13].ColumnName = "GroupName"; // 团组名称
  4960. dt.Columns[14].ColumnName = "OATotalPrice"; // OA金额
  4961. var otaOrderNos = new List<string>();
  4962. foreach (DataRow item in dt.Rows)
  4963. {
  4964. otaOrderNos.Add(item["OTAOrderNo"].ToString());
  4965. }
  4966. var oaDatas = await _sqlSugar.Queryable<Grp_DecreasePayments>()
  4967. .LeftJoin<Grp_DelegationInfo>((dp, di) => dp.DiId == di.Id)
  4968. .Where((dp, di) => dp.IsDel == 0 && dp.PriceName.Contains("wifi") || otaOrderNos.Contains(dp.OTAOrderNo))
  4969. .Select((dp, di) => new
  4970. {
  4971. dp.PriceName,
  4972. dp.OTAOrderNo,
  4973. dp.FeeTotal,
  4974. di.TeamName,
  4975. })
  4976. .ToListAsync();
  4977. foreach (DataRow item in dt.Rows)
  4978. {
  4979. var otaOrderNo = item["OTAOrderNo"].ToString();
  4980. var oaData = oaDatas.Find(x => !string.IsNullOrEmpty(x.OTAOrderNo) && x.OTAOrderNo.Contains(otaOrderNo));
  4981. if (oaData == null) continue;
  4982. item["GroupName"] = oaData.TeamName;
  4983. item["OATotalPrice"] = oaData.FeeTotal.ToString("#0.00");
  4984. }
  4985. string fileName1 = $"OTA_WIFI费用{DateTime.Now:yyyyMMddHHmmss}.xls";
  4986. var pairs = new Dictionary<string, object>();
  4987. var datas = new List<DataTable>
  4988. {
  4989. dt
  4990. };
  4991. url = AsposeHelper.ExpertExcelToModel("WIFI费用清单-模板.xlsx", $"GrpFile/团组增减款项相关文件/团组其他款项(OTA)", fileName1, pairs, datas);
  4992. return Ok(JsonView(true, "操作成功", new { url }));
  4993. }
  4994. #region
  4995. private static DataTable ConvertExcelToDataTable(string excelFilePath)
  4996. {
  4997. // 创建Workbook对象
  4998. var workbook = new Workbook(excelFilePath);
  4999. // 获取第一个工作表
  5000. var worksheet = workbook.Worksheets[0];
  5001. // 将工作表转换为DataTable
  5002. DataTable dataTable = worksheet.Cells.ExportDataTable(1, 0, worksheet.Cells.MaxDataRow + 1, worksheet.Cells.MaxDataColumn + 1);
  5003. return dataTable;
  5004. }
  5005. #endregion
  5006. /// <summary>
  5007. /// 世运会数据
  5008. /// </summary>
  5009. /// <returns></returns>
  5010. [HttpGet]
  5011. public IActionResult WorldGamesData()
  5012. {
  5013. var setData = _sqlSugar.Queryable<Grp_GamesBudgetMaster>().Where(x => x.IsDel == 0).ToList();
  5014. var groupMenu = setData.GroupBy(x => x.T0);
  5015. var resultArr = new List<DecreasePaymentsWorldGamesDataView>();
  5016. foreach (var item in groupMenu)
  5017. {
  5018. resultArr.Add(new DecreasePaymentsWorldGamesDataView
  5019. {
  5020. Data = new SetDataView
  5021. {
  5022. Name = item.Key
  5023. },
  5024. Child = item.Select(x => x.CalculationContent).ToList() ?? new List<string>()
  5025. });
  5026. }
  5027. return Ok(JsonView(true, "success", resultArr));
  5028. }
  5029. #endregion
  5030. #region 文件上传、删除
  5031. /// <summary>
  5032. /// region 文件上传 可以带参数
  5033. /// </summary>
  5034. /// <param name="file"></param>
  5035. /// <returns></returns>
  5036. [HttpPost]
  5037. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5038. public async Task<IActionResult> UploadProject(IFormFile file)
  5039. {
  5040. //var TypeName = Request.Headers["TypeName"].ToString();
  5041. //if (file == null) return Ok(JsonView(false, "文件不存在!"));
  5042. //var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  5043. ////文件名称
  5044. //string projectFileName = file.FileName;
  5045. ////上传的文件的路径
  5046. //string filePath = $"{fileDir}/{projectFileName}";
  5047. //if (TypeName == "A")//A代表团组增减款项
  5048. //{
  5049. // filePath = fileDir + $@"\团组增减款项相关文件";
  5050. // if (!Directory.Exists(filePath))
  5051. // {
  5052. // Directory.CreateDirectory(filePath);
  5053. // }
  5054. // //上传的文件的路径
  5055. // filePath += $@"\{projectFileName}";
  5056. //}
  5057. //else if (TypeName == "B")//B代表商邀相关文件
  5058. //{
  5059. // //上传的文件的路径
  5060. // filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  5061. // if (!Directory.Exists(filePath))
  5062. // {
  5063. // Directory.CreateDirectory(filePath);
  5064. // }
  5065. // //上传的文件的路径
  5066. // filePath = $@"\{projectFileName}";
  5067. //}
  5068. //try
  5069. //{
  5070. // using (FileStream fs = System.IO.File.Create(filePath))
  5071. // {
  5072. // file.CopyTo(fs);
  5073. // fs.Flush();
  5074. // }
  5075. //}
  5076. //catch (Exception ex)
  5077. //{
  5078. // return Ok(JsonView(false, $"文件上传失败! Error:{ex.Message}"));
  5079. //}
  5080. //return Ok(JsonView(true, "上传成功!", projectFileName));
  5081. try
  5082. {
  5083. var TypeName = Request.Headers["TypeName"].ToString();
  5084. if (file != null)
  5085. {
  5086. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  5087. //文件名称
  5088. string projectFileName = file.FileName;
  5089. //上传的文件的路径
  5090. string filePath = $"{fileDir}/{projectFileName}";
  5091. if (TypeName == "A")//A代表团组增减款项
  5092. {
  5093. if (!Directory.Exists(fileDir))
  5094. {
  5095. Directory.CreateDirectory(fileDir);
  5096. }
  5097. //上传的文件的路径
  5098. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  5099. }
  5100. else if (TypeName == "B")//B代表商邀相关文件
  5101. {
  5102. if (!Directory.Exists(fileDir))
  5103. {
  5104. Directory.CreateDirectory(fileDir);
  5105. }
  5106. //上传的文件的路径
  5107. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  5108. }
  5109. using (FileStream fs = System.IO.File.Create(filePath))
  5110. {
  5111. file.CopyTo(fs);
  5112. fs.Flush();
  5113. }
  5114. return Ok(JsonView(true, "上传成功!", projectFileName));
  5115. }
  5116. else
  5117. {
  5118. return Ok(JsonView(false, "上传失败!"));
  5119. }
  5120. }
  5121. catch (Exception ex)
  5122. {
  5123. return Ok(JsonView(false, ex.Message));
  5124. }
  5125. }
  5126. /// <summary>
  5127. /// 删除指定文件
  5128. /// </summary>
  5129. /// <param name="dto"></param>
  5130. /// <returns></returns>
  5131. [HttpPost]
  5132. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5133. public async Task<IActionResult> DelFile(DelFileDto dto)
  5134. {
  5135. try
  5136. {
  5137. var TypeName = Request.Headers["TypeName"].ToString();
  5138. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  5139. string filePath = "";
  5140. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  5141. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  5142. int id = 0;
  5143. if (TypeName == "A")
  5144. {
  5145. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  5146. // 删除该文件
  5147. System.IO.File.Delete(filePath);
  5148. id = await _sqlSugar.Updateable<Grp_DecreasePayments>()
  5149. .Where(a => a.Id == dto.Id)
  5150. .SetColumns(a => new Grp_DecreasePayments { FilePath = "" })
  5151. .ExecuteCommandAsync();
  5152. }
  5153. else if (TypeName == "B")
  5154. {
  5155. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  5156. // 删除该文件
  5157. System.IO.File.Delete(filePath);
  5158. var info = await _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.Id == dto.Id && x.IsDel == 0).FirstAsync();
  5159. if (info != null)
  5160. {
  5161. string[] files = Array.Empty<string>();
  5162. if (!string.IsNullOrEmpty(info.Attachment))
  5163. {
  5164. try
  5165. {
  5166. files = JsonConvert.DeserializeObject<string[]>(info.Attachment);
  5167. }
  5168. catch (Exception)
  5169. {
  5170. files = new List<string>() { info.Attachment }.ToArray();
  5171. }
  5172. }
  5173. if (files.Length > 0)
  5174. {
  5175. var files1 = files.Where(x => !x.Equals(dto.fileName)).ToArray();
  5176. string filePath2 = string.Empty;
  5177. if (files1.Length > 0)
  5178. {
  5179. filePath2 = JsonConvert.SerializeObject(files1);
  5180. }
  5181. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  5182. .Where(a => a.Id == dto.Id)
  5183. .SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = filePath2 })
  5184. .ExecuteCommandAsync();
  5185. }
  5186. }
  5187. }
  5188. if (id != 0)
  5189. {
  5190. return Ok(JsonView(true, "成功!"));
  5191. }
  5192. else
  5193. {
  5194. return Ok(JsonView(false, "失败!"));
  5195. }
  5196. }
  5197. catch (Exception ex)
  5198. {
  5199. return Ok(JsonView(false, "程序错误!"));
  5200. throw;
  5201. }
  5202. }
  5203. /// <summary>
  5204. /// 文件上传多个文件 可以带参数
  5205. /// </summary>
  5206. /// <param name="files"></param>
  5207. /// <returns></returns>
  5208. [HttpPost]
  5209. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5210. public async Task<IActionResult> UploadProjects(IFormFile[] files)
  5211. {
  5212. try
  5213. {
  5214. var TypeName = Request.Headers["TypeName"].ToString();
  5215. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  5216. if (files.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  5217. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  5218. var filePahts = new List<string>();
  5219. foreach (var file in files)
  5220. {
  5221. //文件名称
  5222. string projectFileName = file.FileName;
  5223. //上传的文件的路径
  5224. string filePath = $"{fileDir}/{projectFileName}";
  5225. if (TypeName == "A")//A代表团组增减款项
  5226. {
  5227. if (!Directory.Exists(fileDir))
  5228. {
  5229. Directory.CreateDirectory(fileDir);
  5230. }
  5231. //上传的文件的路径
  5232. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  5233. }
  5234. else if (TypeName == "B")//B代表商邀相关文件
  5235. {
  5236. if (!Directory.Exists(fileDir))
  5237. {
  5238. Directory.CreateDirectory(fileDir);
  5239. }
  5240. //上传的文件的路径
  5241. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  5242. }
  5243. using (FileStream fs = System.IO.File.Create(filePath))
  5244. {
  5245. file.CopyTo(fs);
  5246. fs.Flush();
  5247. }
  5248. filePahts.Add(projectFileName);
  5249. }
  5250. return Ok(JsonView(true, "上传成功!", filePahts));
  5251. }
  5252. catch (Exception ex)
  5253. {
  5254. return Ok(JsonView(false, ex.Message));
  5255. }
  5256. }
  5257. #endregion
  5258. #region 商邀费用录入
  5259. /// <summary>
  5260. /// 根据团组Id查询商邀费用列表
  5261. /// </summary>
  5262. /// <param name="dto"></param>
  5263. /// <returns></returns>
  5264. [HttpPost]
  5265. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5266. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  5267. {
  5268. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  5269. if (groupData.Code != 0)
  5270. {
  5271. return Ok(JsonView(false, groupData.Msg));
  5272. }
  5273. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5274. }
  5275. /// <summary>
  5276. /// 商邀费用列表
  5277. /// 下载文件
  5278. /// </summary>
  5279. /// <param name="id"></param>
  5280. /// <returns></returns>
  5281. [HttpGet("{id}")]
  5282. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5283. public async Task<IActionResult> InvitationOfficialActivitiesListDownFile(int id)
  5284. {
  5285. if (id < 1) return Ok(JsonView(false, "请传入有效的Id!"));
  5286. var info = await _InvitationOfficialActivitiesRep.Query(x => x.Id == id).FirstAsync();
  5287. if (info == null) return Ok(JsonView(false, "数据不存在!"));
  5288. if (string.IsNullOrEmpty(info.Attachment)) return Ok(JsonView(false, "文件不存在!"));
  5289. var filePaths = new List<string>();
  5290. var filePathBase = @$"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/";
  5291. try
  5292. {
  5293. filePaths = JsonConvert.DeserializeObject<List<string>>(info.Attachment);
  5294. }
  5295. catch (Exception ex)
  5296. {
  5297. filePaths.Add(info.Attachment);
  5298. }
  5299. if (filePaths != null && filePaths.Count < 1) return Ok(JsonView(false, "文件不存在!"));
  5300. for (int i = 0; i < filePaths.Count; i++)
  5301. {
  5302. filePaths[i] = $"{filePathBase}{filePaths[i]}";
  5303. }
  5304. var zipFilePathGuid = $"{Guid.NewGuid()}.zip";
  5305. var zipFilePath = $"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{zipFilePathGuid}";
  5306. using (var zipFileStream = new FileStream(zipFilePath, FileMode.Create))
  5307. {
  5308. using (var zipArchive = new ZipArchive(zipFileStream, ZipArchiveMode.Create))
  5309. {
  5310. foreach (string filePath in filePaths)
  5311. {
  5312. if (System.IO.File.Exists(filePath))
  5313. {
  5314. // 获取文件名
  5315. string fileName = Path.GetFileName(filePath);
  5316. // 将文件添加到ZIP归档中
  5317. zipArchive.CreateEntryFromFile(filePath, fileName);
  5318. }
  5319. }
  5320. }
  5321. }
  5322. return Ok(JsonView(new { url = @$"{AppSettingsHelper.Get("OfficeBaseUrl")}{AppSettingsHelper.Get("GrpFileFtpPath")}/商邀相关文件/{zipFilePathGuid}" }));
  5323. }
  5324. /// <summary>
  5325. /// 商邀费用 Info Page 基础数据源
  5326. /// </summary>
  5327. /// <returns></returns>
  5328. [HttpPost]
  5329. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5330. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  5331. {
  5332. try
  5333. {
  5334. Result groupData = await _InvitationOfficialActivitiesRep.InitBasicData();
  5335. if (groupData.Code != 0)
  5336. {
  5337. return Ok(JsonView(false, groupData.Msg));
  5338. }
  5339. return Ok(JsonView(true, "操作成功", groupData.Data));
  5340. }
  5341. catch (Exception ex)
  5342. {
  5343. return Ok(JsonView(false, ex.Message));
  5344. throw;
  5345. }
  5346. }
  5347. /// <summary>
  5348. /// 根据商邀费用ID查询C表和商邀费用数据
  5349. /// </summary>
  5350. /// <param name="dto"></param>
  5351. /// <returns></returns>
  5352. [HttpPost]
  5353. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5354. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  5355. {
  5356. try
  5357. {
  5358. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  5359. if (groupData.Code != 0)
  5360. {
  5361. return Ok(JsonView(false, groupData.Msg));
  5362. }
  5363. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5364. }
  5365. catch (Exception ex)
  5366. {
  5367. return Ok(JsonView(false, ex.Message));
  5368. throw;
  5369. }
  5370. }
  5371. /// <summary>
  5372. /// 商邀费用录入操作(Status:1.新增,2.修改)
  5373. /// </summary>
  5374. /// <param name="dto"></param>
  5375. /// <returns></returns>
  5376. [HttpPost]
  5377. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5378. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  5379. {
  5380. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  5381. if (groupData.Code != 0)
  5382. {
  5383. return Ok(JsonView(false, groupData.Msg));
  5384. }
  5385. #region 应用推送
  5386. try
  5387. {
  5388. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  5389. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  5390. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  5391. //2024-10-21 新增LZ UID
  5392. var userIds = new List<int>() { 21 };
  5393. string title = $"系统通知";
  5394. string content = "";
  5395. var diId = dto.DiId;
  5396. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  5397. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  5398. if (dto.Status == 1) content = $"[新增-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  5399. else if (dto.Status == 2) content = $"[更新-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  5400. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  5401. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "81" };
  5402. await APNsTools.iOS_PushNotifications1("051", $"商邀费用审核", "", content, true, "ExpenseAuditWebView", h5);
  5403. }
  5404. catch (Exception ex)
  5405. {
  5406. }
  5407. #endregion
  5408. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5409. }
  5410. /// <summary>
  5411. /// 商邀删除
  5412. /// </summary>
  5413. /// <param name="dto"></param>
  5414. /// <returns></returns>
  5415. [HttpPost]
  5416. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5417. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  5418. {
  5419. try
  5420. {
  5421. _sqlSugar.BeginTran();
  5422. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  5423. .SetColumns(it => new Grp_InvitationOfficialActivities()
  5424. {
  5425. IsDel = 1,
  5426. DeleteUserId = dto.DeleteUserId,
  5427. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5428. })
  5429. .Where(it => it.Id == dto.Id)
  5430. .ExecuteCommand();
  5431. if (res1 > 0)
  5432. {
  5433. int _diId = 0;
  5434. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  5435. if (_ioaInfo != null)
  5436. {
  5437. _diId = _ioaInfo.DiId;
  5438. }
  5439. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  5440. .SetColumns(a => new Grp_CreditCardPayment()
  5441. {
  5442. IsDel = 1,
  5443. DeleteUserId = dto.DeleteUserId,
  5444. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5445. })
  5446. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  5447. .ExecuteCommand();
  5448. if (res2 > 0)
  5449. {
  5450. _sqlSugar.CommitTran();
  5451. return Ok(JsonView(true, "删除成功!"));
  5452. }
  5453. }
  5454. _sqlSugar.RollbackTran();
  5455. return Ok(JsonView(false, "删除失败"));
  5456. }
  5457. catch (Exception ex)
  5458. {
  5459. _sqlSugar.RollbackTran();
  5460. return Ok(JsonView(false, ex.Message));
  5461. }
  5462. }
  5463. #endregion
  5464. #region 票据上传
  5465. /// <summary>
  5466. /// 团组模块文件上传
  5467. /// </summary>
  5468. /// <param name="dto"></param>
  5469. /// <returns></returns>
  5470. [HttpPost]
  5471. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  5472. {
  5473. var jw = JsonView(false);
  5474. long M = 1024 * 1024;
  5475. if (dto.Files == null || dto.Files.Count == 0)
  5476. {
  5477. jw.Msg = "无文件信息!";
  5478. return Ok(jw);
  5479. }
  5480. if (dto.Files.Sum(x => x.Length) > 20 * M)
  5481. {
  5482. jw.Msg = "文件大小超过20M!";
  5483. return Ok(jw);
  5484. }
  5485. //var nameSp = dto.File.FileName.Split(".");
  5486. //if (nameSp.Length < 2)
  5487. //{
  5488. // jw.Msg = "拓展名称有误!";
  5489. // return Ok(jw);
  5490. //}
  5491. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  5492. //if (!existsName.Contains(nameSp[1].ToUpper()))
  5493. //{
  5494. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  5495. // return Ok(jw);
  5496. //}
  5497. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  5498. if (Ctable == null)
  5499. {
  5500. jw.Msg = "Ctable指向有误!";
  5501. return Ok(jw);
  5502. }
  5503. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  5504. if (groupInfo == null)
  5505. {
  5506. jw.Msg = "团组信息不存在!";
  5507. return Ok(jw);
  5508. }
  5509. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  5510. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5511. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  5512. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5513. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  5514. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  5515. try
  5516. {
  5517. if (!Directory.Exists(fileBase))
  5518. {
  5519. Directory.CreateDirectory(fileBase);
  5520. }
  5521. var saveArr = new List<Grp_GroupModelFile>();
  5522. foreach (var fileStream in dto.Files)
  5523. {
  5524. var saveFilePath = fileBase + "\\" + fileStream.FileName;
  5525. var file = new Grp_GroupModelFile()
  5526. {
  5527. Cid = dto.Cid,
  5528. CreateTime = DateTime.Now,
  5529. CreateUserId = dto.Userid,
  5530. Ctable = dto.Ctable,
  5531. Diid = dto.Diid,
  5532. IsDel = 0,
  5533. FilePath = saveFilePath,
  5534. FileName = fileStream.FileName
  5535. };
  5536. using (FileStream fs = System.IO.File.Create(saveFilePath))
  5537. {
  5538. fileStream.CopyTo(fs);
  5539. fs.Flush();
  5540. }
  5541. saveArr.Add(file);
  5542. }
  5543. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  5544. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  5545. jw = JsonView(true, "保存成功!", new
  5546. {
  5547. count = addResult,
  5548. filesName = saveArr.Select(x => x.FileName)
  5549. });
  5550. }
  5551. catch (Exception ex)
  5552. {
  5553. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  5554. {
  5555. count = 0,
  5556. filesName = Array.Empty<string>(),
  5557. });
  5558. }
  5559. return Ok(jw);
  5560. }
  5561. /// <summary>
  5562. /// 查询各模块已保存文件
  5563. /// </summary>
  5564. /// <param name="dto"></param>
  5565. /// <returns></returns>
  5566. [HttpPost]
  5567. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  5568. {
  5569. var expression = Expressionable.Create<Grp_GroupModelFile>()
  5570. .AndIF(dto.UserId != -1, x => x.CreateUserId == dto.UserId);
  5571. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x => x.Id).ToList();
  5572. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  5573. {
  5574. expression = Expressionable.Create<Grp_GroupModelFile>()
  5575. .And(x => visaIds.Contains(x.CreateUserId));
  5576. }
  5577. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  5578. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  5579. .Where(expression.ToExpression())
  5580. .ToList();
  5581. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  5582. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  5583. {
  5584. x.FileName,
  5585. x.Id,
  5586. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  5587. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  5588. })));
  5589. }
  5590. /// <summary>
  5591. /// 下载该团组下的所有文件
  5592. /// </summary>
  5593. /// <param name="dto"></param>
  5594. /// <returns></returns>
  5595. [HttpPost]
  5596. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  5597. {
  5598. var jw = JsonView(false);
  5599. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  5600. if (groupInfo == null)
  5601. {
  5602. jw.Msg = "团组信息不存在!";
  5603. return Ok(jw);
  5604. }
  5605. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  5606. var isModule = Convert.ToBoolean(dto.isModule);
  5607. var Zips = new Dictionary<string, Stream>();
  5608. var io = new IOOperatorHelper();
  5609. if (isModule)
  5610. {
  5611. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  5612. foreach (var moduleArr in moduleGroup)
  5613. {
  5614. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  5615. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  5616. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5617. var chiZips = new Dictionary<string, Stream>();
  5618. foreach (var item in moduleArr)
  5619. {
  5620. if (System.IO.File.Exists(item.FilePath))
  5621. {
  5622. using (var fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  5623. {
  5624. byte[] bytes = new byte[fileStream.Length];
  5625. fileStream.Read(bytes, 0, bytes.Length);
  5626. fileStream.Close();
  5627. Stream stream = new MemoryStream(bytes);
  5628. chiZips.Add(item.FileName, stream);
  5629. }
  5630. }
  5631. }
  5632. if (chiZips.Count > 0)
  5633. {
  5634. var byts = io.ConvertZipStream(chiZips);
  5635. Stream stream = new MemoryStream(byts);
  5636. Zips.Add(key.Name + "_.zip", stream);
  5637. }
  5638. }
  5639. }
  5640. else
  5641. {
  5642. foreach (var item in dbQuery)
  5643. {
  5644. using (var fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  5645. {
  5646. byte[] bytes = new byte[fileStream.Length];
  5647. fileStream.Read(bytes, 0, bytes.Length);
  5648. fileStream.Close();
  5649. var stream = new MemoryStream(bytes);
  5650. while (Zips.ContainsKey(item.FileName))
  5651. {
  5652. item.FileName = new Random().Next(100) + "_" + item.FileName;
  5653. }
  5654. Zips.Add(item.FileName, stream);
  5655. }
  5656. }
  5657. }
  5658. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  5659. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5660. if (Zips.Count > 0)
  5661. {
  5662. var byts = io.ConvertZipStream(Zips);
  5663. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  5664. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  5665. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  5666. }
  5667. else
  5668. {
  5669. jw.Msg = "暂无生成文件!";
  5670. }
  5671. return Ok(jw);
  5672. }
  5673. /// <summary>
  5674. /// 下载该团组下此模块的所有文件
  5675. /// </summary>
  5676. /// <param name="dto"></param>
  5677. /// <returns></returns>
  5678. [HttpPost]
  5679. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  5680. {
  5681. var jw = JsonView(false);
  5682. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  5683. if (groupInfo == null)
  5684. {
  5685. jw.Msg = "团组信息不存在!";
  5686. return Ok(jw);
  5687. }
  5688. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  5689. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  5690. && x.IsDel == 0);
  5691. if (key == null)
  5692. {
  5693. jw.Msg = "Ctable指向错误!";
  5694. return Ok(jw);
  5695. }
  5696. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  5697. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5698. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  5699. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5700. var io = new IOOperatorHelper();
  5701. var Zips = new Dictionary<string, Stream>();
  5702. foreach (var item in dbQuery)
  5703. {
  5704. if (System.IO.File.Exists(item.FilePath))
  5705. {
  5706. using (var fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  5707. {
  5708. byte[] bytes = new byte[fileStream.Length];
  5709. fileStream.Read(bytes, 0, bytes.Length);
  5710. fileStream.Close();
  5711. var stream = new MemoryStream(bytes);
  5712. while (Zips.ContainsKey(item.FileName))
  5713. {
  5714. item.FileName = new Random().Next(100) + "_" + item.FileName;
  5715. }
  5716. Zips.Add(item.FileName, stream);
  5717. }
  5718. }
  5719. }
  5720. if (Zips.Count > 0)
  5721. {
  5722. var byts = io.ConvertZipStream(Zips);
  5723. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  5724. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  5725. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  5726. }
  5727. else
  5728. {
  5729. jw.Msg = "暂无生成文件!";
  5730. }
  5731. return Ok(jw);
  5732. }
  5733. /// <summary>
  5734. /// 删除该团组下的指定文件
  5735. /// </summary>
  5736. /// <param name="dto"></param>
  5737. /// <returns></returns>
  5738. [HttpPost]
  5739. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  5740. {
  5741. var jw = JsonView(false);
  5742. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  5743. if (sing == null)
  5744. {
  5745. jw.Msg = "暂无";
  5746. return Ok(jw);
  5747. }
  5748. if (System.IO.File.Exists(sing.FilePath))
  5749. {
  5750. try
  5751. {
  5752. System.IO.File.Delete(sing.FilePath);
  5753. }
  5754. catch (Exception ex)
  5755. {
  5756. jw.Msg = "删除失败!" + ex.Message;
  5757. return Ok(jw);
  5758. }
  5759. }
  5760. sing.IsDel = 1;
  5761. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  5762. sing.DeleteUserId = dto.UserId;
  5763. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  5764. jw = JsonView(true, "删除成功!");
  5765. return Ok(jw);
  5766. }
  5767. #endregion
  5768. #region 共享文件上传
  5769. /// <summary>
  5770. /// 共享文件数据初始化
  5771. /// </summary>
  5772. /// <returns></returns>
  5773. [HttpGet]
  5774. public async Task<IActionResult> SharedFileInit(int userid, int portType)
  5775. {
  5776. var marketingDepartmentIds = new List<int> { 6, 26, 27, 28 };
  5777. var isMarketingDepartment = _sqlSugar.Queryable<Sys_Users>()
  5778. .Where(x => x.IsDel == 0 && marketingDepartmentIds.Contains(x.DepId))
  5779. .Select(x => x.Id)
  5780. .ToList()
  5781. .Contains(userid);
  5782. var dropDownType = _sqlSugar.Queryable<Sys_SetData>()
  5783. .Where(x => x.STid == 111 && x.IsDel == 0)
  5784. .Select(x => new
  5785. {
  5786. x.Name,
  5787. x.Id,
  5788. }).ToList();
  5789. if (isMarketingDepartment)
  5790. {
  5791. dropDownType = dropDownType.Where(x => x.Id == 1412).ToList();
  5792. }
  5793. if (portType == 1)
  5794. {
  5795. var provCityDatas = await _groupRepository.ProvinceCityBasicSource();
  5796. var dropDownGroupList = _sqlSugar.Queryable<Grp_DelegationInfo>()
  5797. .Where(x => x.IsDel == 0)
  5798. .OrderByDescending(x => x.VisitDate)
  5799. .Select(x => new
  5800. {
  5801. x.TeamName,
  5802. x.Id,
  5803. x.CityId,
  5804. })
  5805. .ToList()
  5806. .Select(x =>
  5807. {
  5808. var provinceId = x.CityId;
  5809. var isDefualtVal = true;
  5810. if (provinceId > 0)
  5811. {
  5812. var parentId = _groupRepository.FindParentIdByChildId(provCityDatas, provinceId);
  5813. if (parentId != null)
  5814. {
  5815. isDefualtVal = false;
  5816. provinceId = (int)parentId;
  5817. }
  5818. }
  5819. if (isDefualtVal)
  5820. {
  5821. provinceId = 122; //默认四川
  5822. }
  5823. return new
  5824. {
  5825. x.TeamName,
  5826. x.Id,
  5827. provinceId,
  5828. };
  5829. })
  5830. .ToList();
  5831. return Ok(JsonView(true, "SUCCESS!", new
  5832. {
  5833. dropDownType,
  5834. dropDownGroupList,
  5835. isMarketingDepartment
  5836. }));
  5837. }
  5838. else if (portType == 2 || portType == 3)
  5839. {
  5840. return Ok(JsonView(true, "SUCCESS!", new
  5841. {
  5842. dropDownType,
  5843. isMarketingDepartment
  5844. }));
  5845. }
  5846. else
  5847. {
  5848. return Ok(JsonView(false, "portType有误!"));
  5849. }
  5850. }
  5851. /// <summary>
  5852. /// 共享文件上传
  5853. /// </summary>
  5854. /// <param name="dto"></param>
  5855. /// <returns></returns>
  5856. [HttpPost]
  5857. public IActionResult SharedFileUpload([FromForm] SharedFileUploadDto dto)
  5858. {
  5859. var isGroup = new List<int> { 1412 };
  5860. if (isGroup.Contains(dto.FileType) && dto.Diid < 1)
  5861. {
  5862. return Ok(JsonView(false, "该文件需要关联团组!"));
  5863. }
  5864. if (dto.Files == null || dto.Files.Count == 0)
  5865. {
  5866. return Ok(JsonView(false, "无文件信息!"));
  5867. }
  5868. if (dto.Files.Sum(x => x.Length) > 20 * 1024 * 1024)
  5869. {
  5870. return Ok(JsonView(false, "文件大小超过20M!"));
  5871. }
  5872. if (dto.Userid < 1)
  5873. {
  5874. return Ok(JsonView(false, "请传入有效的Userid!"));
  5875. }
  5876. var jobInfo = _sqlSugar.Queryable<Sys_Users, Sys_JobPost>((u, j) => u.JobPostId == j.Id && j.IsDel == 0)
  5877. .Where(u => u.IsDel == 0 && u.Id == dto.Userid)
  5878. .Select((u, j) => new
  5879. {
  5880. u.CnName,
  5881. UserId = u.Id,
  5882. j.JobName,
  5883. })
  5884. .First();
  5885. if (jobInfo == null)
  5886. {
  5887. return Ok(JsonView(false, "请传入有效的Userid!"));
  5888. }
  5889. var commonFileExtensions = new List<string>
  5890. {
  5891. // 文本文件
  5892. ".txt", ".doc", ".docx", ".odt", ".pdf", ".rtf", ".md", ".log",
  5893. // 图片文件
  5894. ".jpg", ".jpeg", ".png", ".gif", ".bmp", ".tiff", ".svg",
  5895. // 视频文件
  5896. ".mp4", ".avi", ".mov", ".mkv", ".wmv", ".flv", ".mpg", ".mpeg",
  5897. // 音频文件
  5898. ".mp3", ".wav", ".ogg", ".aac", ".flac",
  5899. // 压缩文件
  5900. ".zip", ".rar", ".7z", ".tar", ".gz", ".bz2",
  5901. // 数据文件
  5902. ".csv", ".xls", ".xlsx", ".json", ".xml", ".yaml", ".ini",
  5903. };
  5904. try
  5905. {
  5906. var setting = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1416);
  5907. var settingExtend = JsonConvert.DeserializeObject<List<string>>(setting.Remark);
  5908. commonFileExtensions.AddRange(settingExtend);
  5909. }
  5910. catch (Exception)
  5911. { }
  5912. var setdata = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.FileType);
  5913. if (setdata == null)
  5914. {
  5915. return Ok(JsonView(false, "请传入有效的FileType!"));
  5916. }
  5917. var insertList = new List<Grp_GroupShareFile>();
  5918. string winPath = AppSettingsHelper.Get("ShareFileBasePath") + $"{setdata.Name}/";
  5919. if (!Directory.Exists(winPath))
  5920. {
  5921. Directory.CreateDirectory(winPath);
  5922. }
  5923. foreach (var item in dto.Files)
  5924. {
  5925. var houzui = Path.GetExtension(item.FileName);
  5926. if (!commonFileExtensions.Contains(houzui))
  5927. {
  5928. return Ok(JsonView(false, "未知后缀名称!"));
  5929. }
  5930. var fileName = $"{jobInfo.JobName}-{jobInfo.CnName}-{item.FileName}";
  5931. var saveFilePath = winPath + fileName;
  5932. using (FileStream fs = System.IO.File.Create(saveFilePath))
  5933. {
  5934. item.CopyTo(fs);
  5935. fs.Flush();
  5936. }
  5937. var fileDetail = new Grp_GroupShareFile()
  5938. {
  5939. CreateUserId = dto.Userid,
  5940. CreateTime = DateTime.Now,
  5941. UploadJob = jobInfo.JobName,
  5942. FileName = fileName,
  5943. FileType = dto.FileType,
  5944. Diid = dto.Diid,
  5945. FilePath = winPath + fileName,
  5946. };
  5947. insertList.Add(fileDetail);
  5948. }
  5949. _sqlSugar.Insertable<Grp_GroupShareFile>(insertList).ExecuteCommand();
  5950. return Ok(JsonView(true, "保存成功!"));
  5951. }
  5952. /// <summary>
  5953. /// 查询共享文件列表
  5954. /// </summary>
  5955. /// <param name="dto"></param>
  5956. /// <returns></returns>
  5957. [HttpPost]
  5958. public IActionResult QuerySharedFile(QuerySharedFileDto dto)
  5959. {
  5960. var isGroup = new List<int> { 1412 };
  5961. if (!isGroup.Contains(dto.FileType)) dto.Diid = 0;
  5962. var queryExpression = Expressionable.Create<Grp_GroupShareFile>()
  5963. .And(x => x.Diid == dto.Diid)
  5964. .And(x => x.FileType == dto.FileType)
  5965. .And(x => x.IsDel == 0)
  5966. .AndIF(!dto.FileName.IsNullOrWhiteSpace(), x => x.FileName.Contains(dto.FileName))
  5967. .AndIF(DateTime.TryParse(dto.StartTime, out DateTime Start), x => x.CreateTime >= Start)
  5968. .AndIF(DateTime.TryParse(dto.EndTime, out DateTime End), x => x.CreateTime <= End);
  5969. int totalCount = 0;
  5970. var dbQuery = _sqlSugar.Queryable<Grp_GroupShareFile>()
  5971. .Where(queryExpression.ToExpression())
  5972. .OrderBy(x => x.UploadJob)
  5973. .Select(x => new
  5974. {
  5975. x.Id,
  5976. FilePath = AppSettingsHelper.Get("ShareFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("ShareFileBasePath"), AppSettingsHelper.Get("ShareFileFtpPath")),
  5977. x.FileName,
  5978. x.FileType,
  5979. x.CreateTime,
  5980. })
  5981. .ToPageList(dto.PageIndex, dto.PageSize, ref totalCount);
  5982. return Ok(JsonView(true, "SUCCESS!", new
  5983. {
  5984. FileList = dbQuery,
  5985. dto.PageSize,
  5986. dto.PageIndex,
  5987. totalCount
  5988. }));
  5989. }
  5990. /// <summary>
  5991. /// 删除共享文件模块下的指定文件
  5992. /// </summary>
  5993. /// <param name="dto"></param>
  5994. /// <returns></returns>
  5995. [HttpPost]
  5996. public IActionResult DeleteSharedFile(DeleteGroupFileDto dto)
  5997. {
  5998. var jw = JsonView(false);
  5999. var sing = _sqlSugar.Queryable<Grp_GroupShareFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  6000. if (sing == null)
  6001. {
  6002. jw.Msg = "暂无文件信息!";
  6003. return Ok(jw);
  6004. }
  6005. if (sing.CreateUserId != dto.UserId)
  6006. {
  6007. jw.Msg = "只能删除自己上传的文件!";
  6008. return Ok(jw);
  6009. }
  6010. if (System.IO.File.Exists(sing.FilePath))
  6011. {
  6012. try
  6013. {
  6014. System.IO.File.Delete(sing.FilePath);
  6015. }
  6016. catch (Exception ex)
  6017. {
  6018. jw.Msg = "删除失败!" + ex.Message;
  6019. return Ok(jw);
  6020. }
  6021. }
  6022. sing.IsDel = 1;
  6023. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  6024. sing.DeleteUserId = dto.UserId;
  6025. _sqlSugar.Updateable<Grp_GroupShareFile>(sing).ExecuteCommand();
  6026. jw = JsonView(true, "删除成功!");
  6027. return Ok(jw);
  6028. }
  6029. #endregion
  6030. #region 团组英文资料
  6031. /// <summary>
  6032. /// 查询团组英文所有资料
  6033. /// </summary>
  6034. /// <param name="dto"></param>
  6035. /// <returns></returns>
  6036. [HttpPost]
  6037. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6038. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  6039. {
  6040. try
  6041. {
  6042. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  6043. if (groupData.Code != 0)
  6044. {
  6045. return Ok(JsonView(false, groupData.Msg));
  6046. }
  6047. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6048. }
  6049. catch (Exception ex)
  6050. {
  6051. return Ok(JsonView(false, ex.Message));
  6052. throw;
  6053. }
  6054. }
  6055. /// <summary>
  6056. /// 团组英文资料操作(Status:1.新增,2.修改)
  6057. /// </summary>
  6058. /// <param name="dto"></param>
  6059. /// <returns></returns>
  6060. [HttpPost]
  6061. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6062. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  6063. {
  6064. try
  6065. {
  6066. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  6067. if (groupData.Code != 0)
  6068. {
  6069. return Ok(JsonView(false, groupData.Msg));
  6070. }
  6071. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6072. }
  6073. catch (Exception ex)
  6074. {
  6075. return Ok(JsonView(false, ex.Message));
  6076. throw;
  6077. }
  6078. }
  6079. /// <summary>
  6080. /// 团组英文资料Id查询数据
  6081. /// </summary>
  6082. /// <param name="dto"></param>
  6083. /// <returns></returns>
  6084. [HttpPost]
  6085. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6086. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  6087. {
  6088. try
  6089. {
  6090. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  6091. if (_DelegationEnData != null)
  6092. {
  6093. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  6094. }
  6095. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  6096. }
  6097. catch (Exception ex)
  6098. {
  6099. return Ok(JsonView(false, "程序错误!"));
  6100. throw;
  6101. }
  6102. }
  6103. /// <summary>
  6104. /// 团组英文资料删除
  6105. /// </summary>
  6106. /// <param name="dto"></param>
  6107. /// <returns></returns>
  6108. [HttpPost]
  6109. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6110. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  6111. {
  6112. try
  6113. {
  6114. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  6115. if (!res)
  6116. {
  6117. return Ok(JsonView(false, "删除失败"));
  6118. }
  6119. return Ok(JsonView(true, "删除成功!"));
  6120. }
  6121. catch (Exception ex)
  6122. {
  6123. return Ok(JsonView(false, ex.Message));
  6124. throw;
  6125. }
  6126. }
  6127. #endregion
  6128. #region 导出邀请函
  6129. /// <summary>
  6130. /// 导出邀请函页面初始化
  6131. /// </summary>
  6132. /// <param name="dto"></param>
  6133. /// <returns></returns>
  6134. [HttpPost]
  6135. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6136. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  6137. {
  6138. try
  6139. {
  6140. var grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.VisitStartDate, OrderByType.Desc).ToList();
  6141. var crm_Deles = new List<Crm_DeleClient>();
  6142. if (dto.DiId == 0)
  6143. {
  6144. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  6145. }
  6146. else
  6147. {
  6148. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  6149. }
  6150. return Ok(JsonView(true, "查询成功!", new
  6151. {
  6152. deleClient = crm_Deles,
  6153. delegations = grp_Delegations
  6154. }));
  6155. }
  6156. catch (Exception ex)
  6157. {
  6158. return Ok(JsonView(false, "程序错误!"));
  6159. throw;
  6160. }
  6161. }
  6162. /// <summary>
  6163. /// 导出邀请函
  6164. /// </summary>
  6165. /// <param name="dto"></param>
  6166. /// <returns></returns>
  6167. [HttpPost]
  6168. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6169. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  6170. {
  6171. #region 参数验证
  6172. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  6173. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  6174. #endregion
  6175. try
  6176. {
  6177. var transDic = new Dictionary<string, string>();
  6178. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  6179. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  6180. From Grp_TourClientList tcl
  6181. Left Join
  6182. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  6183. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  6184. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  6185. From Crm_DeleClient dc
  6186. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  6187. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  6188. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  6189. Where dc.IsDel = 0) temp
  6190. On temp.DcId =tcl.ClientId
  6191. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  6192. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  6193. var texts = new List<string>();
  6194. if (datas.Count != 0)
  6195. {
  6196. foreach (TourClientListDetailsView item in datas)
  6197. {
  6198. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  6199. {
  6200. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  6201. }
  6202. else
  6203. {
  6204. string name = item.LastName + item.FirstName;
  6205. texts.Add(name);
  6206. }
  6207. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  6208. {
  6209. if (!transDic.ContainsKey(item.Job))
  6210. {
  6211. texts.Add(item.Job);
  6212. }
  6213. }
  6214. if (!string.IsNullOrEmpty(item.CompanyFullName))
  6215. {
  6216. texts.Add(item.CompanyFullName);
  6217. }
  6218. }
  6219. var transData = await _airTicketResRep.ReTransBatch(texts, "en");
  6220. if (transData.Count > 0)
  6221. {
  6222. foreach (TranslateResult item in transData)
  6223. {
  6224. if (!transDic.ContainsKey(item.Query))
  6225. {
  6226. transDic.Add(item.Query, item.Translation);
  6227. }
  6228. }
  6229. }
  6230. var list = new List<GuestList>();
  6231. foreach (var dele in datas)
  6232. {
  6233. var guestList = new GuestList();
  6234. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  6235. {
  6236. guestList.Name = dele.Pinyin;
  6237. }
  6238. else
  6239. {
  6240. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  6241. guestList.Name = Name;
  6242. }
  6243. if (dele.Sex == 0)
  6244. {
  6245. guestList.Sex = "Male";
  6246. }
  6247. else if (dele.Sex == 1)
  6248. {
  6249. guestList.Sex = "Female";
  6250. }
  6251. guestList.DOB = dele.BirthDay.Replace('-', '.');
  6252. if (!string.IsNullOrEmpty(dele.Job))
  6253. {
  6254. guestList.Job = dele.Job;
  6255. }
  6256. list.Add(guestList);
  6257. }
  6258. //载入模板
  6259. var doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  6260. var builder = new DocumentBuilder(doc);
  6261. //获取word里所有表格
  6262. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6263. //获取所填表格的序数
  6264. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  6265. var rowStart = tableOne.Rows[0]; //获取第1行
  6266. //循环赋值
  6267. for (int i = 0; i < list.Count; i++)
  6268. {
  6269. builder.MoveToCell(0, i + 1, 0, 0);
  6270. builder.Write(list[i].Name.ToString());
  6271. builder.MoveToCell(0, i + 1, 1, 0);
  6272. builder.Write(list[i].Sex.ToString());
  6273. builder.MoveToCell(0, i + 1, 2, 0);
  6274. builder.Write(list[i].DOB.ToString());
  6275. builder.MoveToCell(0, i + 1, 3, 0);
  6276. builder.Write(list[i].Job.ToString());
  6277. }
  6278. //删除多余行
  6279. while (tableOne.Rows.Count > list.Count + 1)
  6280. {
  6281. tableOne.Rows.RemoveAt(list.Count + 1);
  6282. }
  6283. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  6284. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  6285. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  6286. doc.Save(filePath);
  6287. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  6288. return Ok(JsonView(true, "操作成功!", Url));
  6289. }
  6290. else
  6291. {
  6292. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  6293. }
  6294. }
  6295. catch (Exception ex)
  6296. {
  6297. return Ok(JsonView(false, ex.Message));
  6298. throw;
  6299. }
  6300. }
  6301. #endregion
  6302. #region 团组经理模块 出入境费用
  6303. /// <summary>
  6304. /// 团组模块 - 出入境费用 - 省份基础数据源
  6305. /// </summary>
  6306. /// <returns></returns>
  6307. [HttpGet]
  6308. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6309. public async Task<IActionResult> GetEnterExitProvBelongCostDataSource()
  6310. {
  6311. return Ok(JsonView(await _groupRepository.ProvinceBasicSource()));
  6312. }
  6313. /// <summary>
  6314. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  6315. /// </summary>
  6316. /// <param name="dto"></param>
  6317. /// <returns></returns>
  6318. [HttpPost]
  6319. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6320. public async Task<IActionResult> GetEnterExitCostDataSource(EnterExitCostDataSourceDto dto)
  6321. {
  6322. var groupNameData = await _groupRepository.EnterExitCostGroupNameAsync();
  6323. var groupNamFirst = groupNameData.FirstOrDefault();
  6324. //SetDataInfoView
  6325. var dataSource = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  6326. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  6327. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  6328. //验证城市归属并给默认值
  6329. int provinceId = 122;
  6330. if (groupNamFirst != null) provinceId = groupNamFirst.ProvinceId;
  6331. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostRep.FileOwner(provinceId);
  6332. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  6333. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  6334. return Ok(JsonView(true, "查询成功!", new
  6335. {
  6336. GroupNameData = groupNameData,
  6337. CurrencyData = _CurrencyData,
  6338. WordTypeData = wordTypeData,
  6339. ExcelTypeData = excelTypeData,
  6340. CurrencyInit = _currencyInfos,
  6341. ViewPermissionData = viewPermissionData
  6342. }));
  6343. }
  6344. /// <summary>
  6345. /// 团组模块 - 出入境费用 - 文件类型list 跟据省份Id获取
  6346. /// </summary>
  6347. /// <returns></returns>
  6348. [HttpGet("{provinceId}")]
  6349. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6350. public async Task<IActionResult> EnterExitCostFileOwner([FromRoute] int provinceId = 122)
  6351. {
  6352. //验证城市归属并给默认值
  6353. if (provinceId < 1) provinceId = 122;
  6354. /*
  6355. * 122 四川
  6356. * 108 贵州
  6357. * 103 重庆
  6358. * 132 云南
  6359. */
  6360. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostDraftRep.FileOwner(provinceId);
  6361. return Ok(JsonView(true, "查询成功!", new
  6362. {
  6363. WordTypeData = wordTypeData,
  6364. ExcelTypeData = excelTypeData,
  6365. }));
  6366. }
  6367. /// <summary>
  6368. /// 团组模块 - 出入境费用
  6369. /// 实时汇率 tips
  6370. /// 签证费用 tips
  6371. /// 机票费用 tips
  6372. /// </summary>
  6373. /// <returns></returns>
  6374. [HttpPost]
  6375. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6376. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  6377. {
  6378. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  6379. //默认币种显示
  6380. var reteInfos = await GeneralMethod.EnterExitCostLiveRate();
  6381. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.DiId);
  6382. var airData = await GeneralMethod.EntryAndExitTips(dto.DiId);
  6383. return Ok(JsonView(true, "查询成功!", new
  6384. {
  6385. //GroupNameData = groupNameData.Data,
  6386. visaData = visaData.Data,
  6387. airData,
  6388. reteInfos
  6389. }));
  6390. }
  6391. /// <summary>
  6392. /// 团组模块 - 出入境费用 - Info
  6393. /// </summary>
  6394. /// <param name="dto"></param>
  6395. /// <returns></returns>
  6396. [HttpPost]
  6397. //[ApiLog("Grp_EnterExitCost", OperationEnum.Details)]
  6398. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6399. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  6400. {
  6401. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6402. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6403. return Ok(await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto));
  6404. }
  6405. /// <summary>
  6406. /// 团组模块 - 出入境费用 - 设置view权限
  6407. /// </summary>
  6408. /// <returns></returns>
  6409. [HttpPost]
  6410. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6411. public async Task<IActionResult> EnterExitCostSetViewPermissiion(EnterExitCostSetViewPermissiionDto dto)
  6412. {
  6413. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6414. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6415. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  6416. var permissions = new List<Grp_EnterExitCostPermission>();
  6417. foreach (var userId in dto.UserIds)
  6418. {
  6419. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.GroupId, UserId = userId, CreateUserId = dto.CurrUserId });
  6420. }
  6421. if (permissions.Any())
  6422. {
  6423. _sqlSugar.BeginTran();
  6424. try
  6425. {
  6426. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.GroupId).ExecuteCommandAsync();
  6427. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  6428. if (result < 1)
  6429. {
  6430. _sqlSugar.RollbackTran();
  6431. return Ok(JsonView(false));
  6432. }
  6433. }
  6434. catch (Exception ex)
  6435. {
  6436. _sqlSugar.RollbackTran();
  6437. return Ok(JsonView(false, ex.Message));
  6438. }
  6439. _sqlSugar.CommitTran();
  6440. return Ok(JsonView(true));
  6441. }
  6442. return Ok(JsonView(false));
  6443. }
  6444. /// <summary>
  6445. /// 团组模块 - 出入境费用 - Add And Update
  6446. /// </summary>
  6447. /// <returns></returns>
  6448. [HttpPost]
  6449. [ApiLog("Grp_EnterExitCost", OperationEnum.Add)]
  6450. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6451. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  6452. {
  6453. try
  6454. {
  6455. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  6456. if (dto.DayOtherPriceData.Any())
  6457. {
  6458. var inserList = dto.DayOtherPriceData
  6459. .Where(x => x.Id == 0)
  6460. .Select(x => new Grp_DayOtherPrice
  6461. {
  6462. Cost = x.Cost,
  6463. Id = x.Id,
  6464. CreateTime = DateTime.Now,
  6465. CreateUserId = dto.UserId,
  6466. Currency = x.Currency,
  6467. Diid = x.DiId,
  6468. Index = x.Index,
  6469. IsDel = 0,
  6470. SetDataId = x.SetDataId,
  6471. SubTotal = x.SubTotal,
  6472. Remark = x.Remark
  6473. })
  6474. .ToList();
  6475. var updateList = dto.DayOtherPriceData
  6476. .Where(x => x.Id != 0)
  6477. .Select(x => new Grp_DayOtherPrice
  6478. {
  6479. Cost = x.Cost,
  6480. Id = x.Id,
  6481. CreateTime = DateTime.Now,
  6482. CreateUserId = dto.UserId,
  6483. Currency = x.Currency,
  6484. Diid = x.DiId,
  6485. Index = x.Index,
  6486. IsDel = 0,
  6487. SetDataId = x.SetDataId,
  6488. SubTotal = x.SubTotal,
  6489. Remark = x.Remark
  6490. })
  6491. .ToList();
  6492. //添加
  6493. _sqlSugar.BeginTran();
  6494. if (inserList.Any())
  6495. {
  6496. var rowCount = _sqlSugar.Insertable<Grp_DayOtherPrice>(inserList).ExecuteCommand();
  6497. }
  6498. if (updateList.Any())
  6499. {
  6500. var rowCount = _sqlSugar.Updateable<Grp_DayOtherPrice>(updateList).ExecuteCommand();
  6501. }
  6502. _sqlSugar.CommitTran();
  6503. }
  6504. if (data.Code != 0)
  6505. {
  6506. return Ok(JsonView(false, data.Msg));
  6507. }
  6508. //生成默认文件pdf并且通知人员
  6509. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  6510. {
  6511. DiId = dto.DiId,
  6512. ExportType = 1,
  6513. SubTypeId = 1005
  6514. }, "pdf");
  6515. //发送通知
  6516. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  6517. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  6518. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  6519. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign, fileUrl);
  6520. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  6521. //汇率信息记录
  6522. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  6523. return Ok(JsonView(true, data.Msg, data.Data));
  6524. }
  6525. catch (Exception ex)
  6526. {
  6527. return Ok(JsonView(false, ex.Message));
  6528. }
  6529. }
  6530. /// <summary>
  6531. /// 团组模块 - 出入境费用 - Confirm 费用
  6532. /// </summary>
  6533. /// <returns></returns>
  6534. [HttpPost]
  6535. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6536. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  6537. {
  6538. //TODO:测试完毕需把对应的用户ID更改
  6539. //1、数据表添加字段
  6540. //2、更改字段接口()
  6541. var _view = await _enterExitCostRep.ConfirmCost(dto);
  6542. //3、确认成功 给财务发送消息
  6543. if (_view.Code == 200)
  6544. {
  6545. if (dto.Type == 1)
  6546. {
  6547. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  6548. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  6549. }
  6550. }
  6551. return Ok(_view);
  6552. }
  6553. /// <summary>
  6554. /// 团组模块 - 出入境费用 - File download
  6555. /// </summary>
  6556. /// <param name="dto"></param>
  6557. /// <returns></returns>
  6558. [HttpPost]
  6559. //[ApiLog("Grp_EnterExitCost", OperationEnum.Download)]
  6560. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6561. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  6562. {
  6563. try
  6564. {
  6565. if (dto.DiId < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  6566. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  6567. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  6568. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  6569. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  6570. 3 团组成员名单 1 团组成员名单", ""));
  6571. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).OrderByDescending(x => x.CreateTime).First();
  6572. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  6573. if (_EnterExitCosts == null) return Ok(JsonView(400, "该团组未填写出入境费用;", ""));
  6574. var currencyInit = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToList();
  6575. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  6576. //数据源
  6577. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  6578. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  6579. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  6580. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  6581. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  6582. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  6583. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  6584. .Where((x, a, b) => x.IsDel == 0 && x.Diid == dto.DiId)
  6585. .Select((x, a, b) => new
  6586. {
  6587. x.Index,
  6588. itemName = a.Name,
  6589. CurrencyStr = b.Name,
  6590. x.Cost,
  6591. x.SubTotal,
  6592. x.Remark
  6593. })
  6594. .OrderBy((x) => x.Index)
  6595. .ToList(); //其他款项费用
  6596. var peiceItemCurrencys = new List<string>();
  6597. if (_DayAndCosts.Any())
  6598. {
  6599. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  6600. if (currencyIds.Any()) peiceItemCurrencys.AddRange(currencyInit.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  6601. }
  6602. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  6603. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  6604. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  6605. {
  6606. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  6607. }
  6608. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  6609. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  6610. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  6611. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  6612. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  6613. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  6614. .Select((tcl, dc, cc) => new ClientInfo
  6615. {
  6616. LastName = dc.LastName,
  6617. FirstName = dc.FirstName,
  6618. Sex = dc.Sex,
  6619. Birthday = dc.BirthDay,
  6620. Company = cc.CompanyFullName,
  6621. Job = dc.Job
  6622. })
  6623. .ToList();
  6624. foreach (var item in DeleClientList)
  6625. {
  6626. EncryptionProcessor.DecryptProperties(item);
  6627. }
  6628. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  6629. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  6630. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  6631. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  6632. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  6633. if (dto.ExportType == 1) //明细表
  6634. {
  6635. if (dto.SubTypeId == 1005) //1005(默认明细表)
  6636. {
  6637. //获取模板
  6638. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  6639. //载入模板
  6640. var doc = new Document(tempPath);
  6641. var builder = new DocumentBuilder(doc);
  6642. var dic = new Dictionary<string, string>();
  6643. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  6644. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  6645. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  6646. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  6647. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  6648. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  6649. //境内费用(其他费用)
  6650. if (_EnterExitCosts.ChoiceOne == 1)
  6651. {
  6652. string row1_1 = "";
  6653. if (_EnterExitCosts.Visa > 0)
  6654. {
  6655. //insidePayTotal += _EnterExitCosts.Visa;
  6656. row1_1 = $"签证费:{_EnterExitCosts.Visa:#0.00} 人民币/人";
  6657. //if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  6658. //{
  6659. // row1_1 += $"\t签证费用描述: {_EnterExitCosts.VisaRemark} 人民币/人";
  6660. //}
  6661. }
  6662. string row1_2 = "";
  6663. if (_EnterExitCosts.YiMiao > 0)
  6664. {
  6665. //insidePayTotal += _EnterExitCosts.YiMiao;
  6666. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00} 人民币/人";
  6667. }
  6668. if (_EnterExitCosts.HeSuan > 0)
  6669. {
  6670. //insidePayTotal += _EnterExitCosts.HeSuan;
  6671. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan:#0.00} 人民币/人";
  6672. }
  6673. if (_EnterExitCosts.Service > 0)
  6674. {
  6675. //insidePayTotal += _EnterExitCosts.Service;
  6676. row1_2 += $"服务费:{_EnterExitCosts.Service:#0.00} 人民币/人";
  6677. }
  6678. string row1_3 = "";
  6679. if (_EnterExitCosts.Safe > 0)
  6680. {
  6681. //insidePayTotal += _EnterExitCosts.Safe;
  6682. row1_3 += $"保险费:{_EnterExitCosts.Safe:#0.00} 人民币/人";
  6683. }
  6684. if (_EnterExitCosts.Ticket > 0)
  6685. {
  6686. //insidePayTotal += _EnterExitCosts.Ticket;
  6687. row1_3 += $"参展门票:{_EnterExitCosts.Ticket:#0.00} 人民币/人";
  6688. }
  6689. string row1 = "";
  6690. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  6691. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  6692. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  6693. row1 += $"备注:{_EnterExitCosts.Remark}";
  6694. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  6695. dic.Add("Row1Str", row1);
  6696. }
  6697. string airTotalStr = string.Empty,
  6698. airPriceStr = string.Empty;
  6699. //经济舱
  6700. if (_EnterExitCosts.SumJJC == 1)
  6701. {
  6702. airTotalStr += $"{_EnterExitCosts.OutsideJJPay:#0.00}元/人(经济舱)";
  6703. airPriceStr += $"{_EnterExitCosts.AirJJ:#0.00}元/人(经济舱)";
  6704. }
  6705. //公务舱
  6706. if (_EnterExitCosts.SumGWC == 1)
  6707. {
  6708. airTotalStr += $" {_EnterExitCosts.OutsideGWPay:#0.00} 元/人(公务舱)";
  6709. airPriceStr += $" {_EnterExitCosts.AirGW:#0.00} 元/人(公务舱)";
  6710. }
  6711. //头等舱
  6712. if (_EnterExitCosts.SumTDC == 1)
  6713. {
  6714. airTotalStr += $" {_EnterExitCosts.OutsideTDPay:#0.00} 元/人(头等舱)";
  6715. airPriceStr += $" {_EnterExitCosts.AirTD:#0.00} 元/人(头等舱)";
  6716. }
  6717. //汇率描述
  6718. string rateStr = "";
  6719. if (peiceItemCurrencyInfos.Any())
  6720. {
  6721. rateStr = "\r\n汇率描述:";
  6722. foreach (var item in peiceItemCurrencyInfos)
  6723. {
  6724. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate:#0.0000} ";
  6725. }
  6726. }
  6727. string twoItemRemark = "备注:";
  6728. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  6729. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  6730. dic.Add("AirTotalStr", airTotalStr);
  6731. dic.Add("AirPriceStr", airPriceStr);
  6732. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  6733. dic.Add("TwoItemRemark", twoItemRemark);
  6734. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6735. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6736. int table1Row = 0,
  6737. table2Row = 0,
  6738. table3Row = 0,
  6739. table4Row = 0,
  6740. table5Row = 0;
  6741. //住宿费
  6742. if (_EnterExitCosts.ChoiceThree == 1)
  6743. {
  6744. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  6745. table1Row = dac1.Count;
  6746. #region 填充word表格内容
  6747. for (int i = 0; i < dac1.Count; i++)
  6748. {
  6749. Grp_DayAndCost dac = dac1[i];
  6750. if (dac == null) continue;
  6751. builder.MoveToCell(0, i, 0, 0);
  6752. builder.Write("第" + dac.Days.ToString() + "晚:");
  6753. builder.MoveToCell(0, i, 1, 0);
  6754. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  6755. //builder.Write(dac.Place == null ? "" : dac.Place);
  6756. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6757. builder.MoveToCell(0, i, 2, 0);
  6758. builder.Write("费用标准:");
  6759. string curr = "";
  6760. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6761. if (currData != null)
  6762. {
  6763. curr = currData.Name;
  6764. }
  6765. builder.MoveToCell(0, i, 3, 0);
  6766. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6767. builder.MoveToCell(0, i, 4, 0);
  6768. builder.Write("费用小计:");
  6769. builder.MoveToCell(0, i, 5, 0);
  6770. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6771. }
  6772. #endregion
  6773. }
  6774. else dic.Add("SubZS", "0.00");
  6775. //删除多余行
  6776. while (table1.Rows.Count > table1Row)
  6777. {
  6778. table1.Rows.RemoveAt(table1Row);
  6779. }
  6780. //伙食费
  6781. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  6782. if (_EnterExitCosts.ChoiceFour == 1)
  6783. {
  6784. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  6785. table2Row = dac2.Count;
  6786. #region 填充word表格内容
  6787. for (int i = 0; i < dac2.Count; i++)
  6788. {
  6789. Grp_DayAndCost dac = dac2[i];
  6790. if (dac == null) continue;
  6791. builder.MoveToCell(1, i, 0, 0);
  6792. builder.Write("第" + dac.Days.ToString() + "天:");
  6793. builder.MoveToCell(1, i, 1, 0);
  6794. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6795. builder.MoveToCell(1, i, 2, 0);
  6796. builder.Write("费用标准:");
  6797. string curr = "";
  6798. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6799. if (currData != null)
  6800. {
  6801. curr = currData.Name;
  6802. }
  6803. builder.MoveToCell(1, i, 3, 0);
  6804. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6805. builder.MoveToCell(1, i, 4, 0);
  6806. builder.Write("费用小计:");
  6807. builder.MoveToCell(1, i, 5, 0);
  6808. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6809. }
  6810. #endregion
  6811. }
  6812. else dic.Add("SubHS", "0.00");
  6813. //删除多余行
  6814. while (table2.Rows.Count > table2Row)
  6815. {
  6816. table2.Rows.RemoveAt(table2Row);
  6817. }
  6818. //公杂费
  6819. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  6820. if (_EnterExitCosts.ChoiceFive == 1)
  6821. {
  6822. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  6823. table3Row = dac3.Count;
  6824. #region 填充word表格内容
  6825. for (int i = 0; i < dac3.Count; i++)
  6826. {
  6827. Grp_DayAndCost dac = dac3[i];
  6828. if (dac == null) continue;
  6829. builder.MoveToCell(2, i, 0, 0);
  6830. builder.Write("第" + dac.Days.ToString() + "天:");
  6831. builder.MoveToCell(2, i, 1, 0);
  6832. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6833. builder.MoveToCell(2, i, 2, 0);
  6834. builder.Write("费用标准:");
  6835. string curr = "";
  6836. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6837. if (currData != null)
  6838. {
  6839. curr = currData.Name;
  6840. }
  6841. builder.MoveToCell(2, i, 3, 0);
  6842. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6843. builder.MoveToCell(2, i, 4, 0);
  6844. builder.Write("费用小计:");
  6845. builder.MoveToCell(2, i, 5, 0);
  6846. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6847. }
  6848. //删除多余行
  6849. while (table3.Rows.Count > table3Row)
  6850. {
  6851. table3.Rows.RemoveAt(table3Row);
  6852. }
  6853. #endregion
  6854. }
  6855. else dic.Add("SubGZF", "0.00");
  6856. //删除多余行
  6857. while (table3.Rows.Count > table3Row)
  6858. {
  6859. table3.Rows.RemoveAt(table3Row);
  6860. }
  6861. //培训费
  6862. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  6863. if (_EnterExitCosts.ChoiceSix == 1)
  6864. {
  6865. string pxStr = $"六、培训费合计: {tainFeeTotal:#0.00} 元/人";
  6866. dic.Add("SubPX", pxStr);
  6867. table4Row = dac4.Count;
  6868. #region 填充word表格内容
  6869. for (int i = 0; i < dac4.Count; i++)
  6870. {
  6871. Grp_DayAndCost dac = dac4[i];
  6872. if (dac == null) continue;
  6873. builder.MoveToCell(3, i, 0, 0);
  6874. builder.Write("第" + dac.Days.ToString() + "天:");
  6875. builder.MoveToCell(3, i, 1, 0);
  6876. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6877. builder.MoveToCell(3, i, 2, 0);
  6878. builder.Write("费用标准:");
  6879. string curr = "";
  6880. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6881. if (currData != null)
  6882. {
  6883. curr = currData.Name;
  6884. }
  6885. builder.MoveToCell(3, i, 3, 0);
  6886. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6887. builder.MoveToCell(3, i, 4, 0);
  6888. builder.Write("费用小计:");
  6889. builder.MoveToCell(3, i, 5, 0);
  6890. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6891. }
  6892. #endregion
  6893. }
  6894. //else dic.Add("SubPX", $"六、培训费合计: 0.00 元/人");
  6895. //删除多余行
  6896. while (table4.Rows.Count > table4Row)
  6897. {
  6898. table4.Rows.RemoveAt(table4Row);
  6899. }
  6900. //其他费用
  6901. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  6902. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  6903. {
  6904. string qtStr = $"七、其他费用合计: {otherPriceTotal:#0.00} 元/人";
  6905. dic.Add("titleQi", qtStr);
  6906. table5Row = dac5.Count;
  6907. #region 填充word表格内容
  6908. for (int i = 0; i < dac5.Count; i++)
  6909. {
  6910. var dac = dac5[i];
  6911. if (dac == null) continue;
  6912. builder.MoveToCell(4, i, 0, 0);
  6913. builder.Write("第" + dac.Index.ToString() + "项:");
  6914. builder.MoveToCell(4, i, 1, 0);
  6915. builder.Write(dac.itemName);
  6916. builder.MoveToCell(4, i, 2, 0);
  6917. builder.Write("费用标准:");
  6918. builder.MoveToCell(4, i, 3, 0);
  6919. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  6920. builder.MoveToCell(4, i, 4, 0);
  6921. builder.Write("费用小计:");
  6922. builder.MoveToCell(4, i, 5, 0);
  6923. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6924. builder.MoveToCell(4, i, 6, 0);
  6925. builder.Write("备注:");
  6926. builder.MoveToCell(4, i, 7, 0);
  6927. builder.Write(dac.Remark);
  6928. }
  6929. #endregion
  6930. }
  6931. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  6932. //删除多余行
  6933. while (table5.Rows.Count > table5Row)
  6934. {
  6935. table5.Rows.RemoveAt(table5Row);
  6936. }
  6937. //加上其他费用
  6938. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  6939. decimal subJJC = 0.00M,
  6940. subGWC = 0.00M,
  6941. subTDC = 0.00M;
  6942. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  6943. string totalLabel = string.Format("全部费用总计:");
  6944. //经济舱
  6945. if (_EnterExitCosts.SumJJC == 1)
  6946. {
  6947. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  6948. totalLabel += $"{subJJC:#0.00} 元/人(经济舱)";
  6949. }
  6950. //公务舱
  6951. if (_EnterExitCosts.SumGWC == 1)
  6952. {
  6953. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  6954. totalLabel += $"{subGWC:#0.00} 元/人(公务舱)";
  6955. }
  6956. //头等舱
  6957. if (_EnterExitCosts.SumTDC == 1)
  6958. {
  6959. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  6960. totalLabel += $"{subTDC:#0.00} 元/人(头等舱)";
  6961. }
  6962. //TotalLabel
  6963. dic.Add("TotalLabel", totalLabel);
  6964. //dic.Add("SubJJC", subJJC.ToString("#0.00"));
  6965. //dic.Add("SubGWC", subGWC.ToString("#0.00"));
  6966. //dic.Add("SubTDC", subTDC.ToString("#0.00"));
  6967. #region 填充word模板书签内容
  6968. foreach (var key in dic.Keys)
  6969. {
  6970. Bookmark bookmark = doc.Range.Bookmarks[key];
  6971. if (bookmark != null)
  6972. {
  6973. builder.MoveToBookmark(key);
  6974. builder.Write(dic[key]);
  6975. }
  6976. }
  6977. #endregion
  6978. #region 设置页眉
  6979. string userLabel = string.Empty;
  6980. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  6981. if (currUserInfo != null)
  6982. {
  6983. var userInfo = await _usersRep.GetUserBriefInfo(currUserInfo.UserId);
  6984. if (userInfo != null)
  6985. {
  6986. string ext = string.IsNullOrEmpty(userInfo.ExtensionNumber) ? "-" : userInfo.ExtensionNumber;
  6987. //userLabel = $"联系人:{userInfo.Name} 职位:{userInfo.Job}\r\n座机/分机号:{ext} 手机号:{userInfo.Tel} 公司邮箱:{userInfo.Email}";
  6988. userLabel = $"联系人:{userInfo.Name} 职 位:{userInfo.Job} 手机号:{userInfo.Tel}\r\n公司邮箱:{userInfo.Email}";
  6989. }
  6990. }
  6991. //设置页脚
  6992. //GeneralMethod.AsposeWordSetFooter(builder, userLabel, "华文仿宋", 10);
  6993. #endregion
  6994. //文件名
  6995. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  6996. AsposeHelper.removewatermark_v2180();
  6997. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6998. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6999. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7000. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7001. }
  7002. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  7003. {
  7004. //获取模板
  7005. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  7006. //载入模板
  7007. var doc = new Document(tempPath);
  7008. var builder = new DocumentBuilder(doc);
  7009. var dic = new Dictionary<string, string>();
  7010. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  7011. {
  7012. var list = new List<string>();
  7013. try
  7014. {
  7015. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  7016. foreach (var item in spilitArr)
  7017. {
  7018. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  7019. var depCode = spDotandEmpty[2].Substring(0, 3);
  7020. var arrCode = spDotandEmpty[2].Substring(3, 3);
  7021. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  7022. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  7023. list.Add(depName);
  7024. list.Add(arrName);
  7025. }
  7026. list = list.Distinct().ToList();
  7027. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  7028. }
  7029. catch (Exception)
  7030. {
  7031. dic.Add("ReturnCode", "行程录入不正确!");
  7032. }
  7033. }
  7034. else
  7035. {
  7036. dic.Add("ReturnCode", "未录入行程!");
  7037. }
  7038. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  7039. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  7040. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  7041. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  7042. {
  7043. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  7044. dic.Add("Day", sp.Days.ToString());
  7045. }
  7046. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7047. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  7048. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  7049. //dic.Add("Names", Names);
  7050. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7051. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7052. decimal dac1totalPrice = 0.00M;
  7053. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  7054. foreach (var dac in dac1)
  7055. {
  7056. if (dac.SubTotal == 0.00M)
  7057. {
  7058. continue;
  7059. }
  7060. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  7061. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  7062. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7063. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7064. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  7065. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  7066. builder.Write(currency);//币种
  7067. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  7068. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7069. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  7070. builder.Write("");//人数
  7071. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  7072. builder.Write("");//天数
  7073. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  7074. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7075. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  7076. decimal rate = 0.00M;
  7077. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  7078. builder.Write(rate.ToString("#0.0000"));//汇率
  7079. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7080. decimal rbmPrice = dac.SubTotal;
  7081. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7082. accommodationStartIndex++;
  7083. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  7084. }
  7085. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7086. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  7087. {
  7088. table1.Rows.RemoveAt(i - 1);
  7089. foodandotherStartIndex--;
  7090. }
  7091. if (dac2.Count == dac3.Count)//国家 币种 金额
  7092. {
  7093. for (int i = 0; i < dac2.Count; i++)
  7094. {
  7095. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7096. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7097. }
  7098. }
  7099. decimal dac2totalPrice = 0.00M;
  7100. foreach (var dac in dac2)
  7101. {
  7102. if (dac.SubTotal == 0)
  7103. {
  7104. continue;
  7105. }
  7106. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  7107. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7108. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  7109. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  7110. builder.Write(currency);//币种
  7111. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  7112. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7113. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  7114. builder.Write("");//人数
  7115. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  7116. builder.Write("");//天数
  7117. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  7118. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7119. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  7120. decimal rate = 0.00M;
  7121. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  7122. builder.Write(rate.ToString("#0.0000"));//汇率
  7123. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  7124. decimal rbmPrice = dac.SubTotal;
  7125. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7126. foodandotherStartIndex++;
  7127. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  7128. }
  7129. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  7130. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  7131. {
  7132. table1.Rows.RemoveAt(i - 1);
  7133. }
  7134. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  7135. string otherFeeStr = "";
  7136. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa:#0.00} 元,";
  7137. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe:#0.00} 元,";
  7138. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00} 元,";
  7139. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  7140. foreach (var otherInfo in dac5)
  7141. {
  7142. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  7143. }
  7144. #endregion
  7145. if (otherFeeStr.Length > 0)
  7146. {
  7147. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  7148. otherFeeStr = $"({otherFeeStr})";
  7149. dic.Add("OtherFeeStr", otherFeeStr);
  7150. }
  7151. //总计
  7152. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  7153. //国际旅费
  7154. string outsideAir = string.Empty;
  7155. string allPriceAir = string.Empty;
  7156. if (_EnterExitCosts.SumJJC == 1)
  7157. {
  7158. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7159. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  7160. }
  7161. if (_EnterExitCosts.SumGWC == 1)
  7162. {
  7163. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  7164. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7165. }
  7166. if (_EnterExitCosts.SumTDC == 1)
  7167. {
  7168. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  7169. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  7170. }
  7171. dic.Add("InTravelPrice", $"({outsideAir})");
  7172. dic.Add("FinalSumPrice", $"({allPriceAir})");
  7173. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  7174. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  7175. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  7176. foreach (var key in dic.Keys)
  7177. {
  7178. builder.MoveToBookmark(key);
  7179. builder.Write(dic[key]);
  7180. }
  7181. //模板文件名
  7182. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  7183. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7184. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7185. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7186. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7187. }
  7188. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  7189. {
  7190. //获取模板
  7191. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  7192. //载入模板
  7193. var designer = new WorkbookDesigner
  7194. {
  7195. Workbook = new Workbook(tempPath)
  7196. };
  7197. var dic = new Dictionary<string, string>();
  7198. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  7199. {
  7200. var list = new List<string>();
  7201. try
  7202. {
  7203. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  7204. foreach (var item in spilitArr)
  7205. {
  7206. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  7207. var depCode = spDotandEmpty[2].Substring(0, 3);
  7208. var arrCode = spDotandEmpty[2].Substring(3, 3);
  7209. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  7210. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  7211. list.Add(depName);
  7212. list.Add(arrName);
  7213. }
  7214. list = list.Distinct().ToList();
  7215. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  7216. }
  7217. catch (Exception)
  7218. {
  7219. dic.Add("ReturnCode", "行程录入不正确!");
  7220. }
  7221. }
  7222. else
  7223. {
  7224. dic.Add("ReturnCode", "未录入行程!");
  7225. }
  7226. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  7227. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  7228. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  7229. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  7230. {
  7231. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  7232. dic.Add("Day", sp.Days.ToString());
  7233. }
  7234. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7235. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  7236. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  7237. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  7238. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  7239. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  7240. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  7241. designer.SetDataSource("Name", Names);
  7242. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  7243. designer.SetDataSource("Day", dic["Day"] + "天");
  7244. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  7245. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  7246. int startIndex = 10;
  7247. const int startIndexcopy = 10;
  7248. if (dac2.Count == dac3.Count)//国家 币种 金额
  7249. {
  7250. for (int i = 0; i < dac2.Count; i++)
  7251. {
  7252. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7253. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7254. }
  7255. }
  7256. var dtdac1 = new DataTable();
  7257. var place = new List<string>();
  7258. dtdac1.Columns.AddRange(new DataColumn[] {
  7259. new(){ ColumnName = "city"},
  7260. new(){ ColumnName = "curr"},
  7261. new(){ ColumnName = "criterion"},
  7262. new(){ ColumnName = "number",DataType = typeof(int)},
  7263. new(){ ColumnName = "day",DataType = typeof(int)},
  7264. new(){ ColumnName = "cost", DataType = typeof(decimal)},
  7265. new(){ ColumnName = "rate", DataType = typeof(decimal) },
  7266. new(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  7267. });
  7268. var dtdac2 = new DataTable();
  7269. dtdac2.Columns.AddRange(new DataColumn[] {
  7270. new(){ ColumnName = "city"},
  7271. new(){ ColumnName = "curr"},
  7272. new(){ ColumnName = "criterion"},
  7273. new(){ ColumnName = "number",DataType = typeof(int)},
  7274. new(){ ColumnName = "day",DataType = typeof(int)},
  7275. new(){ ColumnName = "cost", DataType = typeof(decimal)},
  7276. new(){ ColumnName = "rate", DataType = typeof(decimal) },
  7277. new(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  7278. });
  7279. dtdac1.TableName = "tb1";
  7280. dtdac2.TableName = "tb2";
  7281. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  7282. foreach (var item in dac1)
  7283. {
  7284. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  7285. if (place.Contains(item.Place))
  7286. {
  7287. continue;
  7288. }
  7289. DataRow row = dtdac1.NewRow();
  7290. row["city"] = item.Place;
  7291. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  7292. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7293. row["curr"] = currency;
  7294. row["rate"] = rate.ToString("#0.0000");
  7295. row["criterion"] = item.Cost.ToString("#0.00");
  7296. row["number"] = 1;
  7297. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7298. //row["costRMB"] = rbmPrice;
  7299. dtdac1.Rows.Add(row);
  7300. place.Add(item.Place);
  7301. }
  7302. place = new List<string>();
  7303. foreach (var item in dac2)
  7304. {
  7305. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  7306. if (place.Contains(item.Place))
  7307. {
  7308. continue;
  7309. }
  7310. DataRow row = dtdac2.NewRow();
  7311. row["city"] = item.Place;
  7312. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  7313. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7314. row["curr"] = currency;
  7315. row["rate"] = rate.ToString("#0.0000");
  7316. row["criterion"] = item.Cost.ToString("#0.00");
  7317. row["number"] = 1;
  7318. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7319. //row["cost"] = item.SubTotal;
  7320. //row["costRMB"] = rbmPrice;
  7321. dtdac2.Rows.Add(row);
  7322. place.Add(item.Place);
  7323. //dac2totalPrice += rbmPrice;
  7324. }
  7325. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  7326. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  7327. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7328. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  7329. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic:#0.00} 元");
  7330. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic:#0.00} ");
  7331. string cell4Str1 = string.Empty;
  7332. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ:#0.00} 元/人;";
  7333. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW:#0.00} 元/人;";
  7334. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD:#0.00} 元/人;";
  7335. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  7336. string cellStr = $" 5.其他费用(";
  7337. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  7338. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  7339. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  7340. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  7341. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  7342. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  7343. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  7344. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  7345. foreach (var otherInfo in dac5)
  7346. {
  7347. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  7348. }
  7349. #endregion
  7350. if (cellStr.Length > 8)
  7351. {
  7352. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  7353. }
  7354. cellStr += ")";
  7355. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  7356. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  7357. decimal pxFee = dac4.Sum(it => it.Cost);
  7358. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  7359. string celllastStr1 = "";
  7360. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice:#0.00} 元";
  7361. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice:#0.00} 元";
  7362. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee:#0.00} 元";
  7363. celllastStr1 += $",国际旅费 元";
  7364. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee:#0.00} 元";
  7365. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  7366. designer.SetDataSource("cell4Str", cell4Str);
  7367. designer.SetDataSource("cellStr", cellStr);
  7368. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  7369. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7370. designer.SetDataSource("celllastStr", celllastStr);
  7371. Workbook wb = designer.Workbook;
  7372. var sheet = wb.Worksheets[0];
  7373. //绑定datatable数据集
  7374. designer.SetDataSource(dtdac1);
  7375. designer.SetDataSource(dtdac2);
  7376. designer.Process();
  7377. var rowStart = dtdac1.Rows.Count;
  7378. while (rowStart > 0)
  7379. {
  7380. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  7381. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7382. startIndex++;
  7383. rowStart--;
  7384. }
  7385. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  7386. startIndex += 1; //总计行
  7387. rowStart = dtdac2.Rows.Count;
  7388. while (rowStart > 0)
  7389. {
  7390. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  7391. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7392. startIndex++;
  7393. rowStart--;
  7394. }
  7395. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  7396. wb.CalculateFormula(true);
  7397. //模板文件名
  7398. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  7399. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7400. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7401. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7402. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7403. }
  7404. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  7405. {
  7406. //获取模板
  7407. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  7408. //载入模板
  7409. var doc = new Document(tempPath);
  7410. var builder = new DocumentBuilder(doc);
  7411. var dic = new Dictionary<string, string>
  7412. {
  7413. { "GroupName", _DelegationInfo.TeamName },
  7414. { "ClientUnit", _DelegationInfo.ClientUnit }
  7415. };
  7416. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  7417. string missionLeaderJob = "";//负责人job
  7418. //int groupNumber = 0; //团人数
  7419. if (DeleClientList.Count > 0)
  7420. {
  7421. missionLeader = DeleClientList[0]?.Name ?? "";
  7422. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  7423. }
  7424. dic.Add("MissionLeader", missionLeader); //团负责人
  7425. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  7426. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  7427. #region MyRegion
  7428. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  7429. //{
  7430. // List<string> list = new List<string>();
  7431. // try
  7432. // {
  7433. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  7434. // foreach (var item in spilitArr)
  7435. // {
  7436. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  7437. // var depCode = spDotandEmpty[2].Substring(0, 3);
  7438. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  7439. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  7440. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  7441. // list.Add(depName);
  7442. // list.Add(arrName);
  7443. // }
  7444. // list = list.Distinct().ToList();
  7445. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  7446. // }
  7447. // catch (Exception)
  7448. // {
  7449. // dic.Add("ReturnCode", "行程录入不正确!");
  7450. // }
  7451. //}
  7452. //else
  7453. //{
  7454. // dic.Add("ReturnCode", "未录入行程!");
  7455. //}
  7456. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  7457. dic.Add("ReturnCode", string.Join("、", countrys));
  7458. #endregion
  7459. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  7460. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  7461. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  7462. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  7463. //{
  7464. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  7465. // dic.Add("Day", sp.Days.ToString());
  7466. //}
  7467. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  7468. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  7469. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7470. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7471. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7472. //培训人员名单
  7473. int cultivateRowIndex = 7;
  7474. foreach (var item in DeleClientList)
  7475. {
  7476. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  7477. builder.Write(item.Name);
  7478. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  7479. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  7480. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  7481. string birthDay = "";
  7482. if (item.Birthday != null)
  7483. {
  7484. DateTime dt = Convert.ToDateTime(item.Birthday);
  7485. birthDay = $"{dt.Year}.{dt.Month}";
  7486. }
  7487. builder.Write(birthDay);
  7488. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  7489. builder.Write(item.Company);
  7490. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  7491. builder.Write(item.Job);
  7492. cultivateRowIndex++;
  7493. }
  7494. //删除多余行
  7495. //cultivateRowIndex -= 2;
  7496. int delRows = 10 + 7 - cultivateRowIndex;
  7497. if (delRows > 0)
  7498. {
  7499. for (int i = 0; i < delRows; i++)
  7500. {
  7501. table1.Rows.RemoveAt(cultivateRowIndex);
  7502. //cultivateRowIndex++;
  7503. }
  7504. }
  7505. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  7506. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  7507. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  7508. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  7509. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  7510. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  7511. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  7512. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  7513. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  7514. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  7515. //其他费用
  7516. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  7517. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  7518. //其他费用合计
  7519. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  7520. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  7521. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  7522. //公务舱合计
  7523. //国际旅费
  7524. //string outsideJJ = "";
  7525. //string allPriceJJ = "";
  7526. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  7527. {
  7528. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7529. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  7530. }
  7531. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  7532. {
  7533. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  7534. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  7535. }
  7536. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  7537. {
  7538. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ:#0.00} 公务舱:{_EnterExitCosts.AirGW:#0.00}");
  7539. dic.Add("AirFeeTotal", airFeeTotalStr);
  7540. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal:#0.00} 公务舱:{_gwcFeeToatal:#0.00}");
  7541. dic.Add("FeeTotal", feeTotalStr);
  7542. }
  7543. foreach (var key in dic.Keys)
  7544. {
  7545. builder.MoveToBookmark(key);
  7546. builder.Write(dic[key]);
  7547. }
  7548. //模板文件名
  7549. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  7550. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7551. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7552. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7553. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7554. }
  7555. }
  7556. else if (dto.ExportType == 2) //表格
  7557. {
  7558. //利用键值对存放数据
  7559. Dictionary<string, string> dic = new Dictionary<string, string>();
  7560. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  7561. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  7562. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  7563. dic.Add("Day", sp.Days.ToString());
  7564. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7565. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  7566. {
  7567. //获取模板
  7568. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  7569. //载入模板
  7570. var doc = new Document(tempPath);
  7571. var builder = new DocumentBuilder(doc);
  7572. dic.Add("TeamName", _DelegationInfo.TeamName);
  7573. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  7574. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  7575. string missionLeaderName = "",
  7576. missionLeaderJob = "";
  7577. if (DeleClientList.Count > 0)
  7578. {
  7579. missionLeaderName = DeleClientList[0].Name;
  7580. missionLeaderJob = DeleClientList[0].Job;
  7581. }
  7582. dic.Add("MissionLeaderName", missionLeaderName);
  7583. dic.Add("MissionLeaderJob", missionLeaderJob);
  7584. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  7585. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  7586. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7587. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7588. int rowCount = 10;//总人数行
  7589. int startRowIndex = 7; //起始行
  7590. for (int i = 0; i < DeleClientList.Count; i++)
  7591. {
  7592. builder.MoveToCell(0, startRowIndex, 0, 0);
  7593. builder.Write(DeleClientList[i].Name); //出国人员姓名
  7594. builder.MoveToCell(0, startRowIndex, 1, 0);
  7595. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  7596. builder.Write(sex);//性别
  7597. builder.MoveToCell(0, startRowIndex, 2, 0);
  7598. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  7599. builder.MoveToCell(0, startRowIndex, 3, 0);
  7600. builder.Write(DeleClientList[i].Company);//工作单位
  7601. builder.MoveToCell(0, startRowIndex, 4, 0);
  7602. builder.Write(DeleClientList[i].Job);//职务及级别
  7603. builder.MoveToCell(0, startRowIndex, 5, 0);
  7604. builder.Write("");//人员属性
  7605. builder.MoveToCell(0, startRowIndex, 6, 0);
  7606. builder.Write("");//上次出国时间
  7607. startRowIndex++;
  7608. }
  7609. int nullRow = rowCount - DeleClientList.Count;//空行
  7610. for (int i = 0; i < nullRow; i++)
  7611. {
  7612. table1.Rows.Remove(table1.Rows[startRowIndex]);
  7613. }
  7614. foreach (var key in dic.Keys)
  7615. {
  7616. builder.MoveToBookmark(key);
  7617. builder.Write(dic[key]);
  7618. }
  7619. //模板文件名
  7620. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  7621. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7622. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7623. if (dto.PortType == 1) return Ok(JsonView(true, "成功", new { Url = url }));
  7624. else if (dto.PortType == 2 || dto.PortType == 3) return Ok(JsonView(true, "成功", url));
  7625. }
  7626. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  7627. {
  7628. //获取模板
  7629. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  7630. //载入模板
  7631. var doc = new Document(tempPath);
  7632. var builder = new DocumentBuilder(doc);
  7633. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  7634. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  7635. dic.Add("Names", Names);
  7636. int accommodationRows = 12;
  7637. //int foodandotherRows = 12;
  7638. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  7639. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  7640. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7641. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7642. int accommodationStartIndex = 6;
  7643. decimal dac1totalPrice = 0.00M;
  7644. foreach (var dac in dac1)
  7645. {
  7646. if (dac.SubTotal == 0)
  7647. {
  7648. continue;
  7649. }
  7650. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  7651. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  7652. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7653. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  7654. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  7655. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  7656. builder.Write(currency);//币种
  7657. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  7658. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7659. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  7660. builder.Write("");//人数
  7661. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  7662. builder.Write("");//天数
  7663. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  7664. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7665. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  7666. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7667. builder.Write(rate.ToString("#0.0000"));//汇率
  7668. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7669. decimal rbmPrice = rate * dac.SubTotal;
  7670. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7671. accommodationStartIndex++;
  7672. dac1totalPrice += rbmPrice;
  7673. }
  7674. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7675. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7676. builder.Write("小计");
  7677. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7678. builder.Write(dac1totalPrice.ToString("#0.00"));
  7679. accommodationStartIndex++;
  7680. int nullRow = accommodationRows - dac1.Count;
  7681. //删除空行
  7682. //if (nullRow > 0)
  7683. //{
  7684. // int rowIndex = accommodationStartIndex;
  7685. // for (int i = 0; i < nullRow; i++)
  7686. // {
  7687. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  7688. // row.Remove();
  7689. // rowIndex++;
  7690. // }
  7691. //}
  7692. if (dac2.Count == dac3.Count)//国家 币种 金额
  7693. {
  7694. for (int i = 0; i < dac2.Count; i++)
  7695. {
  7696. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7697. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7698. }
  7699. }
  7700. int foodandotherStartIndex = 19;//
  7701. decimal dac2totalPrice = 0.00M;
  7702. foreach (var dac in dac2)
  7703. {
  7704. if (dac.SubTotal == 0)
  7705. {
  7706. continue;
  7707. }
  7708. //foodandotherStartIndex = 12;
  7709. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  7710. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  7711. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  7712. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  7713. builder.Write(currency);//币种
  7714. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  7715. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7716. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  7717. builder.Write("");//人数
  7718. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  7719. builder.Write("");//天数
  7720. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  7721. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7722. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  7723. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7724. builder.Write(rate.ToString("#0.0000"));//汇率
  7725. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  7726. decimal rbmPrice = rate * dac.SubTotal;
  7727. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7728. foodandotherStartIndex++;
  7729. dac2totalPrice += rbmPrice;
  7730. }
  7731. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  7732. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  7733. //删除空行
  7734. //if (dac2.Count < foodandotherRows)
  7735. //{
  7736. // while (table2.Rows.Count > dac2.Count)
  7737. // {
  7738. // table2.Rows.RemoveAt(dac2.Count);
  7739. // }
  7740. //}
  7741. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  7742. string otherFeeStr = "";
  7743. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  7744. if (_EnterExitCosts.YiMiao > 0) otherFeeStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  7745. if (_EnterExitCosts.HeSuan > 0) otherFeeStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  7746. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  7747. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  7748. if (_EnterExitCosts.Service > 0) otherFeeStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  7749. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  7750. foreach (var otherInfo in dac5)
  7751. {
  7752. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal:#0.00} 元,";
  7753. }
  7754. #endregion
  7755. if (otherFeeStr.Length > 0)
  7756. {
  7757. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  7758. otherFeeStr = $"({otherFeeStr})";
  7759. dic.Add("OtherFeeStr", otherFeeStr);
  7760. }
  7761. foreach (var key in dic.Keys)
  7762. {
  7763. builder.MoveToBookmark(key);
  7764. builder.Write(dic[key]);
  7765. }
  7766. //模板文件名
  7767. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  7768. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7769. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7770. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7771. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7772. }
  7773. }
  7774. else if (dto.ExportType == 3)
  7775. {
  7776. if (dto.SubTypeId == 1) //团组成员名单
  7777. {
  7778. if (!DeleClientList.Any()) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成员暂未录入!!!", ""));
  7779. //获取模板
  7780. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  7781. //载入模板
  7782. var doc = new Document(tempPath);
  7783. var builder = new DocumentBuilder(doc);
  7784. //获取word里所有表格
  7785. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7786. //获取所填表格的序数
  7787. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  7788. var rowStart = tableOne.Rows[0]; //获取第1行
  7789. //循环赋值
  7790. for (int i = 0; i < DeleClientList.Count; i++)
  7791. {
  7792. builder.MoveToCell(0, i + 1, 0, 0);
  7793. builder.Write(DeleClientList[i].Name);
  7794. builder.MoveToCell(0, i + 1, 1, 0);
  7795. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  7796. builder.Write(sex);
  7797. builder.MoveToCell(0, i + 1, 2, 0);
  7798. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  7799. builder.MoveToCell(0, i + 1, 3, 0);
  7800. builder.Write(DeleClientList[i].Company);
  7801. builder.MoveToCell(0, i + 1, 4, 0);
  7802. builder.Write(DeleClientList[i].Job);
  7803. }
  7804. //删除多余行
  7805. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  7806. {
  7807. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  7808. }
  7809. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  7810. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  7811. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  7812. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7813. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7814. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7815. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7816. }
  7817. }
  7818. return Ok(JsonView(400, "操作失败!", ""));
  7819. }
  7820. catch (Exception ex)
  7821. {
  7822. return Ok(JsonView(400, ex.Message, ""));
  7823. }
  7824. }
  7825. /// <summary>
  7826. /// 获取三公费用标准city
  7827. /// </summary>
  7828. /// <param name="placeData"></param>
  7829. /// <param name="nationalTravelFeeId"></param>
  7830. /// <returns></returns>
  7831. private static string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  7832. {
  7833. string _city = string.Empty;
  7834. if (placeData.Count < 1) return _city;
  7835. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  7836. if (data == null) return _city;
  7837. string country = data.Country;
  7838. string city = data.City;
  7839. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  7840. else _city = city;
  7841. return _city;
  7842. }
  7843. ///// <summary>
  7844. ///// 团组模块 - 出入境费用 - 明细表导出
  7845. ///// </summary>
  7846. ///// <returns></returns>
  7847. //[HttpPost]
  7848. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7849. //public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  7850. //{
  7851. // var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  7852. // if (data.Code != 0)
  7853. // {
  7854. // return Ok(JsonView(false, data.Msg));
  7855. // }
  7856. // return Ok(JsonView(true, data.Msg, data.Data));
  7857. //}
  7858. /// <summary>
  7859. /// 团组模块 - 出入境费用 - 一键清空
  7860. /// </summary>
  7861. /// <returns></returns>
  7862. [HttpPost]
  7863. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  7864. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7865. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  7866. {
  7867. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  7868. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  7869. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  7870. var _view = await _enterExitCostRep._OneClickClear(dto.Id, dto.DiId, dto.UserId);
  7871. await _sqlSugar.Updateable<Grp_DayOtherPrice>()
  7872. .Where(x => x.Diid == dto.DiId && x.IsDel == 0)
  7873. .SetColumns(x => new Grp_DayOtherPrice
  7874. {
  7875. IsDel = 1,
  7876. DeleteUserId = dto.UserId,
  7877. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  7878. })
  7879. .ExecuteCommandAsync();
  7880. if (_view.Code == 0)
  7881. {
  7882. return Ok(JsonView(true, "操作成功"));
  7883. }
  7884. return Ok(JsonView(false, "操作失败"));
  7885. }
  7886. /// <summary>
  7887. /// 团组模块 - 出入境费用 - 子项删除
  7888. /// </summary>
  7889. /// <returns></returns>
  7890. [HttpPost]
  7891. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  7892. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7893. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  7894. {
  7895. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  7896. if (data.Code != 0)
  7897. {
  7898. return Ok(JsonView(false, data.Msg));
  7899. }
  7900. return Ok(JsonView(true, "操作成功!", data.Data));
  7901. }
  7902. /// <summary>
  7903. /// 删除三公其他费用
  7904. /// </summary>
  7905. /// <param name="dto"></param>
  7906. /// <returns></returns>
  7907. [HttpPost]
  7908. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  7909. public IActionResult DeleteOtherExpenses(EnterExitCostSubItemDelDto dto)
  7910. {
  7911. var jw = JsonView(false, "删除失败!");
  7912. var data = new Grp_DayOtherPrice()
  7913. {
  7914. Id = dto.Id,
  7915. IsDel = 1,
  7916. DeleteUserId = dto.DeleteUserId,
  7917. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  7918. };
  7919. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  7920. if (del > 0)
  7921. {
  7922. jw.Code = 200;
  7923. jw.Msg = "删除成功!";
  7924. }
  7925. return Ok(jw);
  7926. }
  7927. /// <summary>
  7928. /// 团组模块 - 出入境国家费用标准 List
  7929. /// </summary>
  7930. /// <returns></returns>
  7931. [HttpPost]
  7932. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7933. public async Task<IActionResult> GetNationalTravelFeeData(NationalTravelFeeDataDto dto)
  7934. {
  7935. int provinceId = dto.ProvinceId;
  7936. if (provinceId < 1) provinceId = 122; //默认四川省数据
  7937. var nftData = await _sqlSugar
  7938. .Queryable<Grp_NationalTravelFee, Sys_SetData, Sys_Users, Sys_Cities>((ntf, sd1, u, c) => new JoinQueryInfos(
  7939. JoinType.Left, ntf.Currency == sd1.Id,
  7940. JoinType.Left, ntf.LastUpdateUserId == u.Id,
  7941. JoinType.Left, ntf.ProvinceId == c.Id
  7942. ))
  7943. .Where((ntf, sd1, u, c) => ntf.IsDel == 0 && ntf.ProvinceId == provinceId)
  7944. .Select((ntf, sd1, u, c) => new NationalTravelFeeInfoView
  7945. {
  7946. Id = ntf.Id,
  7947. ProvinceId = ntf.ProvinceId,
  7948. ProvinceName = c.Name_CN,
  7949. Continent = ntf.Continent,
  7950. Country = ntf.Country,
  7951. City = ntf.City,
  7952. Currency = ntf.Currency,
  7953. CurrencyCode = sd1.Name,
  7954. CurrencyName = sd1.Remark,
  7955. RoomCost = ntf.RoomCost,
  7956. FoodCost = ntf.FoodCost,
  7957. PublicCost = ntf.PublicCost,
  7958. LastUpdateUserId = ntf.LastUpdateUserId,
  7959. LastUpdateUserName = u.CnName,
  7960. LastUpdateTime = ntf.LastUpdateTime
  7961. })
  7962. .ToListAsync();
  7963. return Ok(JsonView(true, "查询成功!", nftData));
  7964. }
  7965. /// <summary>
  7966. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  7967. /// </summary>
  7968. /// <returns></returns>
  7969. [HttpPost]
  7970. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7971. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  7972. {
  7973. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  7974. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  7975. List<string> countryData = new List<string>();
  7976. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country!).ToList());
  7977. countryData = countryData.Distinct().ToList();
  7978. List<dynamic> dataSource = new List<dynamic>();
  7979. foreach (var item in countryData)
  7980. {
  7981. var cityData1 = new List<string>();
  7982. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City ?? "").ToList();
  7983. var countryData2 = new
  7984. {
  7985. CountryName = item,
  7986. CityData = cityData1
  7987. };
  7988. if (!dataSource.Contains(countryData2))
  7989. {
  7990. dataSource.Add(countryData2);
  7991. }
  7992. }
  7993. return Ok(JsonView(true, "查询成功!", dataSource));
  7994. }
  7995. /// <summary>
  7996. /// 团组模块 - 出入境国家费用标准 Page List
  7997. /// </summary>
  7998. /// <returns></returns>
  7999. [HttpPost]
  8000. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8001. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  8002. {
  8003. int portId = dto.PortType,
  8004. pageIndex = dto.PageIndex,
  8005. pageSize = dto.PageSize;
  8006. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  8007. if (pageIndex == 0) pageIndex = 1;
  8008. if (pageSize == 0) pageSize = 10;
  8009. RefAsync<int> total = 0;
  8010. var nationalTravelFeeData = await _sqlSugar
  8011. .Queryable<Grp_NationalTravelFee, Sys_SetData, Sys_Users, Sys_Cities>((ntf, sd1, u, sd2) => new JoinQueryInfos(
  8012. JoinType.Left, ntf.Currency == sd1.Id,
  8013. JoinType.Left, ntf.LastUpdateUserId == u.Id,
  8014. JoinType.Left, ntf.ProvinceId == sd2.Id
  8015. ))
  8016. .Where((ntf, sd1, u, sd2) => ntf.IsDel == 0)
  8017. .WhereIF(dto.ProvinceId > 0, (ntf, sd1, u, sd2) => ntf.ProvinceId == dto.ProvinceId)
  8018. .WhereIF(!string.IsNullOrEmpty(dto.Country), (ntf, sd1, u, sd2) => ntf.Country.Contains(dto.Country))
  8019. .WhereIF(!string.IsNullOrEmpty(dto.City), (ntf, sd1, u, sd2) => ntf.City.Contains(dto.City))
  8020. .OrderByDescending((ntf, sd1, u, sd2) => ntf.LastUpdateTime)
  8021. .Select((ntf, sd1, u, sd2) => new NationalTravelFeePageInfoView
  8022. {
  8023. RowNumber = SqlFunc.RowNumber($"{ntf.LastUpdateTime} Desc"),
  8024. Id = ntf.Id,
  8025. ProvinceId = ntf.ProvinceId,
  8026. ProvinceName = sd2.Name_CN,
  8027. Continent = ntf.Continent,
  8028. Country = ntf.Country,
  8029. City = ntf.City,
  8030. Currency = ntf.Currency,
  8031. CurrencyCode = sd1.Name,
  8032. CurrencyName = sd1.Remark,
  8033. RoomCost = ntf.RoomCost,
  8034. FoodCost = ntf.FoodCost,
  8035. PublicCost = ntf.PublicCost,
  8036. LastUpdateUserId = ntf.LastUpdateUserId,
  8037. LastUpdateUserName = u.CnName,
  8038. LastUpdateTime = ntf.LastUpdateTime,
  8039. Remark = ntf.Remark
  8040. })
  8041. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  8042. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  8043. }
  8044. /// <summary>
  8045. /// 团组模块 - 出入境国家费用标准 根据城市查询
  8046. /// </summary>
  8047. /// <returns></returns>
  8048. [HttpPost]
  8049. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8050. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  8051. {
  8052. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  8053. int portId = dto.PortType;
  8054. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  8055. string whereSql = string.Empty;
  8056. if (!string.IsNullOrEmpty(dto.Country))
  8057. {
  8058. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  8059. }
  8060. if (!string.IsNullOrEmpty(dto.City))
  8061. {
  8062. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  8063. }
  8064. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  8065. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,gntf.TrainCost,
  8066. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  8067. From Grp_NationalTravelFee gntf
  8068. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  8069. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  8070. Where gntf.Isdel = 0 {0} ", whereSql);
  8071. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  8072. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  8073. }
  8074. /// <summary>
  8075. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  8076. /// </summary>
  8077. /// <returns></returns>
  8078. [HttpPost]
  8079. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8080. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  8081. {
  8082. return Ok(await _enterExitCostRep.PostNationalTravelFeeOperate(dto));
  8083. }
  8084. /// <summary>
  8085. /// 团组模块 - 出入境国家费用标准 - Del
  8086. /// </summary>
  8087. /// <returns></returns>
  8088. [HttpPost]
  8089. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8090. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  8091. {
  8092. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  8093. {
  8094. Id = dto.Id,
  8095. DeleteUserId = dto.DeleteUserId,
  8096. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  8097. IsDel = 1
  8098. };
  8099. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  8100. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  8101. .WhereColumns(it => new { it.Id })
  8102. .ExecuteCommandAsync();
  8103. if (delStatus <= 0)
  8104. {
  8105. return Ok(JsonView(false, "删除失败!"));
  8106. }
  8107. return Ok(JsonView(true, "操作成功!"));
  8108. }
  8109. /// <summary>
  8110. /// 团组模块 - 出入境国家费用标准 - 费用导入收款账单
  8111. /// 注:Get 请求Headers 加 Token
  8112. /// </summary>
  8113. /// <param name="groupId"></param>
  8114. /// <returns></returns>
  8115. [HttpGet("{groupId}")]
  8116. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8117. public async Task<IActionResult> NationalTravelFeeImportReceivables(int groupId)
  8118. {
  8119. var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  8120. if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  8121. var data = await GeneralMethod.ReceivablesImportFeeAsync(groupId);
  8122. data.ForEach(x =>
  8123. {
  8124. x.CreateUserId = _currUserInfo.UserId;
  8125. });
  8126. if (data.Any())
  8127. {
  8128. var add = await _sqlSugar.Insertable(data).ExecuteCommandAsync();
  8129. if (add > 0)
  8130. {
  8131. return Ok(JsonView(true, "操作成功!"));
  8132. }
  8133. }
  8134. return Ok(JsonView(false, "未操作!"));
  8135. }
  8136. #endregion
  8137. #region 团组经理模块 出入境费用-草稿
  8138. /// <summary>
  8139. /// 团组模块 - 出入境费用-草稿 - 基础数据源 - 省份归属
  8140. /// </summary>
  8141. /// <returns></returns>
  8142. [HttpGet]
  8143. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8144. public async Task<IActionResult> EnterExitDraftProvBelongCostDataSource()
  8145. {
  8146. var provData = await _groupRepository.ProvinceBasicSource();
  8147. return Ok(JsonView(true, "查询成功!", provData));
  8148. }
  8149. /// <summary>
  8150. /// 团组模块 - 出入境费用-草稿 - 文件类型list 根据省份Id获取
  8151. /// </summary>
  8152. /// <returns></returns>
  8153. [HttpGet("{provinceId}")]
  8154. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8155. public async Task<IActionResult> EnterExitCostDraftFileOwner([FromRoute] int provinceId = 122)
  8156. {
  8157. //验证城市归属并给默认值
  8158. if (provinceId < 1) provinceId = 122;
  8159. /*
  8160. * 122 四川
  8161. * 108 贵州
  8162. * 103 重庆
  8163. * 132 云南
  8164. */
  8165. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostDraftRep.FileOwner(provinceId);
  8166. return Ok(JsonView(true, "查询成功!", new
  8167. {
  8168. WordTypeData = wordTypeData,
  8169. ExcelTypeData = excelTypeData,
  8170. }));
  8171. }
  8172. /// <summary>
  8173. /// 团组模块 - 出入境费用-草稿 - 基础数据源(团组名称/币种类型)
  8174. /// </summary>
  8175. /// <returns></returns>
  8176. [HttpPost]
  8177. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8178. public async Task<IActionResult> EnterExitCostDraftDataSource(EnterExitCostDraftDataSourceDto dto)
  8179. {
  8180. var draftNameDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  8181. .Where(x => x.IsDel == 0)
  8182. .OrderByDescending(x => x.CreateTime)
  8183. .Select(x => new { x.Id, x.DraftName })
  8184. .ToListAsync();
  8185. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  8186. //SetDataInfoView
  8187. var dataSource = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  8188. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  8189. var _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  8190. int provinceId = dto.ProvinceId;
  8191. if (provinceId < 1) provinceId = 122;
  8192. /*
  8193. * 122 四川
  8194. * 108 贵州
  8195. * 103 重庆
  8196. * 132 云南
  8197. */
  8198. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostRep.FileOwner(provinceId);
  8199. //默认币种显示
  8200. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  8201. var viewPermissionData = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  8202. return Ok(JsonView(true, "查询成功!", new
  8203. {
  8204. DraftNameDatas = draftNameDatas,
  8205. CurrencyData = _CurrencyData,
  8206. WordTypeData = wordTypeData,
  8207. ExcelTypeData = excelTypeData,
  8208. CurrencyInit = _currencyInfos,
  8209. ViewPermissionData = viewPermissionData
  8210. }));
  8211. }
  8212. /// <summary>
  8213. /// 团组模块 - 出入境费用-草稿
  8214. /// 实时汇率 tips
  8215. /// 机票费用 tips
  8216. /// </summary>
  8217. /// <returns></returns>
  8218. [HttpPost]
  8219. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8220. public async Task<IActionResult> EnterExitCostDraftCorrelationTips(EnterExitCostDraftCorrelationTipsDto dto)
  8221. {
  8222. //var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  8223. return Ok(JsonView(true, "查询成功!", new
  8224. {
  8225. //GroupNameData = groupNameData.Data,
  8226. //visaData = visaData.Data,
  8227. //airData = airData.Data,
  8228. reteInfos = await GeneralMethod.EnterExitCostLiveRate()
  8229. }));
  8230. }
  8231. /// <summary>
  8232. /// 团组模块 - 出入境费用-草稿
  8233. /// 签证费用 tips
  8234. /// </summary>
  8235. /// <returns></returns>
  8236. [HttpPost]
  8237. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8238. public async Task<IActionResult> EnterExitCostDraftVisaTips(EnterExitCostDraftVisaTipsDto dto)
  8239. {
  8240. //if (dto.DraftId < 1) return Ok(JsonView(false,MsgTips.Id));
  8241. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  8242. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  8243. .Select(x => x.NationalTravelFeeId)
  8244. .Distinct()
  8245. .ToListAsync();
  8246. //if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  8247. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  8248. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  8249. .Select(x => x.Country)
  8250. .Distinct()
  8251. .ToArrayAsync();
  8252. //if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  8253. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  8254. return Ok(JsonView(true, "查询成功!", new
  8255. {
  8256. totalAmt,
  8257. remark
  8258. }));
  8259. }
  8260. /// <summary>
  8261. /// 团组模块 - 出入境费用-草稿 - Info
  8262. /// </summary>
  8263. /// <returns></returns>
  8264. [HttpPost]
  8265. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Details)]
  8266. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8267. public async Task<IActionResult> EnterExitCostDraftInfoById(EnterExitCostDraftInfoByIdDto dto)
  8268. {
  8269. return Ok(await _enterExitCostDraftRep.EnterExitCostDraftInfoById(dto));
  8270. }
  8271. /// <summary>
  8272. /// 团组模块 - 出入境费用-草稿 - 设置view权限
  8273. /// </summary>
  8274. /// <returns></returns>
  8275. [HttpPost]
  8276. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8277. public async Task<IActionResult> EnterExitCostDraftSetViewPermissiion(EnterExitCostDraftSetViewPermissiionDto dto)
  8278. {
  8279. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8280. if (dto.DraftId < 1) return Ok(JsonView(false, "请传入有效的DraftId;"));
  8281. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  8282. var permissions = new List<Grp_EnterExitCostDraftPermission>();
  8283. foreach (var userId in dto.UserIds)
  8284. {
  8285. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  8286. }
  8287. if (permissions.Any())
  8288. {
  8289. _sqlSugar.BeginTran();
  8290. try
  8291. {
  8292. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  8293. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  8294. if (result < 1)
  8295. {
  8296. _sqlSugar.RollbackTran();
  8297. return Ok(JsonView(false));
  8298. }
  8299. }
  8300. catch (Exception ex)
  8301. {
  8302. _sqlSugar.RollbackTran();
  8303. return Ok(JsonView(false, ex.Message));
  8304. }
  8305. _sqlSugar.CommitTran();
  8306. return Ok(JsonView(true));
  8307. }
  8308. return Ok(JsonView(false));
  8309. }
  8310. /// <summary>
  8311. /// 团组模块 - 出入境费用-草稿 - Add And Update
  8312. /// </summary>
  8313. /// <returns></returns>
  8314. [HttpPost]
  8315. [ApiLog("Grp_EnterExitCostDraft", OperationEnum.Add)]
  8316. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8317. public async Task<IActionResult> EnterExitCostDraftOp(EnterExitCostDraftOpDto dto)
  8318. {
  8319. var data = await _enterExitCostDraftRep.EnterExitCostDraftOp(dto);
  8320. if (data.Code != 0)
  8321. {
  8322. return Ok(JsonView(false, data.Msg));
  8323. }
  8324. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  8325. //汇率信息记录
  8326. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  8327. return Ok(JsonView(true, data.Msg, data.Data));
  8328. }
  8329. /// <summary>
  8330. /// 团组模块 - 出入境费用-草稿 - File downlaod
  8331. /// </summary>
  8332. /// <param name="dto"></param>
  8333. /// <returns></returns>
  8334. [HttpPost]
  8335. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Download)]
  8336. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8337. public async Task<IActionResult> EnterExitCostDraftDownload(EnterExitCostDraftDownloadDto dto)
  8338. {
  8339. try
  8340. {
  8341. var id = dto.Id;
  8342. if (id < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  8343. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  8344. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  8345. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  8346. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  8347. 3 团组成员名单 1 团组成员名单", ""));
  8348. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(it => it.IsDel == 0 && it.Id == id).OrderByDescending(x => x.CreateTime).First();
  8349. if (_EnterExitCosts == null) return Ok(JsonView(400, "未填写出入境费用-草稿;", ""));
  8350. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(it => it.IsDel == 0 && it.ParentId == id).ToList();
  8351. var countryIds = _DayAndCosts.Select(x => x.NationalTravelFeeId).ToList();
  8352. var nationalTravelFeeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0 && countryIds.Contains(it.Id)).ToList();
  8353. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  8354. //数据源
  8355. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  8356. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  8357. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  8358. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  8359. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  8360. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  8361. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  8362. .Where((x, a, b) => x.IsDel == 0 && x.ParentId == id)
  8363. .Select((x, a, b) => new
  8364. {
  8365. x.Index,
  8366. itemName = a.Name,
  8367. CurrencyStr = b.Name,
  8368. x.Cost,
  8369. x.SubTotal,
  8370. x.Remark
  8371. })
  8372. .OrderBy((x) => x.Index)
  8373. .ToList(); //其他款项费用
  8374. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  8375. var peiceItemCurrencys = new List<string>();
  8376. if (_DayAndCosts.Any())
  8377. {
  8378. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  8379. if (currencyIds.Any()) peiceItemCurrencys.AddRange(_CurrDatas.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  8380. }
  8381. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  8382. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  8383. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  8384. {
  8385. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  8386. }
  8387. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  8388. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  8389. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  8390. if (dto.ExportType == 1) //明细表
  8391. {
  8392. if (dto.SubTypeId == 1005) //1005(默认明细表)
  8393. {
  8394. //获取模板
  8395. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  8396. //载入模板
  8397. Document doc = new Document(tempPath);
  8398. DocumentBuilder builder = new DocumentBuilder(doc);
  8399. //利用键值对存放数据
  8400. Dictionary<string, string> dic = new Dictionary<string, string>();
  8401. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  8402. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  8403. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  8404. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  8405. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  8406. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  8407. //境内费用(其他费用)
  8408. if (_EnterExitCosts.ChoiceOne == 1)
  8409. {
  8410. string row1_1 = "";
  8411. if (_EnterExitCosts.Visa > 0)
  8412. {
  8413. //insidePayTotal += _EnterExitCosts.Visa;
  8414. row1_1 = $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  8415. //if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  8416. //{
  8417. // row1_1 += $"\t签证费用描述: {_EnterExitCosts.VisaRemark} 人民币/人";
  8418. //}
  8419. }
  8420. string row1_2 = "";
  8421. if (_EnterExitCosts.YiMiao > 0)
  8422. {
  8423. //insidePayTotal += _EnterExitCosts.YiMiao;
  8424. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  8425. }
  8426. if (_EnterExitCosts.HeSuan > 0)
  8427. {
  8428. //insidePayTotal += _EnterExitCosts.HeSuan;
  8429. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  8430. }
  8431. if (_EnterExitCosts.Service > 0)
  8432. {
  8433. //insidePayTotal += _EnterExitCosts.Service;
  8434. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  8435. }
  8436. string row1_3 = "";
  8437. if (_EnterExitCosts.Safe > 0)
  8438. {
  8439. //insidePayTotal += _EnterExitCosts.Safe;
  8440. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  8441. }
  8442. if (_EnterExitCosts.Ticket > 0)
  8443. {
  8444. //insidePayTotal += _EnterExitCosts.Ticket;
  8445. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  8446. }
  8447. string row1 = "";
  8448. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  8449. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  8450. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  8451. row1 += $"备注:{_EnterExitCosts.Remark}";
  8452. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  8453. dic.Add("Row1Str", row1);
  8454. }
  8455. string airTotalStr = string.Empty,
  8456. airPriceStr = string.Empty;
  8457. //经济舱
  8458. if (_EnterExitCosts.SumJJC == 1)
  8459. {
  8460. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  8461. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  8462. }
  8463. //公务舱
  8464. if (_EnterExitCosts.SumGWC == 1)
  8465. {
  8466. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  8467. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  8468. }
  8469. //头等舱
  8470. if (_EnterExitCosts.SumTDC == 1)
  8471. {
  8472. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  8473. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  8474. }
  8475. //汇率描述
  8476. string rateStr = "";
  8477. if (peiceItemCurrencyInfos.Any())
  8478. {
  8479. rateStr = "\r\n汇率描述:";
  8480. foreach (var item in peiceItemCurrencyInfos)
  8481. {
  8482. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate.ToString("#0.0000")} ";
  8483. }
  8484. }
  8485. string twoItemRemark = "备注:";
  8486. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  8487. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  8488. dic.Add("AirTotalStr", airTotalStr);
  8489. dic.Add("AirPriceStr", airPriceStr);
  8490. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  8491. dic.Add("TwoItemRemark", twoItemRemark);
  8492. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8493. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  8494. int table1Row = 0,
  8495. table2Row = 0,
  8496. table3Row = 0,
  8497. table4Row = 0,
  8498. table5Row = 0;
  8499. //住宿费
  8500. if (_EnterExitCosts.ChoiceThree == 1)
  8501. {
  8502. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  8503. table1Row = dac1.Count;
  8504. #region 填充word表格内容
  8505. for (int i = 0; i < dac1.Count; i++)
  8506. {
  8507. var dac = dac1[i];
  8508. if (dac == null) continue;
  8509. builder.MoveToCell(0, i, 0, 0);
  8510. builder.Write("第" + dac.Days.ToString() + "晚:");
  8511. builder.MoveToCell(0, i, 1, 0);
  8512. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  8513. //builder.Write(dac.Place == null ? "" : dac.Place);
  8514. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8515. builder.MoveToCell(0, i, 2, 0);
  8516. builder.Write("费用标准:");
  8517. string curr = "";
  8518. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8519. if (currData != null)
  8520. {
  8521. curr = currData.Name;
  8522. }
  8523. builder.MoveToCell(0, i, 3, 0);
  8524. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8525. builder.MoveToCell(0, i, 4, 0);
  8526. builder.Write("费用小计:");
  8527. builder.MoveToCell(0, i, 5, 0);
  8528. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8529. }
  8530. #endregion
  8531. }
  8532. else dic.Add("SubZS", "0.00");
  8533. //删除多余行
  8534. while (table1.Rows.Count > table1Row)
  8535. {
  8536. table1.Rows.RemoveAt(table1Row);
  8537. }
  8538. //伙食费
  8539. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  8540. if (_EnterExitCosts.ChoiceFour == 1)
  8541. {
  8542. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  8543. table2Row = dac2.Count;
  8544. #region 填充word表格内容
  8545. for (int i = 0; i < dac2.Count; i++)
  8546. {
  8547. var dac = dac2[i];
  8548. if (dac == null) continue;
  8549. builder.MoveToCell(1, i, 0, 0);
  8550. builder.Write("第" + dac.Days.ToString() + "天:");
  8551. builder.MoveToCell(1, i, 1, 0);
  8552. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8553. builder.MoveToCell(1, i, 2, 0);
  8554. builder.Write("费用标准:");
  8555. string curr = "";
  8556. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8557. if (currData != null)
  8558. {
  8559. curr = currData.Name;
  8560. }
  8561. builder.MoveToCell(1, i, 3, 0);
  8562. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8563. builder.MoveToCell(1, i, 4, 0);
  8564. builder.Write("费用小计:");
  8565. builder.MoveToCell(1, i, 5, 0);
  8566. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8567. }
  8568. #endregion
  8569. }
  8570. else dic.Add("SubHS", "0.00");
  8571. //删除多余行
  8572. while (table2.Rows.Count > table2Row)
  8573. {
  8574. table2.Rows.RemoveAt(table2Row);
  8575. }
  8576. //公杂费
  8577. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  8578. if (_EnterExitCosts.ChoiceFive == 1)
  8579. {
  8580. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  8581. table3Row = dac3.Count;
  8582. #region 填充word表格内容
  8583. for (int i = 0; i < dac3.Count; i++)
  8584. {
  8585. var dac = dac3[i];
  8586. if (dac == null) continue;
  8587. builder.MoveToCell(2, i, 0, 0);
  8588. builder.Write("第" + dac.Days.ToString() + "天:");
  8589. builder.MoveToCell(2, i, 1, 0);
  8590. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8591. builder.MoveToCell(2, i, 2, 0);
  8592. builder.Write("费用标准:");
  8593. string curr = "";
  8594. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8595. if (currData != null)
  8596. {
  8597. curr = currData.Name;
  8598. }
  8599. builder.MoveToCell(2, i, 3, 0);
  8600. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8601. builder.MoveToCell(2, i, 4, 0);
  8602. builder.Write("费用小计:");
  8603. builder.MoveToCell(2, i, 5, 0);
  8604. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8605. }
  8606. //删除多余行
  8607. while (table3.Rows.Count > table3Row)
  8608. {
  8609. table3.Rows.RemoveAt(table3Row);
  8610. }
  8611. #endregion
  8612. }
  8613. else dic.Add("SubGZF", "0.00");
  8614. //删除多余行
  8615. while (table3.Rows.Count > table3Row)
  8616. {
  8617. table3.Rows.RemoveAt(table3Row);
  8618. }
  8619. //培训费
  8620. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  8621. if (_EnterExitCosts.ChoiceSix == 1)
  8622. {
  8623. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  8624. dic.Add("SubPX", pxStr);
  8625. table4Row = dac4.Count;
  8626. #region 填充word表格内容
  8627. for (int i = 0; i < dac4.Count; i++)
  8628. {
  8629. var dac = dac4[i];
  8630. if (dac == null) continue;
  8631. builder.MoveToCell(3, i, 0, 0);
  8632. builder.Write("第" + dac.Days.ToString() + "天:");
  8633. builder.MoveToCell(3, i, 1, 0);
  8634. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8635. builder.MoveToCell(3, i, 2, 0);
  8636. builder.Write("费用标准:");
  8637. string curr = "";
  8638. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8639. if (currData != null)
  8640. {
  8641. curr = currData.Name;
  8642. }
  8643. builder.MoveToCell(3, i, 3, 0);
  8644. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8645. builder.MoveToCell(3, i, 4, 0);
  8646. builder.Write("费用小计:");
  8647. builder.MoveToCell(3, i, 5, 0);
  8648. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8649. }
  8650. #endregion
  8651. }
  8652. //else dic.Add("SubPX", $"六、培训费合计: 0 元/人");
  8653. //删除多余行
  8654. while (table4.Rows.Count > table4Row)
  8655. {
  8656. table4.Rows.RemoveAt(table4Row);
  8657. }
  8658. //其他费用
  8659. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  8660. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  8661. {
  8662. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  8663. dic.Add("titleQi", qtStr);
  8664. table5Row = dac5.Count;
  8665. #region 填充word表格内容
  8666. for (int i = 0; i < dac5.Count; i++)
  8667. {
  8668. var dac = dac5[i];
  8669. if (dac == null) continue;
  8670. builder.MoveToCell(4, i, 0, 0);
  8671. builder.Write("第" + dac.Index.ToString() + "项:");
  8672. builder.MoveToCell(4, i, 1, 0);
  8673. builder.Write(dac.itemName);
  8674. builder.MoveToCell(4, i, 2, 0);
  8675. builder.Write("费用标准:");
  8676. builder.MoveToCell(4, i, 3, 0);
  8677. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  8678. builder.MoveToCell(4, i, 4, 0);
  8679. builder.Write("费用小计:");
  8680. builder.MoveToCell(4, i, 5, 0);
  8681. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8682. builder.MoveToCell(4, i, 6, 0);
  8683. builder.Write("备注:");
  8684. builder.MoveToCell(4, i, 7, 0);
  8685. builder.Write(dac.Remark);
  8686. }
  8687. #endregion
  8688. }
  8689. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  8690. //删除多余行
  8691. while (table5.Rows.Count > table5Row)
  8692. {
  8693. table5.Rows.RemoveAt(table5Row);
  8694. }
  8695. //加上其他费用
  8696. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  8697. decimal subJJC = 0.00M,
  8698. subGWC = 0.00M,
  8699. subTDC = 0.00M;
  8700. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  8701. string totalLabel = string.Format("全部费用总计:");
  8702. //经济舱
  8703. if (_EnterExitCosts.SumJJC == 1)
  8704. {
  8705. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  8706. totalLabel += $"{subJJC.ToString("#0.00")} 元/人(经济舱)";
  8707. }
  8708. //公务舱
  8709. if (_EnterExitCosts.SumGWC == 1)
  8710. {
  8711. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  8712. totalLabel += $"{subGWC.ToString("#0.00")} 元/人(公务舱)";
  8713. }
  8714. //头等舱
  8715. if (_EnterExitCosts.SumTDC == 1)
  8716. {
  8717. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  8718. totalLabel += $"{subTDC.ToString("#0.00")} 元/人(头等舱)";
  8719. }
  8720. //TotalLabel
  8721. dic.Add("TotalLabel", totalLabel);
  8722. #region 填充word模板书签内容
  8723. foreach (var key in dic.Keys)
  8724. {
  8725. Bookmark bookmark = doc.Range.Bookmarks[key];
  8726. if (bookmark != null)
  8727. {
  8728. builder.MoveToBookmark(key);
  8729. builder.Write(dic[key]);
  8730. }
  8731. }
  8732. #endregion
  8733. //文件名
  8734. string strFileName = $"{_EnterExitCosts.DraftName}_出入境费用-草稿{Guid.NewGuid().ToString()}.docx";
  8735. strFileName = CommonFun.ValidFileName(strFileName);
  8736. AsposeHelper.removewatermark_v2180();
  8737. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8738. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8739. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8740. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8741. }
  8742. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  8743. {
  8744. //获取模板
  8745. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  8746. //载入模板
  8747. Document doc = new Document(tempPath);
  8748. DocumentBuilder builder = new DocumentBuilder(doc);
  8749. Dictionary<string, string> dic = new Dictionary<string, string>();
  8750. string returnCodeLabel = string.Empty;
  8751. if (nationalTravelFeeData.Any())
  8752. {
  8753. List<string> list = new List<string>();
  8754. foreach (var item in nationalTravelFeeData)
  8755. {
  8756. list.Add($"{item.Country}({item.City})");
  8757. }
  8758. list = list.Distinct().ToList();
  8759. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  8760. }
  8761. var countryLabel = string.Empty;
  8762. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  8763. if (countryData.Any())
  8764. {
  8765. countryLabel = string.Join("、", countryData);
  8766. }
  8767. dic.Add("ReturnCodeAir", returnCodeLabel);
  8768. dic.Add("VisitStartDate", "-");
  8769. dic.Add("VisitEndDate", "-");
  8770. dic.Add("Day", "-");
  8771. dic.Add("VisitCountry", countryLabel);
  8772. dic.Add("ClientUnit", "-");
  8773. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  8774. //dic.Add("Names", Names);
  8775. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8776. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  8777. decimal dac1totalPrice = 0.00M;
  8778. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  8779. foreach (var dac in dac1)
  8780. {
  8781. if (dac.SubTotal == 0.00M)
  8782. {
  8783. continue;
  8784. }
  8785. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  8786. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  8787. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  8788. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  8789. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  8790. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  8791. builder.Write(currency);//币种
  8792. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  8793. builder.Write(dac.Cost.ToString("#0.00"));//标准
  8794. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  8795. builder.Write("");//人数
  8796. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  8797. builder.Write("");//天数
  8798. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  8799. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  8800. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  8801. decimal rate = 0.00M;
  8802. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  8803. builder.Write(rate.ToString("#0.0000"));//汇率
  8804. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  8805. decimal rbmPrice = dac.SubTotal;
  8806. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  8807. accommodationStartIndex++;
  8808. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  8809. }
  8810. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  8811. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  8812. {
  8813. table1.Rows.RemoveAt(i - 1);
  8814. foodandotherStartIndex--;
  8815. }
  8816. if (dac2.Count == dac3.Count)//国家 币种 金额
  8817. {
  8818. for (int i = 0; i < dac2.Count; i++)
  8819. {
  8820. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  8821. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  8822. }
  8823. }
  8824. decimal dac2totalPrice = 0.00M;
  8825. foreach (var dac in dac2)
  8826. {
  8827. if (dac.SubTotal == 0)
  8828. {
  8829. continue;
  8830. }
  8831. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  8832. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  8833. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  8834. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  8835. builder.Write(currency);//币种
  8836. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  8837. builder.Write(dac.Cost.ToString("#0.00"));//标准
  8838. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  8839. builder.Write("");//人数
  8840. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  8841. builder.Write("");//天数
  8842. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  8843. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  8844. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  8845. decimal rate = 0.00M;
  8846. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  8847. builder.Write(rate.ToString("#0.0000"));//汇率
  8848. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  8849. decimal rbmPrice = dac.SubTotal;
  8850. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  8851. foodandotherStartIndex++;
  8852. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  8853. }
  8854. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  8855. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  8856. {
  8857. table1.Rows.RemoveAt(i - 1);
  8858. }
  8859. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  8860. string otherFeeStr = "";
  8861. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  8862. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  8863. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  8864. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  8865. foreach (var otherInfo in dac5)
  8866. {
  8867. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  8868. }
  8869. #endregion
  8870. if (otherFeeStr.Length > 0)
  8871. {
  8872. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  8873. otherFeeStr = $"({otherFeeStr})";
  8874. dic.Add("OtherFeeStr", otherFeeStr);
  8875. }
  8876. //总计
  8877. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  8878. //国际旅费
  8879. string outsideAir = string.Empty;
  8880. string allPriceAir = string.Empty;
  8881. if (_EnterExitCosts.SumJJC == 1)
  8882. {
  8883. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  8884. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  8885. }
  8886. if (_EnterExitCosts.SumGWC == 1)
  8887. {
  8888. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  8889. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  8890. }
  8891. if (_EnterExitCosts.SumTDC == 1)
  8892. {
  8893. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  8894. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  8895. }
  8896. dic.Add("InTravelPrice", $"({outsideAir})");
  8897. dic.Add("FinalSumPrice", $"({allPriceAir})");
  8898. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  8899. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  8900. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  8901. foreach (var key in dic.Keys)
  8902. {
  8903. builder.MoveToBookmark(key);
  8904. builder.Write(dic[key]);
  8905. }
  8906. //模板文件名
  8907. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  8908. strFileName = CommonFun.ValidFileName(strFileName);
  8909. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8910. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8911. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8912. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8913. }
  8914. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  8915. {
  8916. //获取模板
  8917. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  8918. //载入模板
  8919. WorkbookDesigner designer = new WorkbookDesigner();
  8920. designer.Workbook = new Workbook(tempPath);
  8921. Dictionary<string, string> dic = new Dictionary<string, string>();
  8922. string returnCodeLabel = string.Empty;
  8923. if (nationalTravelFeeData.Any())
  8924. {
  8925. List<string> list = new List<string>();
  8926. foreach (var item in nationalTravelFeeData)
  8927. {
  8928. list.Add($"{item.Country}({item.City})");
  8929. }
  8930. list = list.Distinct().ToList();
  8931. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  8932. }
  8933. var countryLabel = string.Empty;
  8934. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  8935. if (countryData.Any())
  8936. {
  8937. countryLabel = string.Join("、", countryData);
  8938. }
  8939. dic.Add("ReturnCodeAir", returnCodeLabel);
  8940. dic.Add("VisitStartDate", "-");
  8941. dic.Add("VisitEndDate", "-");
  8942. dic.Add("Day", "0");
  8943. dic.Add("VisitCountry", countryLabel);
  8944. dic.Add("ClientUnit", "-");
  8945. designer.SetDataSource("ClientUnit", "-");
  8946. designer.SetDataSource("VisitCountry", countryLabel);
  8947. designer.SetDataSource("Group", "-");
  8948. designer.SetDataSource("ClientUnitTitle", "-");
  8949. designer.SetDataSource("Name", "-");
  8950. designer.SetDataSource("VisitStartDate", "-");
  8951. designer.SetDataSource("Day", "0");
  8952. designer.SetDataSource("ReturnCode", returnCodeLabel);
  8953. designer.SetDataSource("ReturnCodeAir", "-");
  8954. int startIndex = 10;
  8955. const int startIndexcopy = 10;
  8956. if (dac2.Count == dac3.Count)//国家 币种 金额
  8957. {
  8958. for (int i = 0; i < dac2.Count; i++)
  8959. {
  8960. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  8961. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  8962. }
  8963. }
  8964. DataTable dtdac1 = new DataTable();
  8965. List<string> place = new List<string>();
  8966. dtdac1.Columns.AddRange(new DataColumn[] {
  8967. new DataColumn(){ ColumnName = "city"},
  8968. new DataColumn(){ ColumnName = "curr"},
  8969. new DataColumn(){ ColumnName = "criterion"},
  8970. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  8971. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  8972. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  8973. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  8974. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  8975. });
  8976. DataTable dtdac2 = new DataTable();
  8977. dtdac2.Columns.AddRange(new DataColumn[] {
  8978. new DataColumn(){ ColumnName = "city"},
  8979. new DataColumn(){ ColumnName = "curr"},
  8980. new DataColumn(){ ColumnName = "criterion"},
  8981. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  8982. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  8983. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  8984. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  8985. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  8986. });
  8987. dtdac1.TableName = "tb1";
  8988. dtdac2.TableName = "tb2";
  8989. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  8990. foreach (var item in dac1)
  8991. {
  8992. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  8993. if (place.Contains(item.Place))
  8994. {
  8995. continue;
  8996. }
  8997. DataRow row = dtdac1.NewRow();
  8998. row["city"] = item.Place;
  8999. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  9000. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  9001. row["curr"] = currency;
  9002. row["rate"] = rate.ToString("#0.0000");
  9003. row["criterion"] = item.Cost.ToString("#0.00");
  9004. row["number"] = 1;
  9005. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  9006. //row["costRMB"] = rbmPrice;
  9007. dtdac1.Rows.Add(row);
  9008. place.Add(item.Place);
  9009. }
  9010. place = new List<string>();
  9011. foreach (var item in dac2)
  9012. {
  9013. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  9014. if (place.Contains(item.Place))
  9015. {
  9016. continue;
  9017. }
  9018. DataRow row = dtdac2.NewRow();
  9019. row["city"] = item.Place;
  9020. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  9021. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  9022. row["curr"] = currency;
  9023. row["rate"] = rate.ToString("#0.0000");
  9024. row["criterion"] = item.Cost.ToString("#0.00");
  9025. row["number"] = 1;
  9026. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  9027. //row["cost"] = item.SubTotal;
  9028. //row["costRMB"] = rbmPrice;
  9029. dtdac2.Rows.Add(row);
  9030. place.Add(item.Place);
  9031. //dac2totalPrice += rbmPrice;
  9032. }
  9033. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  9034. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  9035. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  9036. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  9037. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic:#0.00} 元");
  9038. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic:#0.00} ");
  9039. string cell4Str1 = string.Empty;
  9040. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ:#0.00} 元/人;";
  9041. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW:#0.00} 元/人;";
  9042. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD:#0.00} 元/人;";
  9043. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  9044. string cellStr = $" 5.其他费用(";
  9045. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  9046. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  9047. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  9048. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  9049. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  9050. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  9051. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  9052. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  9053. foreach (var otherInfo in dac5)
  9054. {
  9055. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal:#0.00} 元,";
  9056. }
  9057. #endregion
  9058. if (cellStr.Length > 8)
  9059. {
  9060. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  9061. }
  9062. cellStr += ")";
  9063. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  9064. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  9065. decimal pxFee = dac4.Sum(it => it.Cost);
  9066. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  9067. string celllastStr1 = "";
  9068. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice:#0.00} 元";
  9069. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice:#0.00} 元";
  9070. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee:#0.00} 元";
  9071. celllastStr1 += $",国际旅费 元";
  9072. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee:#0.00} 元";
  9073. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  9074. designer.SetDataSource("cell4Str", cell4Str);
  9075. designer.SetDataSource("cellStr", cellStr);
  9076. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  9077. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  9078. designer.SetDataSource("celllastStr", celllastStr);
  9079. Workbook wb = designer.Workbook;
  9080. var sheet = wb.Worksheets[0];
  9081. //绑定datatable数据集
  9082. designer.SetDataSource(dtdac1);
  9083. designer.SetDataSource(dtdac2);
  9084. designer.Process();
  9085. var rowStart = dtdac1.Rows.Count;
  9086. while (rowStart > 0)
  9087. {
  9088. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  9089. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  9090. startIndex++;
  9091. rowStart--;
  9092. }
  9093. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  9094. startIndex += 1; //总计行
  9095. rowStart = dtdac2.Rows.Count;
  9096. while (rowStart > 0)
  9097. {
  9098. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  9099. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  9100. startIndex++;
  9101. rowStart--;
  9102. }
  9103. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  9104. wb.CalculateFormula(true);
  9105. //模板文件名
  9106. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  9107. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  9108. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  9109. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  9110. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  9111. }
  9112. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  9113. {
  9114. //获取模板
  9115. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  9116. //载入模板
  9117. Document doc = new Document(tempPath);
  9118. DocumentBuilder builder = new DocumentBuilder(doc);
  9119. Dictionary<string, string> dic = new Dictionary<string, string>();
  9120. dic.Add("GroupName", "-");
  9121. dic.Add("ClientUnit", "-");
  9122. //string missionLeader = ""; //团负责人默认接团客户名单第一个人
  9123. //string missionLeaderJob = "";//负责人job
  9124. //int groupNumber = 0; //团人数
  9125. dic.Add("MissionLeader", "-"); //团负责人
  9126. dic.Add("MissionLeaderJob", "-"); //团负责人job
  9127. dic.Add("GroupNumber", "0"); //团人数
  9128. dic.Add("Day", "0");
  9129. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  9130. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  9131. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  9132. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  9133. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  9134. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  9135. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  9136. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  9137. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  9138. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  9139. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  9140. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  9141. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  9142. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  9143. //其他费用
  9144. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  9145. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  9146. //其他费用合计
  9147. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  9148. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  9149. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  9150. //公务舱合计
  9151. //国际旅费
  9152. //string outsideJJ = "";
  9153. //string allPriceJJ = "";
  9154. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  9155. {
  9156. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  9157. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  9158. }
  9159. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  9160. {
  9161. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  9162. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  9163. }
  9164. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  9165. {
  9166. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ:#0.00} 公务舱:{_EnterExitCosts.AirGW:#0.00}");
  9167. dic.Add("AirFeeTotal", airFeeTotalStr);
  9168. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal:#0.00} 公务舱:{_gwcFeeToatal:#0.00}");
  9169. dic.Add("FeeTotal", feeTotalStr);
  9170. }
  9171. foreach (var key in dic.Keys)
  9172. {
  9173. builder.MoveToBookmark(key);
  9174. builder.Write(dic[key]);
  9175. }
  9176. //模板文件名
  9177. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  9178. strFileName = CommonFun.ValidFileName(strFileName);
  9179. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  9180. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  9181. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  9182. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  9183. }
  9184. }
  9185. else if (dto.ExportType == 2) //表格
  9186. {
  9187. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  9188. }
  9189. else if (dto.ExportType == 3)
  9190. {
  9191. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  9192. }
  9193. return Ok(JsonView(400, "只可导出明细表!", ""));
  9194. }
  9195. catch (Exception ex)
  9196. {
  9197. return Ok(JsonView(400, ex.Message, ""));
  9198. }
  9199. }
  9200. /// <summary>
  9201. /// 获取三公费用标准city
  9202. /// </summary>
  9203. /// <param name="placeData"></param>
  9204. /// <param name="nationalTravelFeeId"></param>
  9205. /// <returns></returns>
  9206. private string GetEnterExitCostDraftExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  9207. {
  9208. string _city = string.Empty;
  9209. if (!placeData.Any()) return _city;
  9210. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  9211. if (data == null) return _city;
  9212. string country = data.Country;
  9213. string city = data.City;
  9214. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  9215. else _city = city;
  9216. return _city;
  9217. }
  9218. /// <summary>
  9219. /// 团组模块 - 出入境费用-草稿 - 一键清空
  9220. /// </summary>
  9221. /// <returns></returns>
  9222. [HttpPost]
  9223. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  9224. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9225. public async Task<IActionResult> EnterExitCostDraftOneClickEmpty(EnterExitCostDraftOneClickEmptyDto dto)
  9226. {
  9227. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  9228. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  9229. var _view = await _enterExitCostDraftRep.OneClickEmpty(dto.Id, dto.UserId);
  9230. if (_view.Code == 0)
  9231. {
  9232. return Ok(JsonView(true, "操作成功"));
  9233. }
  9234. return Ok(JsonView(false, "操作失败"));
  9235. }
  9236. /// <summary>
  9237. /// 团组模块 - 出入境费用-草稿 - 子项删除
  9238. /// </summary>
  9239. /// <returns></returns>
  9240. [HttpPost]
  9241. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  9242. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9243. public async Task<IActionResult> EnterExitCostDraftSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  9244. {
  9245. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  9246. if (data.Code != 0)
  9247. {
  9248. return Ok(JsonView(false, data.Msg));
  9249. }
  9250. return Ok(JsonView(true, "操作成功!", data.Data));
  9251. }
  9252. /// <summary>
  9253. /// 三公其他费用草稿 删除
  9254. /// </summary>
  9255. /// <param name="dto"></param>
  9256. /// <returns></returns>
  9257. [HttpPost]
  9258. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  9259. public IActionResult EnterExitCostDraftOtherExpensesDel(EnterExitCostDraftOtherExpensesDelDto dto)
  9260. {
  9261. var jw = JsonView(false, "删除失败!");
  9262. var data = new Grp_DayOtherPriceDraft()
  9263. {
  9264. Id = dto.Id,
  9265. IsDel = 1,
  9266. DeleteUserId = dto.DeleteUserId,
  9267. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  9268. };
  9269. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  9270. if (del > 0)
  9271. {
  9272. jw.Code = 200;
  9273. jw.Msg = "删除成功!";
  9274. }
  9275. return Ok(jw);
  9276. }
  9277. /// <summary>
  9278. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用基础数据
  9279. /// </summary>
  9280. /// <returns></returns>
  9281. [HttpPost]
  9282. public async Task<IActionResult> EnterExitCostDraftImportDataInit()
  9283. {
  9284. var jw = JsonView(false);
  9285. var groupNameDatas = await _groupRepository.EnterExitCostGroupNameAsync();
  9286. var draftDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0).OrderByDescending(x => x.CreateTime).Select(x => new { x.Id, x.DraftName }).ToListAsync();
  9287. jw.Code = StatusCodes.Status200OK;
  9288. jw.Msg = "操作成功!";
  9289. jw.Data = new { groupNameDatas = groupNameDatas, draftNames = draftDatas };
  9290. return Ok(jw);
  9291. }
  9292. /// <summary>
  9293. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用
  9294. /// </summary>
  9295. /// <param name="dto"></param>
  9296. /// <returns></returns>
  9297. [HttpPost]
  9298. public async Task<IActionResult> EnterExitCostDraftImportData(EnterExitCostDraftImportDataDto dto)
  9299. {
  9300. int userId = dto.UserId,
  9301. portId = dto.PortType,
  9302. groupId = dto.GroupId,
  9303. draftId = dto.DraftId;
  9304. _portTypeData.Add(1);
  9305. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9306. if (!_portTypeData.Contains(portId)) return Ok(JsonView(false, MsgTips.Port));
  9307. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId!"));
  9308. if (draftId < 1) return Ok(JsonView(false, "请传入有效的DraftId!"));
  9309. _sqlSugar.BeginTran();
  9310. try
  9311. {
  9312. var draftDatas = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).First();
  9313. if (draftDatas == null)
  9314. {
  9315. _sqlSugar.RollbackTran();
  9316. return Ok(JsonView(false, "草稿数据为空,不可导入!"));
  9317. }
  9318. //验证可覆盖已有数据 两边创建人需为同一人;
  9319. int draftCreateUserId = draftDatas.CreateUserId,
  9320. formalCreateUserId = 0;
  9321. var formalData = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  9322. if (formalData != null)
  9323. {
  9324. formalCreateUserId = formalData.CreateUserId;
  9325. if (draftCreateUserId != formalCreateUserId)
  9326. {
  9327. _sqlSugar.RollbackTran();
  9328. return Ok(JsonView(false, "由草稿数据到入至正式数据,两边创建人为同一人才可导入正式版!"));
  9329. }
  9330. }
  9331. //默认添加查看、编辑权限(创建人、自己)
  9332. await _enterExitCostRep.InitPerm(dto.GroupId, dto.UserId);
  9333. var dayDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  9334. var otherDatas = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  9335. var newExterData = _mapper.Map<Grp_EnterExitCost>(draftDatas);
  9336. newExterData.DiId = groupId;
  9337. newExterData.CreateUserId = userId;
  9338. newExterData.Remark = $"由草稿数据导入;草稿数Id:{draftId}";
  9339. var newDayDatas = _mapper.Map<List<Grp_DayAndCost>>(dayDatas);
  9340. if (newDayDatas.Any()) newDayDatas.Select(x => { x.DiId = groupId; x.CreateUserId = userId; return x; }).ToList();
  9341. var newOtherDatas = _mapper.Map<List<Grp_DayOtherPrice>>(otherDatas);
  9342. if (newOtherDatas.Any()) newOtherDatas.Select(x => { x.Diid = groupId; x.CreateUserId = userId; return x; }).ToList();
  9343. var enterExitCostInfo = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  9344. //数据如果存在执行删除
  9345. if (enterExitCostInfo != null)
  9346. {
  9347. _sqlSugar.Updateable<Grp_EnterExitCost>()
  9348. .SetColumns(x => new Grp_EnterExitCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Remark = "由草稿数据导入前软删除数据!" })
  9349. .Where(x => x.Id == enterExitCostInfo.Id)
  9350. .ExecuteCommand();
  9351. _sqlSugar.Updateable<Grp_DayAndCost>()
  9352. .SetColumns(x => new Grp_DayAndCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  9353. .Where(x => x.DiId == groupId)
  9354. .ExecuteCommand();
  9355. _sqlSugar.Updateable<Grp_DayOtherPrice>()
  9356. .SetColumns(x => new Grp_DayOtherPrice() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  9357. .Where(x => x.Diid == groupId)
  9358. .ExecuteCommand();
  9359. _sqlSugar.Updateable<Grp_EnterExitCostPermission>()
  9360. .SetColumns(x => new Grp_EnterExitCostPermission() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  9361. .Where(x => x.GroupId == groupId)
  9362. .ExecuteCommand();
  9363. }
  9364. //执行insert
  9365. var insertId = _sqlSugar.Insertable(newExterData).ExecuteReturnIdentity();
  9366. if (insertId < 1)
  9367. {
  9368. _sqlSugar.RollbackTran();
  9369. return Ok(JsonView(false, "草稿数据导入失败!"));
  9370. }
  9371. if (newDayDatas.Any()) _sqlSugar.Insertable(newDayDatas).ExecuteCommand();
  9372. if (newOtherDatas.Any()) _sqlSugar.Insertable(newOtherDatas).ExecuteCommand();
  9373. #region 默认添加权限
  9374. #endregion
  9375. _sqlSugar.CommitTran();
  9376. //执行操作之后
  9377. //生成默认文件pdf并且通知人员
  9378. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  9379. {
  9380. DiId = groupId,
  9381. ExportType = 1,
  9382. SubTypeId = 1005
  9383. }, "pdf");
  9384. //发送通知
  9385. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  9386. string md5Sign = GeneralMethod.Encrypt($"{insertId}&fileName={fileUrl}");
  9387. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", insertId, fileUrl);
  9388. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(groupId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  9389. //汇率信息记录
  9390. await GeneralMethod.RateRecordSave(userId, insertId, "出入境费用-草稿导入");
  9391. return Ok(JsonView(true));
  9392. }
  9393. catch (Exception ex)
  9394. {
  9395. _sqlSugar.RollbackTran();
  9396. return Ok(JsonView(false, ex.Message));
  9397. }
  9398. }
  9399. #endregion
  9400. #region 团组经理模块 出入境费用 移动端(Android/IOS)
  9401. /// <summary>
  9402. /// 获取币种基础数据(含逻辑处理)
  9403. /// </summary>
  9404. /// <returns></returns>
  9405. private async Task<List<CurrencyInfo>> EnterExitCostMobileGetCurrencyInit()
  9406. {
  9407. return await GeneralMethod.EnterExitCostInitRate();
  9408. }
  9409. /// <summary>
  9410. /// 团组模块 - 出入境费用-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  9411. /// </summary>
  9412. /// <returns></returns>
  9413. [HttpPost]
  9414. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9415. public async Task<IActionResult> EnterExitCostMobileDataSource(EnterExitCostMobileDataSourceDto dto)
  9416. {
  9417. //验证城市归属并给默认值
  9418. int provinceId = dto.ProvinceId;
  9419. if (provinceId < 1) provinceId = 122;
  9420. var dataSource = await _sqlSugar
  9421. .Queryable<Sys_SetData>()
  9422. .Where(x => x.IsDel == 0 && (x.STid == 72 || x.STid == 73) && x.Remark.Contains(provinceId.ToString()))
  9423. .ToListAsync();
  9424. var fileTypes = new List<EecSetDataInfoView>();
  9425. //三公费用-Word明细类型
  9426. var wordTypeData = dataSource
  9427. .Where(it => it.STid == 72)
  9428. .Select(x => new EecSetDataInfoView
  9429. {
  9430. ParentId = 1,
  9431. Id = x.Id,
  9432. Name = x.Name
  9433. })
  9434. .ToArray();
  9435. if (wordTypeData.Any()) fileTypes.AddRange(wordTypeData);
  9436. var excelTypeData = dataSource
  9437. .Where(it => it.STid == 73)
  9438. .Select(x => new EecSetDataInfoView
  9439. {
  9440. ParentId = 2,
  9441. Id = x.Id,
  9442. Name = x.Name
  9443. })
  9444. .ToArray();
  9445. if (excelTypeData.Any()) fileTypes.AddRange(excelTypeData);
  9446. var groupNameList = new EecSetDataInfoView() { ParentId = 3, Id = 1, Name = "团组成员名单" };
  9447. fileTypes.Add(groupNameList);
  9448. fileTypes = fileTypes.OrderBy(x => x.ParentId).ThenBy(x => x.Id).ToList();
  9449. //默认币种显示
  9450. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  9451. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  9452. return Ok(JsonView(true, "查询成功!", new
  9453. {
  9454. FileTypeData = fileTypes,
  9455. CurrencyInit = _currencyInfos,
  9456. viewPermissionData = viewPermissionData
  9457. }));
  9458. }
  9459. /// <summary>
  9460. /// 团组模块 - 出入境费用-移动端 - 团组基础数据Data
  9461. /// </summary>
  9462. /// <returns></returns>
  9463. [HttpPost]
  9464. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9465. public async Task<IActionResult> EnterExitCostMobileGroupData(PostEnterExitCostMobileGroupDataDto dto)
  9466. {
  9467. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9468. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9469. RefAsync<int> total = 0;
  9470. int diId = 0;
  9471. var status = int.TryParse(dto.GroupName, out diId);
  9472. var basicUserId = await _enterExitCostRep.PermissionViewUsersAsync();
  9473. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  9474. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  9475. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  9476. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  9477. .OrderByDescending(x => x.VisitStartDate)
  9478. .Select(x => new EnterExitCostMobileGroupView()
  9479. {
  9480. Id = x.Id,
  9481. GroupName = x.TeamName,
  9482. IsNull = SqlFunc.Subqueryable<Grp_EnterExitCost>().Where(x1 => x1.DiId == x.Id && x1.IsDel == 0).Any() ? false : true,
  9483. IsView = SqlFunc.Subqueryable<Grp_EnterExitCostPermission>().Where(x1 => x1.GroupId == x.Id && x1.UserId == dto.CurrUserId).Any(),
  9484. ProvinceId = x.CityId
  9485. })
  9486. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9487. //处理省份Id
  9488. if (data.Any())
  9489. {
  9490. var provCityDatas = await _groupRepository.ProvinceCityBasicSource();
  9491. if (provCityDatas.Any())
  9492. {
  9493. foreach (var item in data)
  9494. {
  9495. var provinceId = item.ProvinceId;
  9496. var isDefualtVal = true;
  9497. if (provinceId > 0)
  9498. {
  9499. var parentId = _groupRepository.FindParentIdByChildId(provCityDatas, provinceId);
  9500. if (parentId != null)
  9501. {
  9502. isDefualtVal = false;
  9503. item.ProvinceId = (int)parentId;
  9504. }
  9505. }
  9506. if (isDefualtVal)
  9507. {
  9508. item.ProvinceId = 122; //默认四川
  9509. }
  9510. }
  9511. }
  9512. }
  9513. //处理是否显示
  9514. if (basicUserId.Any(x => x.Id == dto.CurrUserId))
  9515. {
  9516. foreach (var item in data)
  9517. {
  9518. item.IsView = true;
  9519. }
  9520. }
  9521. return Ok(JsonView(true, "查询成功!", data, total));
  9522. }
  9523. /// <summary>
  9524. /// 团组模块 - 出入境费用-移动端 - 币种基础数据Data
  9525. /// </summary>
  9526. /// <returns></returns>
  9527. [HttpPost]
  9528. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9529. public async Task<IActionResult> EnterExitCostMobileCurrencyData(PostEnterExitCostMobileCurrencyDataDto dto)
  9530. {
  9531. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9532. RefAsync<int> total = 0;
  9533. var data = await _sqlSugar.Queryable<Sys_SetData>()
  9534. .Where(x => x.IsDel == 0 && x.STid == 66)
  9535. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  9536. .Select(x => new
  9537. {
  9538. id = x.Id,
  9539. name = x.Name,
  9540. remark = x.Remark,
  9541. })
  9542. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9543. return Ok(JsonView(true, "查询成功!", data, total));
  9544. }
  9545. /// <summary>
  9546. /// 团组模块 - 出入境费用-移动端 - 其他款项 - 币种、费用类型基础数据Data
  9547. /// </summary>
  9548. /// <returns></returns>
  9549. [HttpPost]
  9550. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9551. public async Task<IActionResult> EnterExitCostMobileOtherItemCurrencyData(PostEnterExitCostMobileOtherItemCurrencyDataDto dto)
  9552. {
  9553. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9554. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9555. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType, dto.DiId, 98);
  9556. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  9557. var groupOtherRateData = groupRateData.TeamRates;
  9558. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  9559. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  9560. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  9561. groupOtherRateData = groupOtherRateData
  9562. .Select(x => new TeamRateDescAddCurrencyIdView
  9563. {
  9564. CurrencyId = x.CurrencyId,
  9565. CurrencyName = x.CurrencyName,
  9566. CurrencyCode = x.CurrencyCode,
  9567. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  9568. }).ToList();
  9569. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  9570. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  9571. }
  9572. /// <summary>
  9573. /// 团组模块 - 出入境费用-移动端 - 实时汇率、签证费用、机票费用 Tips
  9574. /// </summary>
  9575. /// <returns></returns>
  9576. [HttpPost]
  9577. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9578. public async Task<IActionResult> EnterExitCostMobileFeeTips(GetEnterExitCostMobileFeeTipsDto dto)
  9579. {
  9580. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9581. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9582. var tipsData = new List<int>() { 1, 2, 3 };
  9583. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  9584. if (dto.TipsType == 1)
  9585. {
  9586. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  9587. }
  9588. else if (dto.TipsType == 2)
  9589. {
  9590. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.GroupId);
  9591. return Ok(JsonView(true, "查询成功!", visaData.Data));
  9592. }
  9593. else if (dto.TipsType == 3)
  9594. {
  9595. var airData = await GeneralMethod.EntryAndExitTips(dto.GroupId);
  9596. return Ok(JsonView(true, "查询成功!", airData));
  9597. }
  9598. return Ok(JsonView(false));
  9599. }
  9600. /// <summary>
  9601. /// 团组模块 - 出入境国家费用标准-移动端 List
  9602. /// </summary>
  9603. /// <returns></returns>
  9604. [HttpPost]
  9605. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9606. public async Task<IActionResult> NationalTravelFeeMobileData(PostNationalTravelFeeMobileDataDto dto)
  9607. {
  9608. Stopwatch sw = new Stopwatch();
  9609. sw.Start();
  9610. int provinceId = dto.ProvinceId;
  9611. if (provinceId < 1) provinceId = 122; // 默认四川
  9612. RefAsync<int> total = 0;
  9613. var data = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  9614. .LeftJoin<Sys_SetData>((ntf, sd) => ntf.Currency == sd.Id)
  9615. .LeftJoin<Sys_Users>((ntf, sd, u) => ntf.CreateUserId == u.Id)
  9616. .LeftJoin<Sys_Cities>((ntf, sd, u, sd1) => ntf.ProvinceId == sd1.Id)
  9617. .Where((ntf, sd, u, sd1) => ntf.IsDel == 0 && ntf.ProvinceId == provinceId)
  9618. .WhereIF(!string.IsNullOrEmpty(dto.Search), (ntf, sd, u, sd1) => dto.Search.Contains(ntf.Country) || dto.Search.Contains(ntf.City))
  9619. .Select((ntf, sd, u, sd1) => new
  9620. {
  9621. Id = ntf.Id,
  9622. Area = $"{ntf.Country}-{ntf.City}",
  9623. Currency = ntf.Currency,
  9624. CurrencyCode = sd.Name,
  9625. CurrencyName = sd.Remark,
  9626. RoomCost = ntf.RoomCost,
  9627. FoodCost = ntf.FoodCost,
  9628. PublicCost = ntf.PublicCost,
  9629. TrainCost = ntf.TrainCost,
  9630. LastUpdateUserId = ntf.LastUpdateUserId,
  9631. LastUpdateUserName = u.CnName,
  9632. LastUpdateTime = ntf.LastUpdateTime
  9633. })
  9634. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9635. sw.Stop();
  9636. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", data, total));
  9637. }
  9638. /// <summary>
  9639. /// 团组模块 - 出入境费用-移动端 - Info
  9640. /// </summary>
  9641. /// <returns></returns>
  9642. [HttpPost]
  9643. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9644. public async Task<IActionResult> EnterExitCostMobileInfo(EnterExitCostInfobyDiIdDto dto)
  9645. {
  9646. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9647. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9648. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  9649. return Ok(data);
  9650. }
  9651. /// <summary>
  9652. /// 团组模块 - 出入境费用-移动端 - ParentInfo
  9653. /// </summary>
  9654. /// <returns></returns>
  9655. [HttpPost]
  9656. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9657. public async Task<IActionResult> EnterExitCostMobileParentInfo(EnterExitCostInfobyDiIdDto dto)
  9658. {
  9659. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9660. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9661. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9662. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  9663. var mobileInfo = new EnterExitCostMobileParentInfoView();
  9664. mobileInfo.DiId = dto.DiId;
  9665. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  9666. if (eecInfo == null) return Ok(mobileInfo);
  9667. //验证查看权限
  9668. (bool isView, bool isSet) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);
  9669. if (!isView) return Ok(JsonView(false, "没有查看权限!"));
  9670. mobileInfo = _mapper.Map<EnterExitCostMobileParentInfoView>(eecInfo);
  9671. mobileInfo.IsAssignPerm = isSet;
  9672. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCost>()
  9673. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9674. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9675. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  9676. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9677. {
  9678. SubId = dac.Id,
  9679. DiId = dac.DiId,
  9680. Type = dac.Type,
  9681. Days = dac.Days,
  9682. NationalTravelFeeId = dac.NationalTravelFeeId,
  9683. Arae = $"{ntf.Country}-{ntf.City}",
  9684. Cost = dac.Cost,
  9685. Currency = dac.Currency,
  9686. CurrencyName = sd.Name,
  9687. SubTotal = dac.SubTotal,
  9688. })
  9689. .ToList();
  9690. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  9691. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  9692. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  9693. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  9694. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  9695. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  9696. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  9697. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  9698. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  9699. //其他款项
  9700. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  9701. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9702. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9703. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  9704. .OrderBy((dop, sd1, sd2) => dop.Index)
  9705. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  9706. {
  9707. SubId = dop.Id,
  9708. DiId = dop.Diid,
  9709. Index = dop.Index,
  9710. SetDataId = dop.SetDataId,
  9711. SetDataName = sd1.Name,
  9712. Cost = dop.Cost,
  9713. Currency = dop.Currency,
  9714. CurrencyName = sd2.Remark,
  9715. SubTotal = dop.SubTotal,
  9716. Remark = dop.Remark,
  9717. })
  9718. .ToArray();
  9719. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  9720. return Ok(mobileInfo);
  9721. }
  9722. /// <summary>
  9723. /// 团组模块 - 出入境费用-移动端 - 查看权限用户
  9724. /// </summary>
  9725. /// <returns></returns>
  9726. [HttpPost]
  9727. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9728. public async Task<IActionResult> EnterExitCostMobileViewPermissionUsers(EnterExitCostMobileViewPermissionUsersDto dto)
  9729. {
  9730. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9731. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9732. //验证查看权限
  9733. (bool viewPerm, bool assignPerm) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);//分配权限
  9734. if (!viewPerm) return Ok(JsonView(false, "未分配查看权限,如要查看,请联系市场部或国交部负责人!"));
  9735. var userIds = await _sqlSugar
  9736. .Queryable<Grp_EnterExitCostPermission>()
  9737. .Where(x => x.IsDel == 0 && x.GroupId == dto.DiId)
  9738. .Select(x => x.UserId)
  9739. .ToArrayAsync();
  9740. var perUsers = await _enterExitCostRep.PermissionViewUsersAsync();
  9741. var perUsersView = new List<dynamic>();
  9742. foreach (var item in perUsers)
  9743. {
  9744. bool isView1 = false;
  9745. if (userIds.Any(x => x == item.Id)) isView1 = true;
  9746. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  9747. }
  9748. return Ok(JsonView(perUsersView));
  9749. }
  9750. /// <summary>
  9751. /// 团组模块 - 出入境费用-移动端 - SubInfo
  9752. /// </summary>
  9753. /// <returns></returns>
  9754. [HttpPost]
  9755. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9756. public async Task<IActionResult> EnterExitCostMobileSubInfo(PostEnterExitCostMobileSubInfoDto dto)
  9757. {
  9758. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9759. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9760. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9761. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  9762. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  9763. //验证查看权限
  9764. //(bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  9765. //if (!isView) return Ok(JsonView(false, msg));
  9766. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  9767. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  9768. var subType = dto.SubType;
  9769. if (subType == 1) //1:境内费用
  9770. {
  9771. var oneData = new ChoiceOneMobileSubInfoView()
  9772. {
  9773. Id = eecInfo.Id,
  9774. ChoiceOne = eecInfo.ChoiceOne,
  9775. ChoiceOneTotalCost = eecInfo.InsidePay,
  9776. Visa = eecInfo.Visa,
  9777. VisaRemark = eecInfo.VisaRemark,
  9778. YiMiao = eecInfo.YiMiao,
  9779. HeSuan = eecInfo.HeSuan,
  9780. Service = eecInfo.Service,
  9781. Ticket = eecInfo.Ticket,
  9782. Safe = eecInfo.Safe,
  9783. FirstItemRemark = eecInfo.FirstItemRemark
  9784. };
  9785. return Ok(JsonView(oneData));
  9786. }
  9787. else if (subType == 2) //2:国际旅费
  9788. {
  9789. var twoData = new ChoiceTwoMobileSubInfoView()
  9790. {
  9791. Id = eecInfo.Id,
  9792. ChoiceTwoJJ = eecInfo.SumJJC,
  9793. OutsideJJPay = eecInfo.OutsideJJPay,
  9794. ChoiceTwoGW = eecInfo.SumGWC,
  9795. OutsideGWPay = eecInfo.OutsideGWPay,
  9796. ChoiceTwoTD = eecInfo.SumTDC,
  9797. OutsideTDPay = eecInfo.OutsideTDPay,
  9798. AirJJ = eecInfo.AirJJ,
  9799. AirGW = eecInfo.AirGW,
  9800. AirTD = eecInfo.AirTD,
  9801. CityTranffic = eecInfo.CityTranffic,
  9802. TwoItemRemark = eecInfo.TwoItemRemark
  9803. };
  9804. return Ok(JsonView(twoData));
  9805. }
  9806. else if (subType == 3) //3:住宿费
  9807. {
  9808. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  9809. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9810. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9811. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 1)
  9812. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9813. {
  9814. SubId = dac.Id,
  9815. DiId = dac.DiId,
  9816. Type = dac.Type,
  9817. Days = dac.Days,
  9818. NationalTravelFeeId = dac.NationalTravelFeeId,
  9819. Arae = $"{ntf.Country}-{ntf.City}",
  9820. Cost = dac.Cost,
  9821. Currency = dac.Currency,
  9822. CurrencyName = sd.Name,
  9823. SubTotal = dac.SubTotal,
  9824. })
  9825. .ToArray();
  9826. var data = new ChoiceMobileSubInfo3To6View()
  9827. {
  9828. ParentId = eecInfo.Id,
  9829. Choice = eecInfo.ChoiceThree,
  9830. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9831. Details = dayAndCostDatas
  9832. };
  9833. return Ok(JsonView(data));
  9834. }
  9835. else if (subType == 4) //4:伙食费
  9836. {
  9837. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  9838. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9839. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9840. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 2)
  9841. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9842. {
  9843. SubId = dac.Id,
  9844. DiId = dac.DiId,
  9845. Type = dac.Type,
  9846. Days = dac.Days,
  9847. NationalTravelFeeId = dac.NationalTravelFeeId,
  9848. Arae = $"{ntf.Country}-{ntf.City}",
  9849. Cost = dac.Cost,
  9850. Currency = dac.Currency,
  9851. CurrencyName = sd.Name,
  9852. SubTotal = dac.SubTotal,
  9853. })
  9854. .ToArray();
  9855. var data = new ChoiceMobileSubInfo3To6View()
  9856. {
  9857. ParentId = eecInfo.Id,
  9858. Choice = eecInfo.ChoiceFour,
  9859. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9860. Details = dayAndCostDatas
  9861. };
  9862. return Ok(JsonView(data));
  9863. }
  9864. else if (subType == 5) //5:公杂费
  9865. {
  9866. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  9867. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9868. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9869. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 3)
  9870. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9871. {
  9872. SubId = dac.Id,
  9873. DiId = dac.DiId,
  9874. Type = dac.Type,
  9875. Days = dac.Days,
  9876. NationalTravelFeeId = dac.NationalTravelFeeId,
  9877. Arae = $"{ntf.Country}-{ntf.City}",
  9878. Cost = dac.Cost,
  9879. Currency = dac.Currency,
  9880. CurrencyName = sd.Name,
  9881. SubTotal = dac.SubTotal,
  9882. })
  9883. .ToArray();
  9884. var data = new ChoiceMobileSubInfo3To6View()
  9885. {
  9886. ParentId = eecInfo.Id,
  9887. Choice = eecInfo.ChoiceFive,
  9888. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9889. Details = dayAndCostDatas
  9890. };
  9891. return Ok(JsonView(data));
  9892. }
  9893. else if (subType == 6) //6:培训费
  9894. {
  9895. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  9896. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9897. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9898. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 4)
  9899. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9900. {
  9901. SubId = dac.Id,
  9902. DiId = dac.DiId,
  9903. Type = dac.Type,
  9904. Days = dac.Days,
  9905. NationalTravelFeeId = dac.NationalTravelFeeId,
  9906. Arae = $"{ntf.Country}-{ntf.City}",
  9907. Cost = dac.Cost,
  9908. Currency = dac.Currency,
  9909. CurrencyName = sd.Name,
  9910. SubTotal = dac.SubTotal,
  9911. })
  9912. .ToArray();
  9913. var data = new ChoiceMobileSubInfo3To6View()
  9914. {
  9915. ParentId = eecInfo.Id,
  9916. Choice = eecInfo.ChoiceSix,
  9917. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9918. Details = dayAndCostDatas
  9919. };
  9920. return Ok(JsonView(data));
  9921. }
  9922. else if (subType == 7) //7:其他
  9923. {
  9924. //其他款项
  9925. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  9926. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9927. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9928. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  9929. .OrderBy((dop, sd1, sd2) => dop.Index)
  9930. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  9931. {
  9932. SubId = dop.Id,
  9933. DiId = dop.Diid,
  9934. Index = dop.Index,
  9935. SetDataId = dop.SetDataId,
  9936. SetDataName = sd1.Name,
  9937. Cost = dop.Cost,
  9938. Currency = dop.Currency,
  9939. CurrencyName = sd2.Name,
  9940. SubTotal = dop.SubTotal,
  9941. Remark = dop.Remark,
  9942. })
  9943. .ToArray();
  9944. var data = new ChoiceSevenMobileSubInfoView()
  9945. {
  9946. ParentId = eecInfo.Id,
  9947. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  9948. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  9949. Details = otherData
  9950. };
  9951. return Ok(JsonView(data));
  9952. }
  9953. return Ok(JsonView(false));
  9954. }
  9955. #region op
  9956. ///// <summary>
  9957. ///// 移动端更新费用消息通知
  9958. ///// </summary>
  9959. ///// <param name="diid"></param>
  9960. ///// <param name="id"></param>
  9961. ///// <param name="currUserId"></param>
  9962. //private async Task EnterExitCostMobileOpNotice(int diid, int id, int currUserId)
  9963. //{
  9964. // try
  9965. // {
  9966. // ////生成默认文件pdf并且通知人员
  9967. // //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  9968. // //{
  9969. // // DiId = diid,
  9970. // // ExportType = 1,
  9971. // // SubTypeId = 1005
  9972. // //}, "pdf");
  9973. // ////发送通知
  9974. // //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  9975. // //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  9976. // //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  9977. // //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(diid, new List<string>() { "208", "233", "21" }, currUserId, url);
  9978. // ////汇率信息记录
  9979. // //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  9980. // }
  9981. // catch (Exception ex)
  9982. // {
  9983. // //记录日志
  9984. // throw;
  9985. // }
  9986. //}
  9987. /// <summary>
  9988. /// 验证出入境费用数据是否存在
  9989. /// 不存在添加
  9990. /// </summary>
  9991. /// <param name="diId"></param>
  9992. /// <param name="currUserId"></param>
  9993. /// <returns></returns>
  9994. /// <exception cref="CustomException"></exception>
  9995. private async Task<int> EnterExitCostVerifyIsNull(int diId, int currUserId)
  9996. {
  9997. var parentId = 0;
  9998. var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).OrderByDescending(x => x.CreateTime).FirstAsync();
  9999. if (info != null)
  10000. {
  10001. parentId = info.Id;
  10002. }
  10003. else
  10004. {
  10005. var currencys = await EnterExitCostMobileGetCurrencyInit();
  10006. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCost() { DiId = diId, CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  10007. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  10008. parentId = addId;
  10009. }
  10010. return parentId;
  10011. }
  10012. /// <summary>
  10013. /// 团组模块 - 出入境费用-移动端 - 设置view权限
  10014. /// </summary>
  10015. /// <returns></returns>
  10016. [HttpPost]
  10017. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10018. public async Task<IActionResult> EnterExitCostMobileSetViewPermissiion(EnterExitCostMobileSetViewPermissiionDto dto)
  10019. {
  10020. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10021. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10022. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  10023. //验证编辑权限
  10024. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10025. //if (!isEdit) return Ok(JsonView(false, msg));
  10026. var permissions = new List<Grp_EnterExitCostPermission>();
  10027. foreach (var userId in dto.UserIds)
  10028. {
  10029. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = userId, CreateUserId = dto.CurrUserId });
  10030. }
  10031. if (permissions.Any())
  10032. {
  10033. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  10034. {
  10035. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  10036. }
  10037. _sqlSugar.BeginTran();
  10038. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.DiId).ExecuteCommandAsync();
  10039. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  10040. if (result < 1)
  10041. {
  10042. _sqlSugar.RollbackTran();
  10043. return Ok(JsonView(false));
  10044. }
  10045. _sqlSugar.CommitTran();
  10046. return Ok(JsonView(true));
  10047. }
  10048. return Ok(JsonView(false));
  10049. }
  10050. /// <summary>
  10051. /// 团组模块 - 出入境费用-移动端 - OP --> 汇率
  10052. /// </summary>
  10053. /// <returns></returns>
  10054. [HttpPost]
  10055. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10056. public async Task<IActionResult> EnterExitCostMobileOpRate(PostEnterExitCostMobileFeeRateOpDto dto)
  10057. {
  10058. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10059. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10060. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10061. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  10062. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  10063. int id = dto.Id;
  10064. if (id <= 0) //add
  10065. {
  10066. //int provinceId = dto.ProvinceId;
  10067. int groupId = dto.DiId;
  10068. //if (provinceId < 1) provinceId = 122;
  10069. var info = new Grp_EnterExitCost() { DiId = groupId, CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId };
  10070. var add = await _sqlSugar.Insertable(info).ExecuteCommandAsync();
  10071. if (add < 1) return Ok(JsonView(false));
  10072. id = add;
  10073. }
  10074. else //update
  10075. {
  10076. ////验证编辑权限
  10077. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10078. //if (!isEdit) return Ok(JsonView(false, msg));
  10079. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>().SetColumns(x => new Grp_EnterExitCost() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.Id).ExecuteCommandAsync();
  10080. if (upd < 1) return Ok(JsonView(false));
  10081. }
  10082. #region 汇率变更时更改币种相关费用
  10083. var opDayCosts = new List<Grp_DayAndCost>();
  10084. var opDayOtherCosts = new List<Grp_DayOtherPrice>();
  10085. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  10086. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCost>()
  10087. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  10088. .Where((dac, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  10089. .Select((dac, sd) => new
  10090. {
  10091. dac.Id,
  10092. dac.DiId,
  10093. CurrencyCode = sd.Name,
  10094. dac.Cost
  10095. })
  10096. .ToList();
  10097. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  10098. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  10099. .Where((dop, sd) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  10100. .Select((dop, sd) => new
  10101. {
  10102. dop.Id,
  10103. dop.Diid,
  10104. CurrencyCode = sd.Name,
  10105. dop.Cost
  10106. })
  10107. .ToList();
  10108. if (dayCosts.Count > 0)
  10109. {
  10110. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  10111. foreach (var dc in new_dayCosts)
  10112. {
  10113. var thisCurrency = dc.Key.ToUpper();
  10114. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  10115. if (thisRate == 0.00M) continue;
  10116. foreach (var dcSub in dc)
  10117. {
  10118. opDayCosts.Add(new Grp_DayAndCost()
  10119. {
  10120. Id = dcSub.Id,
  10121. DiId = dcSub.DiId,
  10122. Cost = dcSub.Cost,
  10123. SubTotal = dcSub.Cost * thisRate,
  10124. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  10125. });
  10126. }
  10127. }
  10128. if (opDayCosts.Count > 0)
  10129. {
  10130. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  10131. }
  10132. }
  10133. if (dayOtherCosts.Count > 0)
  10134. {
  10135. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  10136. foreach (var dc in new_dayOtherCosts)
  10137. {
  10138. var thisCurrency = dc.Key.ToUpper();
  10139. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  10140. if (thisRate == 0.00M) continue;
  10141. foreach (var dcSub in dc)
  10142. {
  10143. opDayOtherCosts.Add(new Grp_DayOtherPrice()
  10144. {
  10145. Id = dcSub.Id,
  10146. Diid = dcSub.Diid,
  10147. Cost = dcSub.Cost,
  10148. SubTotal = dcSub.Cost * thisRate,
  10149. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  10150. });
  10151. }
  10152. }
  10153. if (opDayOtherCosts.Count > 0)
  10154. {
  10155. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  10156. }
  10157. }
  10158. #endregion
  10159. //消息通知
  10160. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10161. //汇率信息记录
  10162. await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  10163. return Ok(JsonView(new { parentId = id }));
  10164. }
  10165. /// <summary>
  10166. /// 团组模块 - 出入境费用-移动端 - OP --> 复选框
  10167. /// </summary>
  10168. /// <returns></returns>
  10169. [HttpPost]
  10170. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10171. public async Task<IActionResult> EnterExitCostMobileOpCheckbox(PostEnterExitCostMobileFeeOpCheckboxDto dto)
  10172. {
  10173. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10174. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10175. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10176. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10177. var checkboxInfo = _mapper.Map<Grp_EnterExitCost>(dto);
  10178. int id = dto.Id;
  10179. if (id <= 0) //add
  10180. {
  10181. checkboxInfo.CreateUserId = dto.CurrUserId;
  10182. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  10183. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  10184. if (add < 1) return Ok(JsonView(false));
  10185. }
  10186. else //update
  10187. {
  10188. ////验证编辑权限
  10189. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10190. //if (!isEdit) return Ok(JsonView(false, msg));
  10191. var upd = await _sqlSugar.Updateable(checkboxInfo)
  10192. .UpdateColumns(x => new
  10193. {
  10194. x.ChoiceOne,
  10195. x.ChoiceTwo,
  10196. x.SumJJC,
  10197. x.SumGWC,
  10198. x.SumTDC,
  10199. x.ChoiceThree,
  10200. x.ChoiceFour,
  10201. x.ChoiceFive,
  10202. x.ChoiceSix,
  10203. x.OtherExpenses_Checked
  10204. })
  10205. .Where(x => x.Id == id)
  10206. .ExecuteCommandAsync();
  10207. if (upd < 1) return Ok(JsonView(false));
  10208. }
  10209. return Ok(JsonView(new { parentId = id }));
  10210. }
  10211. /// <summary>
  10212. /// 团组模块 - 出入境费用-移动端 - OP --> 3-7项复选框单个复选框更改
  10213. /// </summary>
  10214. /// <returns></returns>
  10215. [HttpPost]
  10216. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10217. public async Task<IActionResult> EnterExitCostMobileOpSingleCheckbox(EnterExitCostMobileOpSingleCheckboxDto dto)
  10218. {
  10219. int itemTypeId = dto.ItemType, id = dto.Id, currUserId = dto.CurrUserId, diId = dto.DiId, isSelected = dto.IsSelected;
  10220. // if (provinceId < 1) provinceId = 122;
  10221. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  10222. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10223. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10224. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10225. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  10226. var checkboxInfo = new Grp_EnterExitCost()
  10227. {
  10228. Id = id,
  10229. //ProvinceId = provinceId,
  10230. DiId = diId,
  10231. CreateUserId = currUserId
  10232. };
  10233. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  10234. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  10235. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  10236. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  10237. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  10238. if (id <= 0) //add
  10239. {
  10240. checkboxInfo.CreateUserId = dto.CurrUserId;
  10241. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  10242. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  10243. if (add < 1) return Ok(JsonView(false));
  10244. }
  10245. else //update
  10246. {
  10247. ////验证编辑权限
  10248. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10249. //if (!isEdit) return Ok(JsonView(false, msg));
  10250. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>()
  10251. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  10252. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  10253. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  10254. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  10255. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  10256. .Where(x => x.Id == id)
  10257. .ExecuteCommandAsync();
  10258. if (upd < 1) return Ok(JsonView(false));
  10259. }
  10260. return Ok(JsonView(new { parentId = id }));
  10261. }
  10262. /// <summary>
  10263. /// 团组模块 - 出入境费用-移动端 - OP --> 境内费用 Step1
  10264. /// </summary>
  10265. /// <returns></returns>
  10266. [HttpPost]
  10267. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10268. public async Task<IActionResult> EnterExitCostMobileOpStep1(PostEnterExitCostMobileOpStep1Dto dto)
  10269. {
  10270. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10271. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10272. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10273. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10274. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  10275. info.FirstItemRemark = dto.FirstItemRemark;
  10276. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  10277. int id = dto.Id;
  10278. if (id <= 0) //add
  10279. {
  10280. info.CreateUserId = dto.CurrUserId;
  10281. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  10282. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  10283. if (add < 1) return Ok(JsonView(false));
  10284. id = add;
  10285. }
  10286. else //update
  10287. {
  10288. ////验证编辑权限
  10289. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10290. //if (!isEdit) return Ok(JsonView(false, msg));
  10291. var upd = await _sqlSugar.Updateable(info)
  10292. .UpdateColumns(x => new
  10293. {
  10294. x.ChoiceOne,
  10295. x.InsidePay,
  10296. x.VisaRemark,
  10297. x.Visa,
  10298. x.Service,
  10299. x.Safe,
  10300. x.Ticket,
  10301. x.HeSuan,
  10302. x.YiMiao,
  10303. x.FirstItemRemark
  10304. })
  10305. .Where(x => x.Id == id)
  10306. .ExecuteCommandAsync();
  10307. if (upd < 1) return Ok(JsonView(false));
  10308. }
  10309. //消息通知
  10310. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10311. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  10312. }
  10313. /// <summary>
  10314. /// 团组模块 - 出入境费用-移动端 - OP --> 国际旅费 Step2
  10315. /// </summary>
  10316. /// <returns></returns>
  10317. [HttpPost]
  10318. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10319. public async Task<IActionResult> EnterExitCostMobileOpStep2(PostEnterExitCostMobileOpStep2Dto dto)
  10320. {
  10321. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10322. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10323. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10324. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10325. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  10326. info.DiId = dto.DiId;
  10327. //info.ProvinceId = dto.ProvinceId;
  10328. info.OutsideJJPay = dto.OutsideJJPay;
  10329. info.OutsideGWPay = dto.OutsideGWPay;
  10330. info.OutsideTDPay = dto.OutsideTDPay;
  10331. info.AirJJ = dto.AirJJ;
  10332. info.AirGW = dto.AirGW;
  10333. info.AirTD = dto.AirTD;
  10334. info.CityTranffic = dto.CityTranffic;
  10335. info.TwoItemRemark = dto.TwoItemRemark;
  10336. info.SumJJC = dto.ChoiceTwoJJ;
  10337. info.SumGWC = dto.ChoiceTwoGW;
  10338. info.SumTDC = dto.ChoiceTwoTD;
  10339. int id = dto.Id;
  10340. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  10341. if (id <= 0) //add
  10342. {
  10343. info.CreateUserId = dto.CurrUserId;
  10344. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  10345. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  10346. if (addId <= 0) return Ok(JsonView(false));
  10347. id = addId;
  10348. }
  10349. else //update
  10350. {
  10351. ////验证编辑权限
  10352. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10353. //if (!isEdit) return Ok(JsonView(false, msg));
  10354. var upd = await _sqlSugar.Updateable(info)
  10355. .UpdateColumns(x => new
  10356. {
  10357. x.SumJJC,
  10358. x.OutsideJJPay,
  10359. x.SumGWC,
  10360. x.OutsideGWPay,
  10361. x.SumTDC,
  10362. x.OutsideTDPay,
  10363. x.AirJJ,
  10364. x.AirGW,
  10365. x.AirTD,
  10366. x.CityTranffic,
  10367. x.TwoItemRemark
  10368. })
  10369. .Where(x => x.Id == id)
  10370. .ExecuteCommandAsync();
  10371. if (upd < 1) return Ok(JsonView(false));
  10372. }
  10373. jjcItemTotal = info.AirJJ + info.CityTranffic;
  10374. gwcItemTotal = info.AirGW + info.CityTranffic;
  10375. tdcItemTotal = info.AirTD + info.CityTranffic;
  10376. //消息通知
  10377. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10378. return Ok(JsonView(new
  10379. {
  10380. parentId = id,
  10381. choiceTwoJJ = dto.ChoiceTwoJJ,
  10382. jjcItemTotal = jjcItemTotal,
  10383. choiceTwoGW = dto.ChoiceTwoGW,
  10384. gwcItemTotal = gwcItemTotal,
  10385. choiceTwoTD = dto.ChoiceTwoTD,
  10386. tdcItemTotal = tdcItemTotal
  10387. }));
  10388. }
  10389. /// <summary>
  10390. /// 团组模块 - 出入境费用-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  10391. /// </summary>
  10392. /// <returns></returns>
  10393. [HttpPost]
  10394. [ApiExplorerSettings(IgnoreApi = true)]
  10395. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10396. public async Task<IActionResult> EnterExitCostMobileOpBatchStep3To6(PostEnterExitCostMobileOpStep3To6Dto dto)
  10397. {
  10398. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10399. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10400. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10401. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  10402. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  10403. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  10404. var infos1 = _mapper.Map<List<Grp_DayAndCost>>(dto.Infos);
  10405. var infos = infos1.Select(x => new Grp_DayAndCost
  10406. {
  10407. Id = x.Id,
  10408. DiId = dto.DiId,
  10409. Type = dto.FeeType,
  10410. Days = x.Days,
  10411. NationalTravelFeeId = x.NationalTravelFeeId,
  10412. Cost = x.Cost,
  10413. Currency = x.Currency,
  10414. SubTotal = x.SubTotal,
  10415. CreateUserId = dto.CurrUserId
  10416. })
  10417. .ToList();
  10418. var adds = infos.Where(x => x.Id <= 0).ToList();
  10419. var upds = infos.Where(x => x.Id > 0).ToList();
  10420. if (adds.Count > 0)
  10421. {
  10422. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  10423. if (add < 1) return Ok(JsonView(false));
  10424. }
  10425. if (upds.Count > 0)
  10426. {
  10427. var upd = await _sqlSugar.Updateable(adds)
  10428. .UpdateColumns(x => new
  10429. {
  10430. x.Days,
  10431. x.NationalTravelFeeId,
  10432. x.Cost,
  10433. x.Currency,
  10434. x.SubTotal
  10435. })
  10436. .WhereColumns(x => new { x.Id })
  10437. .ExecuteCommandAsync();
  10438. if (upd < 1) return Ok(JsonView(false));
  10439. }
  10440. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  10441. //消息通知
  10442. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  10443. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10444. return Ok(JsonView(new { itemTotal = itemTotal }));
  10445. }
  10446. /// <summary>
  10447. /// 团组模块 - 出入境费用-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  10448. /// </summary>
  10449. /// <returns></returns>
  10450. [HttpPost]
  10451. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10452. public async Task<IActionResult> EnterExitCostMobileOpSingleStep3To6(PostEnterExitCostMobileOpSingleStep3To6Dto dto)
  10453. {
  10454. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  10455. int subId = dto.SubId, feeType = dto.FeeType;
  10456. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10457. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10458. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10459. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  10460. var subInfo = _mapper.Map<Grp_DayAndCost>(dto);
  10461. subInfo.Id = subId;
  10462. subInfo.DiId = dto.DiId;
  10463. if (feeType == 3) subInfo.Type = 1;
  10464. else if (feeType == 4) subInfo.Type = 2;
  10465. else if (feeType == 5) subInfo.Type = 3;
  10466. else if (feeType == 6) subInfo.Type = 4;
  10467. subInfo.CreateUserId = dto.CurrUserId;
  10468. int parentId = await EnterExitCostVerifyIsNull(dto.DiId, dto.CurrUserId); //主表验证
  10469. if (parentId < 1) return Ok(JsonView(false));
  10470. //子表op
  10471. if (subId < 1)
  10472. {
  10473. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  10474. if (subAdd < 1) return Ok(JsonView(false));
  10475. }
  10476. else
  10477. {
  10478. ////验证编辑权限
  10479. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10480. //if (!isEdit) return Ok(JsonView(false, msg));
  10481. var subUpd = await _sqlSugar.Updateable(subInfo)
  10482. .UpdateColumns(x => new
  10483. {
  10484. x.Days,
  10485. x.NationalTravelFeeId,
  10486. x.Cost,
  10487. x.Currency,
  10488. x.SubTotal
  10489. })
  10490. .WhereColumns(x => new { x.Id })
  10491. .ExecuteCommandAsync();
  10492. if (subUpd < 1) return Ok(JsonView(false));
  10493. }
  10494. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == feeType).Sum(x => x.SubTotal);
  10495. //await EnterExitCostMobileOpNotice(dto.DiId, parentId, dto.CurrUserId);
  10496. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  10497. }
  10498. /// <summary>
  10499. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-批量 Step7
  10500. /// </summary>
  10501. /// <returns></returns>
  10502. [HttpPost]
  10503. [ApiExplorerSettings(IgnoreApi = true)]
  10504. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10505. public async Task<IActionResult> EnterExitCostMobileOpBatchStep7(PostEnterExitCostMobileOpStep7Dto dto)
  10506. {
  10507. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10508. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10509. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10510. var infos1 = _mapper.Map<List<Grp_DayOtherPrice>>(dto.Infos);
  10511. var infos = infos1.Select(x => new Grp_DayOtherPrice()
  10512. {
  10513. Id = x.Id,
  10514. Diid = dto.DiId,
  10515. SetDataId = x.SetDataId,
  10516. Index = x.Index,
  10517. Cost = x.Cost,
  10518. Currency = x.Currency,
  10519. SubTotal = x.SubTotal,
  10520. CreateUserId = dto.CurrUserId,
  10521. Remark = x.Remark
  10522. }).ToList();
  10523. var adds = infos.Where(x => x.Id <= 0).ToList();
  10524. var upds = infos.Where(x => x.Id > 0).ToList();
  10525. if (adds.Count > 0)
  10526. {
  10527. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  10528. if (add < 1) return Ok(JsonView(false));
  10529. }
  10530. if (upds.Count > 0)
  10531. {
  10532. var upd = await _sqlSugar.Updateable(adds)
  10533. .UpdateColumns(x => new
  10534. {
  10535. x.Index,
  10536. x.SetDataId,
  10537. x.Cost,
  10538. x.Currency,
  10539. x.SubTotal,
  10540. x.Remark
  10541. })
  10542. .WhereColumns(x => new { x.Id })
  10543. .ExecuteCommandAsync();
  10544. if (upd < 1) return Ok(JsonView(false));
  10545. }
  10546. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == dto.DiId).Sum(x => x.SubTotal);
  10547. //消息通知
  10548. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  10549. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10550. return Ok(JsonView(new { itemTotal = itemTotal }));
  10551. }
  10552. /// <summary>
  10553. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-单条 Step7
  10554. /// </summary>
  10555. /// <returns></returns>
  10556. [HttpPost]
  10557. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10558. public async Task<IActionResult> EnterExitCostMobileOpSingleStep7(PostEnterExitCostMobileOpSingleStep7Dto dto)
  10559. {
  10560. int subId = dto.SubId;
  10561. int diId = dto.Diid;
  10562. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10563. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10564. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10565. var subInfo = _mapper.Map<Grp_DayOtherPrice>(dto);
  10566. subInfo.Id = subId;
  10567. subInfo.Diid = dto.Diid;
  10568. subInfo.CreateUserId = dto.CurrUserId;
  10569. int parentId = await EnterExitCostVerifyIsNull(diId, dto.CurrUserId); //主表验证
  10570. if (parentId < 1) return Ok(JsonView(false));
  10571. #region 子表op
  10572. if (subId < 1)//add
  10573. {
  10574. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  10575. if (subAdd < 1) return Ok(JsonView(false));
  10576. }
  10577. else //upd
  10578. {
  10579. ////验证编辑权限
  10580. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.Diid, dto.CurrUserId, 2);
  10581. //if (!isEdit) return Ok(JsonView(false, msg));
  10582. var subUpd = await _sqlSugar.Updateable(subInfo)
  10583. .UpdateColumns(x => new
  10584. {
  10585. x.Index,
  10586. x.SetDataId,
  10587. x.Cost,
  10588. x.Currency,
  10589. x.SubTotal,
  10590. x.Remark
  10591. })
  10592. .WhereColumns(x => new { x.Id })
  10593. .ExecuteCommandAsync();
  10594. if (subUpd < 1) return Ok(JsonView(false));
  10595. }
  10596. #endregion
  10597. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == diId).Sum(x => x.SubTotal);
  10598. //消息通知
  10599. //await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  10600. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  10601. }
  10602. /// <summary>
  10603. /// 团组模块 - 出入境费用-移动端 - 3-6子项删除
  10604. /// </summary>
  10605. /// <returns></returns>
  10606. [HttpPost]
  10607. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10608. public async Task<IActionResult> EnterExitCostMobileSubItemDel(EnterExitCostSubItemDelDto dto)
  10609. {
  10610. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  10611. if (data.Code != 0)
  10612. {
  10613. return Ok(JsonView(false, data.Msg));
  10614. }
  10615. return Ok(JsonView(true, "操作成功!", data.Data));
  10616. }
  10617. /// <summary>
  10618. /// 团组模块 - 出入境费用-移动端 - 其他费用删除
  10619. /// </summary>
  10620. /// <param name="dto"></param>
  10621. /// <returns></returns>
  10622. [HttpPost]
  10623. public IActionResult EnterExitCostMobileOtherFeeDel(EnterExitCostSubItemDelDto dto)
  10624. {
  10625. var data = new Grp_DayOtherPrice()
  10626. {
  10627. Id = dto.Id,
  10628. IsDel = 1,
  10629. DeleteUserId = dto.DeleteUserId,
  10630. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  10631. };
  10632. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  10633. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  10634. return Ok(JsonView(false, "删除失败!"));
  10635. }
  10636. #endregion
  10637. #endregion
  10638. #region 团组经理模块 出入境费用-草稿 移动端(Android/IOS)
  10639. /// <summary>
  10640. /// 团组模块 - 出入境费用-草稿 - 基础数据源 - 省份归属
  10641. /// </summary>
  10642. /// <returns></returns>
  10643. [HttpGet]
  10644. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10645. public async Task<IActionResult> EnterExitDraftMobileProvBelongCostDataSource()
  10646. {
  10647. var provData = await _groupRepository.ProvinceBasicSource();
  10648. return Ok(JsonView(true, "查询成功!", provData));
  10649. }
  10650. /// <summary>
  10651. /// 团组模块 - 出入境费用-草稿-移动端 - 草稿名称数据Data
  10652. /// </summary>
  10653. /// <returns></returns>
  10654. [HttpPost]
  10655. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10656. public async Task<IActionResult> EnterExitCostDraftMobileNameData(EnterExitCostDraftMobileNameDataDto dto)
  10657. {
  10658. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10659. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10660. RefAsync<int> total = 0;
  10661. var data = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  10662. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.DraftName))
  10663. .WhereIF(!string.IsNullOrEmpty(dto.DraftName), x => x.DraftName.Contains(dto.DraftName))
  10664. .Select(x => new
  10665. {
  10666. Id = x.Id,
  10667. DraftName = x.DraftName,
  10668. IsViewOrEdit = SqlFunc.Subqueryable<Grp_EnterExitCostDraftPermission>()
  10669. .Where(x1 => x1.IsDel == 0 && x1.Permission == 1 && x1.DraftId == x.Id && x1.UserId == dto.CurrUserId)
  10670. .Any()
  10671. })
  10672. .OrderByDescending(x => x.Id)
  10673. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10674. return Ok(JsonView(true, "查询成功!", data, total));
  10675. }
  10676. /// <summary>
  10677. /// 出入境费用-草稿 移动端
  10678. /// 获取币种基础数据(含逻辑处理)
  10679. /// </summary>
  10680. /// <returns></returns>
  10681. private async Task<List<CurrencyInfo>> EnterExitCostDraftMobileGetCurrencyInit()
  10682. {
  10683. return await GeneralMethod.EnterExitCostInitRate();
  10684. }
  10685. /// <summary>
  10686. /// 团组模块 - 出入境费用-草稿-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  10687. /// </summary>
  10688. /// <returns></returns>
  10689. [HttpPost]
  10690. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10691. public async Task<IActionResult> EnterExitCostDraftMobileDataSource(EnterExitCostDraftMobileDataSourceDto dto)
  10692. {
  10693. //验证城市归属并给默认值
  10694. int provinceId = dto.ProvinceId;
  10695. if (provinceId < 1) provinceId = 122;
  10696. var dataSource = await _sqlSugar
  10697. .Queryable<Sys_SetData>()
  10698. .Where(x => x.IsDel == 0 && (x.STid == 72 || x.STid == 73) && x.Remark.Contains(provinceId.ToString()))
  10699. .ToListAsync();
  10700. //三公费用-Word明细类型
  10701. var wordTypeData = dataSource.Where(it => it.STid == 72)
  10702. .Select(x => new SetDataInfoView
  10703. {
  10704. Id = x.Id,
  10705. Name = x.Name,
  10706. Remark = x.Remark
  10707. })
  10708. .ToList();
  10709. //三公费用-Excel明细类型
  10710. var excelTypeData = dataSource.Where(it => it.STid == 73)
  10711. .Select(x => new SetDataInfoView
  10712. {
  10713. Id = x.Id,
  10714. Name = x.Name,
  10715. Remark = x.Remark
  10716. })
  10717. .ToList();
  10718. //默认币种显示
  10719. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  10720. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  10721. return Ok(JsonView(true, "查询成功!", new
  10722. {
  10723. WordTypeData = wordTypeData,
  10724. ExcelTypeData = excelTypeData,
  10725. CurrencyInit = _currencyInfos,
  10726. viewPermissionData = viewPermissionData
  10727. }));
  10728. }
  10729. /// <summary>
  10730. /// 团组模块 - 出入境费用-草稿-移动端 - 团组基础数据Data
  10731. /// </summary>
  10732. /// <returns></returns>
  10733. [HttpPost]
  10734. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10735. public async Task<IActionResult> EnterExitCostDraftMobileGroupData(PostEnterExitCostDraftMobileGroupDataDto dto)
  10736. {
  10737. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10738. RefAsync<int> total = 0;
  10739. int diId = 0;
  10740. var status = int.TryParse(dto.GroupName, out diId);
  10741. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  10742. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  10743. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  10744. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  10745. .OrderByDescending(x => x.VisitStartDate)
  10746. .Select(x => new
  10747. {
  10748. Id = x.Id,
  10749. GroupName = x.TeamName
  10750. })
  10751. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10752. return Ok(JsonView(true, "查询成功!", data, total));
  10753. }
  10754. /// <summary>
  10755. /// 团组模块 - 出入境费用-草稿-移动端 - 币种基础数据Data
  10756. /// </summary>
  10757. /// <returns></returns>
  10758. [HttpPost]
  10759. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10760. public async Task<IActionResult> EnterExitCostDraftMobileCurrencyData(PostEnterExitCostDraftMobileCurrencyDataDto dto)
  10761. {
  10762. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10763. RefAsync<int> total = 0;
  10764. var data = await _sqlSugar.Queryable<Sys_SetData>()
  10765. .Where(x => x.IsDel == 0 && x.STid == 66)
  10766. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  10767. .Select(x => new
  10768. {
  10769. id = x.Id,
  10770. name = x.Name,
  10771. remark = x.Remark,
  10772. })
  10773. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10774. return Ok(JsonView(true, "查询成功!", data, total));
  10775. }
  10776. /// <summary>
  10777. /// 团组模块 - 出入境费用-草稿-移动端 - 其他款项 - 币种、费用类型基础数据Data
  10778. /// </summary>
  10779. /// <returns></returns>
  10780. [HttpPost]
  10781. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10782. public async Task<IActionResult> EnterExitCostDraftMobileOtherItemCurrencyData(PostEnterExitCostDraftMobileOtherItemCurrencyDataDto dto)
  10783. {
  10784. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10785. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10786. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(1, 2477, 98);
  10787. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  10788. var groupOtherRateData = groupRateData.TeamRates;
  10789. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  10790. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  10791. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  10792. groupOtherRateData = groupOtherRateData
  10793. .Select(x => new TeamRateDescAddCurrencyIdView
  10794. {
  10795. CurrencyId = x.CurrencyId,
  10796. CurrencyName = x.CurrencyName,
  10797. CurrencyCode = x.CurrencyCode,
  10798. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  10799. }).ToList();
  10800. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  10801. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  10802. }
  10803. /// <summary>
  10804. /// 团组模块 - 出入境费用-草稿-移动端 - 实时汇率、签证费用、机票费用 Tips
  10805. /// </summary>
  10806. /// <returns></returns>
  10807. [HttpPost]
  10808. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10809. public async Task<IActionResult> EnterExitCostDraftMobileFeeTips(EnterExitCostDraftMobileFeeTipsDto dto)
  10810. {
  10811. int portType = dto.PortType;
  10812. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10813. var tipsData = new List<int>() { 1, 2, 3 };
  10814. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  10815. if (dto.TipsType == 1)
  10816. {
  10817. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  10818. }
  10819. else if (dto.TipsType == 2)
  10820. {
  10821. if (portType == 2)
  10822. {
  10823. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10824. }
  10825. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10826. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  10827. .Select(x => x.NationalTravelFeeId)
  10828. .Distinct()
  10829. .ToListAsync();
  10830. if (portType == 2)
  10831. {
  10832. if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  10833. }
  10834. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  10835. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  10836. .Select(x => x.Country)
  10837. .Distinct()
  10838. .ToArrayAsync();
  10839. if (portType == 2)
  10840. {
  10841. if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  10842. }
  10843. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  10844. return Ok(JsonView(true, "查询成功!", new
  10845. {
  10846. totalAmt = totalAmt,
  10847. remark = remark
  10848. }));
  10849. }
  10850. else if (dto.TipsType == 3)
  10851. {
  10852. return Ok(JsonView(false, "暂无机票费用提示信息!"));
  10853. }
  10854. return Ok(JsonView(false));
  10855. }
  10856. /// <summary>
  10857. /// 团组模块 - 出入境费用-草稿-移动端 - 创建
  10858. /// </summary>
  10859. /// <returns></returns>
  10860. [HttpPost]
  10861. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10862. public async Task<IActionResult> EnterExitCostDraftMobileCreate(EnterExitCostDraftMobileCreateDto dto)
  10863. {
  10864. if (string.IsNullOrEmpty(dto.DraftName)) return Ok(JsonView(false, "草稿名称为空!"));
  10865. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10866. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10867. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DraftName.Equals(dto.DraftName) && it.IsDel == 0);
  10868. if (eecInfo != null) return Ok(JsonView(false, "草稿名称重复!"));
  10869. var rateInfos = await EnterExitCostMobileGetCurrencyInit();
  10870. var info = new Grp_EnterExitCostDraft()
  10871. {
  10872. ProvinceId = dto.ProvinceId,
  10873. DraftName = dto.DraftName,
  10874. CurrencyRemark = CommonFun.GetCurrencyChinaToString(rateInfos),
  10875. CreateUserId = dto.CurrUserId
  10876. };
  10877. _sqlSugar.BeginTran();
  10878. var draftId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  10879. if (draftId < 1)
  10880. {
  10881. _sqlSugar.RollbackTran();
  10882. return Ok(JsonView(false, "草稿创建失败!"));
  10883. }
  10884. //添加默认权限
  10885. await _enterExitCostDraftRep.InitPerm(draftId, dto.CurrUserId);
  10886. _sqlSugar.CommitTran();
  10887. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(draftId, dto.CurrUserId);
  10888. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  10889. mobileInfo.Id = draftId;
  10890. mobileInfo.DraftName = dto.DraftName;
  10891. mobileInfo.Currencys = rateInfos;
  10892. mobileInfo.IsAssignPerm = assignPerm;
  10893. return Ok(JsonView(mobileInfo));
  10894. }
  10895. /// <summary>
  10896. /// 出入境费用-草稿-移动端 查看编辑提示消息
  10897. /// </summary>
  10898. private static string _viewPermStr = $"未分配查看权限,如要查看,请联系市场部或国交部负责人!";
  10899. /// <summary>
  10900. /// 团组模块 - 出入境费用-草稿-移动端 - ParentInfo
  10901. /// </summary>
  10902. /// <returns></returns>
  10903. [HttpPost]
  10904. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10905. public async Task<IActionResult> EnterExitCostDraftMobileParentInfo(EnterExitCostDraftMobileParentInfoDto dto)
  10906. {
  10907. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10908. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10909. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  10910. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  10911. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  10912. if (eecInfo == null) return Ok(JsonView(mobileInfo));
  10913. //验证查看编辑权限
  10914. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  10915. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  10916. mobileInfo = _mapper.Map<EnterExitCostDraftMobileParentInfoView>(eecInfo);
  10917. mobileInfo.ProvinceId = eecInfo.ProvinceId;
  10918. mobileInfo.IsAssignPerm = assignPerm;
  10919. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10920. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10921. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10922. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  10923. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  10924. {
  10925. ParentId = dac.ParentId,
  10926. SubId = dac.Id,
  10927. Type = dac.Type,
  10928. Days = dac.Days,
  10929. NationalTravelFeeId = dac.NationalTravelFeeId,
  10930. Arae = $"{ntf.Country}-{ntf.City}",
  10931. Cost = dac.Cost,
  10932. Currency = dac.Currency,
  10933. CurrencyName = sd.Name,
  10934. SubTotal = dac.SubTotal,
  10935. })
  10936. .ToList();
  10937. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  10938. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  10939. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  10940. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  10941. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  10942. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  10943. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  10944. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  10945. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  10946. //其他款项
  10947. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  10948. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  10949. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  10950. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  10951. .OrderBy((dop, sd1, sd2) => dop.Index)
  10952. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  10953. {
  10954. ParentId = dop.ParentId,
  10955. SubId = dop.Id,
  10956. Index = dop.Index,
  10957. SetDataId = dop.SetDataId,
  10958. SetDataName = sd1.Name,
  10959. Cost = dop.Cost,
  10960. Currency = dop.Currency,
  10961. CurrencyName = sd2.Remark,
  10962. SubTotal = dop.SubTotal,
  10963. Remark = dop.Remark,
  10964. })
  10965. .ToArray();
  10966. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  10967. return Ok(mobileInfo);
  10968. }
  10969. /// <summary>
  10970. /// 团组模块 - 出入境费用-草稿-移动端 - SubInfo
  10971. /// </summary>
  10972. /// <returns></returns>
  10973. [HttpPost]
  10974. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10975. public async Task<IActionResult> EnterExitCostDraftMobileSubInfo(PostEnterExitCostDraftMobileSubInfoDto dto)
  10976. {
  10977. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10978. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10979. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10980. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  10981. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  10982. //验证查看编辑权限
  10983. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  10984. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  10985. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  10986. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  10987. var subType = dto.SubType;
  10988. if (subType == 1) //1:境内费用
  10989. {
  10990. var oneData = new ChoiceOneMobileSubInfoView()
  10991. {
  10992. Id = eecInfo.Id,
  10993. ChoiceOne = eecInfo.ChoiceOne,
  10994. ChoiceOneTotalCost = eecInfo.InsidePay,
  10995. Visa = eecInfo.Visa,
  10996. VisaRemark = eecInfo.VisaRemark,
  10997. YiMiao = eecInfo.YiMiao,
  10998. HeSuan = eecInfo.HeSuan,
  10999. Service = eecInfo.Service,
  11000. Ticket = eecInfo.Ticket,
  11001. Safe = eecInfo.Safe,
  11002. FirstItemRemark = eecInfo.FirstItemRemark
  11003. };
  11004. return Ok(JsonView(oneData));
  11005. }
  11006. else if (subType == 2) //2:国际旅费
  11007. {
  11008. var twoData = new ChoiceTwoMobileSubInfoView()
  11009. {
  11010. Id = eecInfo.Id,
  11011. ChoiceTwoJJ = eecInfo.SumJJC,
  11012. OutsideJJPay = eecInfo.OutsideJJPay,
  11013. ChoiceTwoGW = eecInfo.SumGWC,
  11014. OutsideGWPay = eecInfo.OutsideGWPay,
  11015. ChoiceTwoTD = eecInfo.SumTDC,
  11016. OutsideTDPay = eecInfo.OutsideTDPay,
  11017. AirJJ = eecInfo.AirJJ,
  11018. AirGW = eecInfo.AirGW,
  11019. AirTD = eecInfo.AirTD,
  11020. CityTranffic = eecInfo.CityTranffic,
  11021. TwoItemRemark = eecInfo.TwoItemRemark
  11022. };
  11023. return Ok(JsonView(twoData));
  11024. }
  11025. else if (subType == 3) //3:住宿费
  11026. {
  11027. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11028. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  11029. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  11030. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 1)
  11031. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  11032. {
  11033. ParentId = dac.ParentId,
  11034. SubId = dac.Id,
  11035. Type = dac.Type,
  11036. Days = dac.Days,
  11037. NationalTravelFeeId = dac.NationalTravelFeeId,
  11038. Arae = $"{ntf.Country}-{ntf.City}",
  11039. Cost = dac.Cost,
  11040. Currency = dac.Currency,
  11041. CurrencyName = sd.Name,
  11042. SubTotal = dac.SubTotal,
  11043. })
  11044. .ToArray();
  11045. var data = new ChoiceDraftMobileSubInfo3To6View()
  11046. {
  11047. ParentId = eecInfo.Id,
  11048. Choice = eecInfo.ChoiceThree,
  11049. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  11050. Details = dayAndCostDatas
  11051. };
  11052. return Ok(JsonView(data));
  11053. }
  11054. else if (subType == 4) //4:伙食费
  11055. {
  11056. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11057. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  11058. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  11059. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 2)
  11060. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  11061. {
  11062. ParentId = dac.ParentId,
  11063. SubId = dac.Id,
  11064. Type = dac.Type,
  11065. Days = dac.Days,
  11066. NationalTravelFeeId = dac.NationalTravelFeeId,
  11067. Arae = $"{ntf.Country}-{ntf.City}",
  11068. Cost = dac.Cost,
  11069. Currency = dac.Currency,
  11070. CurrencyName = sd.Name,
  11071. SubTotal = dac.SubTotal,
  11072. })
  11073. .ToArray();
  11074. var data = new ChoiceDraftMobileSubInfo3To6View()
  11075. {
  11076. ParentId = eecInfo.Id,
  11077. Choice = eecInfo.ChoiceFour,
  11078. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  11079. Details = dayAndCostDatas
  11080. };
  11081. return Ok(JsonView(data));
  11082. }
  11083. else if (subType == 5) //5:公杂费
  11084. {
  11085. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11086. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  11087. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  11088. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 3)
  11089. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  11090. {
  11091. ParentId = dac.ParentId,
  11092. SubId = dac.Id,
  11093. Type = dac.Type,
  11094. Days = dac.Days,
  11095. NationalTravelFeeId = dac.NationalTravelFeeId,
  11096. Arae = $"{ntf.Country}-{ntf.City}",
  11097. Cost = dac.Cost,
  11098. Currency = dac.Currency,
  11099. CurrencyName = sd.Name,
  11100. SubTotal = dac.SubTotal,
  11101. })
  11102. .ToArray();
  11103. var data = new ChoiceDraftMobileSubInfo3To6View()
  11104. {
  11105. ParentId = eecInfo.Id,
  11106. Choice = eecInfo.ChoiceFive,
  11107. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  11108. Details = dayAndCostDatas
  11109. };
  11110. return Ok(JsonView(data));
  11111. }
  11112. else if (subType == 6) //6:培训费
  11113. {
  11114. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11115. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  11116. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  11117. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 4)
  11118. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  11119. {
  11120. ParentId = dac.ParentId,
  11121. SubId = dac.Id,
  11122. Type = dac.Type,
  11123. Days = dac.Days,
  11124. NationalTravelFeeId = dac.NationalTravelFeeId,
  11125. Arae = $"{ntf.Country}-{ntf.City}",
  11126. Cost = dac.Cost,
  11127. Currency = dac.Currency,
  11128. CurrencyName = sd.Name,
  11129. SubTotal = dac.SubTotal,
  11130. })
  11131. .ToArray();
  11132. var data = new ChoiceDraftMobileSubInfo3To6View()
  11133. {
  11134. ParentId = eecInfo.Id,
  11135. Choice = eecInfo.ChoiceSix,
  11136. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  11137. Details = dayAndCostDatas
  11138. };
  11139. return Ok(JsonView(data));
  11140. }
  11141. else if (subType == 7) //7:其他
  11142. {
  11143. //其他款项
  11144. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  11145. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  11146. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  11147. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  11148. .OrderBy((dop, sd1, sd2) => dop.Index)
  11149. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  11150. {
  11151. ParentId = dop.ParentId,
  11152. SubId = dop.Id,
  11153. Index = dop.Index,
  11154. SetDataId = dop.SetDataId,
  11155. SetDataName = sd1.Name,
  11156. Cost = dop.Cost,
  11157. Currency = dop.Currency,
  11158. CurrencyName = sd2.Name,
  11159. SubTotal = dop.SubTotal,
  11160. Remark = dop.Remark,
  11161. })
  11162. .ToArray();
  11163. var data = new ChoiceSevenDraftMobileSubInfoView()
  11164. {
  11165. ParentId = eecInfo.Id,
  11166. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  11167. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  11168. Details = otherData
  11169. };
  11170. return Ok(JsonView(data));
  11171. }
  11172. return Ok(JsonView(false));
  11173. }
  11174. #region op
  11175. ///// <summary>
  11176. ///// 移动端更新费用消息通知
  11177. ///// </summary>
  11178. ///// <param name="draftId"></param>
  11179. ///// <param name="id"></param>
  11180. ///// <param name="currUserId"></param>
  11181. //private async Task EnterExitCostDraftMobileOpNotice(int draftId, int id, int currUserId)
  11182. //{
  11183. // try
  11184. // {
  11185. // ////生成默认文件pdf并且通知人员
  11186. // //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  11187. // //{
  11188. // // DiId = draftId,
  11189. // // ExportType = 1,
  11190. // // SubTypeId = 1005
  11191. // //}, "pdf");
  11192. // ////发送通知
  11193. // //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  11194. // //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  11195. // //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  11196. // //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(draftId, new List<string>() { "208", "233", "21" }, currUserId, url);
  11197. // ////汇率信息记录
  11198. // //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  11199. // }
  11200. // catch (Exception ex)
  11201. // {
  11202. // //记录日志
  11203. // throw;
  11204. // }
  11205. //}
  11206. /// <summary>
  11207. /// 验证出入境费用数据是否存在
  11208. /// 不存在添加
  11209. /// </summary>
  11210. /// <param name="draftId"></param>
  11211. /// <param name="currUserId"></param>
  11212. /// <returns></returns>
  11213. /// <exception cref="CustomException"></exception>
  11214. private async Task<int> EnterExitCostDraftVerifyIsNull(int draftId, int currUserId)
  11215. {
  11216. var parentId = 0;
  11217. var info = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).OrderByDescending(x => x.CreateTime).FirstAsync();
  11218. if (info != null) parentId = info.Id;
  11219. else
  11220. {
  11221. var currencys = await EnterExitCostDraftMobileGetCurrencyInit();
  11222. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  11223. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  11224. parentId = addId;
  11225. }
  11226. return parentId;
  11227. }
  11228. /// <summary>
  11229. /// 团组模块 - 出入境费用-草稿-移动端 - 查看权限用户
  11230. /// </summary>
  11231. /// <returns></returns>
  11232. [HttpPost]
  11233. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11234. public async Task<IActionResult> EnterExitCostDraftMobileViewPermissionUsers(EnterExitCostDraftMobileViewPermissionUsersDto dto)
  11235. {
  11236. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11237. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11238. //验证查看权限
  11239. (bool isView, bool isSet) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11240. if (!isView) return Ok(JsonView(false, _viewPermStr));
  11241. var userIds = await _sqlSugar
  11242. .Queryable<Grp_EnterExitCostDraftPermission>()
  11243. .Where(x => x.IsDel == 0 && x.DraftId == dto.DraftId)
  11244. .Select(x => x.UserId)
  11245. .ToArrayAsync();
  11246. var perUsers = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  11247. var perUsersView = new List<dynamic>();
  11248. var feeBasePerm = AppSettingsHelper.Get<FeeBasePermView>("FeeBasePerm");
  11249. var viewPermissionData = new List<PermissionViewUserview>();
  11250. if (feeBasePerm.Any())
  11251. {
  11252. foreach (var item in feeBasePerm)
  11253. {
  11254. if (item.Users.Any())
  11255. {
  11256. viewPermissionData.AddRange(item.Users);
  11257. }
  11258. }
  11259. }
  11260. foreach (var item in perUsers)
  11261. {
  11262. bool isView1 = false;
  11263. if (userIds.Any(x => x == item.Id)) isView1 = true;
  11264. else if (viewPermissionData.Any(x => x.Id == dto.CurrUserId) && item.Id == dto.CurrUserId) isView1 = true;
  11265. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  11266. }
  11267. return Ok(JsonView(perUsersView));
  11268. }
  11269. /// <summary>
  11270. /// 团组模块 - 出入境费用-草稿-移动端 - 设置view权限
  11271. /// </summary>
  11272. /// <returns></returns>
  11273. [HttpPost]
  11274. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11275. public async Task<IActionResult> EnterExitCostDraftMobileSetViewPermissiion(EnterExitCostDraftMobileSetViewPermissiionDto dto)
  11276. {
  11277. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11278. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11279. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  11280. //验证查看编辑权限
  11281. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11282. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  11283. var permissions = new List<Grp_EnterExitCostDraftPermission>() { };
  11284. foreach (var userId in dto.UserIds)
  11285. {
  11286. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  11287. }
  11288. if (permissions.Any())
  11289. {
  11290. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  11291. {
  11292. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  11293. }
  11294. _sqlSugar.BeginTran();
  11295. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  11296. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  11297. if (result < 1)
  11298. {
  11299. _sqlSugar.RollbackTran();
  11300. return Ok(JsonView(false));
  11301. }
  11302. _sqlSugar.CommitTran();
  11303. return Ok(JsonView(true));
  11304. }
  11305. return Ok(JsonView(false));
  11306. }
  11307. /// <summary>
  11308. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 省份
  11309. /// </summary>
  11310. /// <returns></returns>
  11311. [HttpPost]
  11312. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11313. public async Task<IActionResult> EnterExitCostDraftMobileOpProv(EnterExitCostDraftMobileOpProvDto dto)
  11314. {
  11315. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11316. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11317. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11318. if (dto.ProvinceId < 1) return Ok(JsonView(false, "请传入有效的省份Id!"));
  11319. int id = dto.DraftId;
  11320. if (id <= 0) //add
  11321. {
  11322. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11323. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  11324. if (add < 1) return Ok(JsonView(false));
  11325. id = add;
  11326. }
  11327. else //update
  11328. {
  11329. //验证查看编辑权限
  11330. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11331. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  11332. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  11333. if (upd < 1) return Ok(JsonView(false));
  11334. }
  11335. return Ok(JsonView(new { parentId = id }));
  11336. }
  11337. /// <summary>
  11338. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 汇率
  11339. /// </summary>
  11340. /// <returns></returns>
  11341. [HttpPost]
  11342. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11343. public async Task<IActionResult> EnterExitCostDraftMobileOpRate(PostEnterExitCostDraftMobileFeeRateOpDto dto)
  11344. {
  11345. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11346. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11347. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11348. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  11349. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  11350. int id = dto.DraftId;
  11351. if (id <= 0) //add
  11352. {
  11353. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11354. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId, CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  11355. if (add < 1) return Ok(JsonView(false));
  11356. id = add;
  11357. }
  11358. else //update
  11359. {
  11360. //验证查看编辑权限
  11361. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11362. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  11363. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  11364. if (upd < 1) return Ok(JsonView(false));
  11365. }
  11366. #region 汇率变更时更改币种相关费用
  11367. var opDayCosts = new List<Grp_DayAndCostDraft>();
  11368. var opDayOtherCosts = new List<Grp_DayOtherPriceDraft>();
  11369. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  11370. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11371. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  11372. .Where((dac, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  11373. .Select((dac, sd) => new
  11374. {
  11375. dac.Id,
  11376. dac.ParentId,
  11377. CurrencyCode = sd.Name,
  11378. dac.Cost
  11379. })
  11380. .ToList();
  11381. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  11382. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  11383. .Where((dop, sd) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  11384. .Select((dop, sd) => new
  11385. {
  11386. dop.Id,
  11387. dop.ParentId,
  11388. CurrencyCode = sd.Name,
  11389. dop.Cost
  11390. })
  11391. .ToList();
  11392. if (dayCosts.Count > 0)
  11393. {
  11394. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  11395. foreach (var dc in new_dayCosts)
  11396. {
  11397. var thisCurrency = dc.Key.ToUpper();
  11398. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  11399. if (thisRate == 0.00M) continue;
  11400. foreach (var dcSub in dc)
  11401. {
  11402. opDayCosts.Add(new Grp_DayAndCostDraft()
  11403. {
  11404. Id = dcSub.Id,
  11405. ParentId = dcSub.ParentId,
  11406. Cost = dcSub.Cost,
  11407. SubTotal = dcSub.Cost * thisRate,
  11408. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now:yyyy-MM-dd HH:mm:ss}、opUserId:{dto.CurrUserId}]"
  11409. });
  11410. }
  11411. }
  11412. if (opDayCosts.Count > 0)
  11413. {
  11414. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  11415. }
  11416. }
  11417. if (dayOtherCosts.Count > 0)
  11418. {
  11419. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  11420. foreach (var dc in new_dayOtherCosts)
  11421. {
  11422. var thisCurrency = dc.Key.ToUpper();
  11423. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  11424. if (thisRate == 0.00M) continue;
  11425. foreach (var dcSub in dc)
  11426. {
  11427. opDayOtherCosts.Add(new Grp_DayOtherPriceDraft()
  11428. {
  11429. Id = dcSub.Id,
  11430. ParentId = dcSub.ParentId,
  11431. Cost = dcSub.Cost,
  11432. SubTotal = dcSub.Cost * thisRate,
  11433. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  11434. });
  11435. }
  11436. }
  11437. if (opDayOtherCosts.Count > 0)
  11438. {
  11439. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  11440. }
  11441. }
  11442. #endregion
  11443. ////消息通知
  11444. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11445. ////汇率信息记录
  11446. //await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  11447. return Ok(JsonView(new { parentId = id }));
  11448. }
  11449. /// <summary>
  11450. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 复选框
  11451. /// </summary>
  11452. /// <returns></returns>
  11453. [HttpPost]
  11454. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11455. public async Task<IActionResult> EnterExitCostDraftMobileOpCheckbox(PostEnterExitCostDraftMobileFeeOpCheckboxDto dto)
  11456. {
  11457. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11458. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11459. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11460. var checkboxInfo = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  11461. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11462. int id = dto.DraftId;
  11463. if (id <= 0) //add
  11464. {
  11465. checkboxInfo.ProvinceId = dto.ProvinceId;
  11466. checkboxInfo.CreateUserId = dto.CurrUserId;
  11467. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostDraftMobileGetCurrencyInit());
  11468. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  11469. if (add < 1) return Ok(JsonView(false));
  11470. }
  11471. else //update
  11472. {
  11473. var upd = await _sqlSugar.Updateable(checkboxInfo)
  11474. .UpdateColumns(x => new
  11475. {
  11476. x.ChoiceOne,
  11477. x.ChoiceTwo,
  11478. x.SumJJC,
  11479. x.SumGWC,
  11480. x.SumTDC,
  11481. x.ChoiceThree,
  11482. x.ChoiceFour,
  11483. x.ChoiceFive,
  11484. x.ChoiceSix,
  11485. x.OtherExpenses_Checked
  11486. })
  11487. .Where(x => x.Id == id)
  11488. .ExecuteCommandAsync();
  11489. if (upd < 1) return Ok(JsonView(false));
  11490. }
  11491. return Ok(JsonView(new { parentId = id }));
  11492. }
  11493. /// <summary>
  11494. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 3-7项复选框单个复选框
  11495. /// </summary>
  11496. /// <returns></returns>
  11497. [HttpPost]
  11498. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11499. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleCheckbox(EnterExitCostDarftMobileOpSingleCheckboxDto dto)
  11500. {
  11501. int itemTypeId = dto.ItemType, currUserId = dto.CurrUserId, draftId = dto.DraftId, isSelected = dto.IsSelected;
  11502. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  11503. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11504. if (draftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11505. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11506. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  11507. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11508. var checkboxInfo = new Grp_EnterExitCostDraft()
  11509. {
  11510. Id = draftId,
  11511. ProvinceId = dto.ProvinceId,
  11512. CreateUserId = currUserId
  11513. };
  11514. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  11515. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  11516. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  11517. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  11518. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  11519. if (draftId <= 0) //add
  11520. {
  11521. checkboxInfo.CreateUserId = dto.CurrUserId;
  11522. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11523. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  11524. if (add < 1) return Ok(JsonView(false));
  11525. }
  11526. else //update
  11527. {
  11528. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>()
  11529. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  11530. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  11531. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  11532. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  11533. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  11534. .Where(x => x.Id == draftId)
  11535. .ExecuteCommandAsync();
  11536. if (upd < 1) return Ok(JsonView(false));
  11537. }
  11538. return Ok(JsonView(new { parentId = draftId }));
  11539. }
  11540. /// <summary>
  11541. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 境内费用 Step1
  11542. /// </summary>
  11543. /// <returns></returns>
  11544. [HttpPost]
  11545. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11546. public async Task<IActionResult> EnterExitCostDraftMobileOpStep1(PostEnterExitCostDraftMobileOpStep1Dto dto)
  11547. {
  11548. int id = dto.DraftId, currUserId = dto.CurrUserId;
  11549. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11550. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  11551. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11552. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11553. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  11554. info.ProvinceId = dto.ProvinceId;
  11555. info.FirstItemRemark = dto.FirstItemRemark;
  11556. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  11557. if (id <= 0) //add
  11558. {
  11559. info.CreateUserId = dto.CurrUserId;
  11560. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11561. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  11562. if (add < 1) return Ok(JsonView(false));
  11563. id = add;
  11564. }
  11565. else //update
  11566. {
  11567. var upd = await _sqlSugar.Updateable(info)
  11568. .UpdateColumns(x => new
  11569. {
  11570. x.ChoiceOne,
  11571. x.InsidePay,
  11572. x.VisaRemark,
  11573. x.Visa,
  11574. x.Service,
  11575. x.Safe,
  11576. x.Ticket,
  11577. x.HeSuan,
  11578. x.YiMiao,
  11579. x.FirstItemRemark
  11580. })
  11581. .Where(x => x.Id == id)
  11582. .ExecuteCommandAsync();
  11583. if (upd < 1) return Ok(JsonView(false));
  11584. }
  11585. ////消息通知
  11586. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11587. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  11588. }
  11589. /// <summary>
  11590. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 国际旅费 Step2
  11591. /// </summary>
  11592. /// <returns></returns>
  11593. [HttpPost]
  11594. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11595. public async Task<IActionResult> EnterExitCostDraftMobileOpStep2(PostEnterExitCostDraftMobileOpStep2Dto dto)
  11596. {
  11597. int id = dto.DraftId;
  11598. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11599. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  11600. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11601. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11602. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  11603. info.ProvinceId = dto.ProvinceId;
  11604. info.OutsideJJPay = dto.OutsideJJPay;
  11605. info.OutsideGWPay = dto.OutsideGWPay;
  11606. info.OutsideTDPay = dto.OutsideTDPay;
  11607. info.AirJJ = dto.AirJJ;
  11608. info.AirGW = dto.AirGW;
  11609. info.AirTD = dto.AirTD;
  11610. info.CityTranffic = dto.CityTranffic;
  11611. info.TwoItemRemark = dto.TwoItemRemark;
  11612. info.SumJJC = dto.ChoiceTwoJJ;
  11613. info.SumGWC = dto.ChoiceTwoGW;
  11614. info.SumTDC = dto.ChoiceTwoTD;
  11615. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  11616. if (id <= 0) //add
  11617. {
  11618. info.CreateUserId = dto.CurrUserId;
  11619. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11620. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  11621. if (addId <= 0) return Ok(JsonView(false));
  11622. id = addId;
  11623. }
  11624. else //update
  11625. {
  11626. var upd = await _sqlSugar.Updateable(info)
  11627. .UpdateColumns(x => new
  11628. {
  11629. x.SumJJC,
  11630. x.OutsideJJPay,
  11631. x.SumGWC,
  11632. x.OutsideGWPay,
  11633. x.SumTDC,
  11634. x.OutsideTDPay,
  11635. x.AirJJ,
  11636. x.AirGW,
  11637. x.AirTD,
  11638. x.CityTranffic,
  11639. x.TwoItemRemark
  11640. })
  11641. .Where(x => x.Id == id)
  11642. .ExecuteCommandAsync();
  11643. if (upd < 1) return Ok(JsonView(false));
  11644. }
  11645. jjcItemTotal = info.AirJJ + info.CityTranffic;
  11646. gwcItemTotal = info.AirGW + info.CityTranffic;
  11647. tdcItemTotal = info.AirTD + info.CityTranffic;
  11648. ////消息通知
  11649. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11650. return Ok(JsonView(new
  11651. {
  11652. parentId = id,
  11653. choiceTwoJJ = dto.ChoiceTwoJJ,
  11654. jjcItemTotal = jjcItemTotal,
  11655. choiceTwoGW = dto.ChoiceTwoGW,
  11656. gwcItemTotal = gwcItemTotal,
  11657. choiceTwoTD = dto.ChoiceTwoTD,
  11658. tdcItemTotal = tdcItemTotal
  11659. }));
  11660. }
  11661. /// <summary>
  11662. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  11663. /// </summary>
  11664. /// <returns></returns>
  11665. [HttpPost]
  11666. [ApiExplorerSettings(IgnoreApi = true)]
  11667. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11668. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep3To6(PostEnterExitCostDraftMobileOpStep3To6Dto dto)
  11669. {
  11670. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11671. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11672. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11673. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  11674. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  11675. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  11676. var infos1 = _mapper.Map<List<Grp_DayAndCostDraft>>(dto.Infos);
  11677. var infos = infos1.Select(x => new Grp_DayAndCostDraft
  11678. {
  11679. Id = x.Id,
  11680. ParentId = dto.DraftId,
  11681. Type = dto.FeeType,
  11682. Days = x.Days,
  11683. NationalTravelFeeId = x.NationalTravelFeeId,
  11684. Cost = x.Cost,
  11685. Currency = x.Currency,
  11686. SubTotal = x.SubTotal,
  11687. CreateUserId = dto.CurrUserId
  11688. })
  11689. .ToList();
  11690. var adds = infos.Where(x => x.Id <= 0).ToList();
  11691. var upds = infos.Where(x => x.Id > 0).ToList();
  11692. if (adds.Count > 0)
  11693. {
  11694. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  11695. if (add < 1) return Ok(JsonView(false));
  11696. }
  11697. if (upds.Count > 0)
  11698. {
  11699. var upd = await _sqlSugar.Updateable(adds)
  11700. .UpdateColumns(x => new
  11701. {
  11702. x.Days,
  11703. x.NationalTravelFeeId,
  11704. x.Cost,
  11705. x.Currency,
  11706. x.SubTotal
  11707. })
  11708. .WhereColumns(x => new { x.Id })
  11709. .ExecuteCommandAsync();
  11710. if (upd < 1) return Ok(JsonView(false));
  11711. }
  11712. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  11713. ////消息通知
  11714. //var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).First()?.Id ?? 0;
  11715. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11716. return Ok(JsonView(new { itemTotal = itemTotal }));
  11717. }
  11718. /// <summary>
  11719. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  11720. /// </summary>
  11721. /// <returns></returns>
  11722. [HttpPost]
  11723. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11724. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep3To6(PostEnterExitCostDraftMobileOpSingleStep3To6Dto dto)
  11725. {
  11726. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  11727. int subId = dto.SubId, feeType = dto.FeeType;
  11728. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11729. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11730. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11731. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  11732. var subInfo = _mapper.Map<Grp_DayAndCostDraft>(dto);
  11733. subInfo.Id = subId;
  11734. subInfo.ParentId = dto.DraftId;
  11735. if (feeType == 3) subInfo.Type = 1;
  11736. else if (feeType == 4) subInfo.Type = 2;
  11737. else if (feeType == 5) subInfo.Type = 3;
  11738. else if (feeType == 6) subInfo.Type = 4;
  11739. subInfo.CreateUserId = dto.CurrUserId;
  11740. int parentId = await EnterExitCostDraftVerifyIsNull(dto.DraftId, dto.CurrUserId); //主表验证
  11741. if (parentId < 1) return Ok(JsonView(false));
  11742. //子表op
  11743. if (subId < 1)
  11744. {
  11745. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  11746. if (subAdd < 1) return Ok(JsonView(false));
  11747. }
  11748. else
  11749. {
  11750. var subUpd = await _sqlSugar.Updateable(subInfo)
  11751. .UpdateColumns(x => new
  11752. {
  11753. x.Days,
  11754. x.NationalTravelFeeId,
  11755. x.Cost,
  11756. x.Currency,
  11757. x.SubTotal
  11758. })
  11759. .WhereColumns(x => new { x.Id })
  11760. .ExecuteCommandAsync();
  11761. if (subUpd < 1) return Ok(JsonView(false));
  11762. }
  11763. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == feeType).Sum(x => x.SubTotal);
  11764. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  11765. }
  11766. /// <summary>
  11767. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-批量 Step7
  11768. /// </summary>
  11769. /// <returns></returns>
  11770. [HttpPost]
  11771. [ApiExplorerSettings(IgnoreApi = true)]
  11772. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11773. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep7(PostEnterExitCostDraftMobileOpStep7Dto dto)
  11774. {
  11775. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11776. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11777. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11778. var infos1 = _mapper.Map<List<Grp_DayOtherPriceDraft>>(dto.Infos);
  11779. var infos = infos1.Select(x => new Grp_DayOtherPriceDraft()
  11780. {
  11781. Id = x.Id,
  11782. ParentId = dto.DraftId,
  11783. SetDataId = x.SetDataId,
  11784. Index = x.Index,
  11785. Cost = x.Cost,
  11786. Currency = x.Currency,
  11787. SubTotal = x.SubTotal,
  11788. CreateUserId = dto.CurrUserId,
  11789. Remark = x.Remark
  11790. }).ToList();
  11791. var adds = infos.Where(x => x.Id <= 0).ToList();
  11792. var upds = infos.Where(x => x.Id > 0).ToList();
  11793. if (adds.Count > 0)
  11794. {
  11795. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  11796. if (add < 1) return Ok(JsonView(false));
  11797. }
  11798. if (upds.Count > 0)
  11799. {
  11800. var upd = await _sqlSugar.Updateable(adds)
  11801. .UpdateColumns(x => new
  11802. {
  11803. x.Index,
  11804. x.SetDataId,
  11805. x.Cost,
  11806. x.Currency,
  11807. x.SubTotal,
  11808. x.Remark
  11809. })
  11810. .WhereColumns(x => new { x.Id })
  11811. .ExecuteCommandAsync();
  11812. if (upd < 1) return Ok(JsonView(false));
  11813. }
  11814. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).Sum(x => x.SubTotal);
  11815. //消息通知
  11816. //var id = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == dto.DraftId).First()?.Id ?? 0;
  11817. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11818. return Ok(JsonView(new { itemTotal = itemTotal }));
  11819. }
  11820. /// <summary>
  11821. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-单条 Step7
  11822. /// </summary>
  11823. /// <returns></returns>
  11824. [HttpPost]
  11825. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11826. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep7(PostEnterExitCostDraftMobileOpSingleStep7Dto dto)
  11827. {
  11828. int subId = dto.SubId, id = dto.DraftId;
  11829. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11830. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  11831. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11832. var subInfo = _mapper.Map<Grp_DayOtherPriceDraft>(dto);
  11833. subInfo.Id = subId;
  11834. subInfo.ParentId = id;
  11835. subInfo.CreateUserId = dto.CurrUserId;
  11836. int parentId = await EnterExitCostDraftVerifyIsNull(id, dto.CurrUserId); //主表验证
  11837. if (parentId < 1) return Ok(JsonView(false));
  11838. #region 子表op
  11839. if (subId < 1)//add
  11840. {
  11841. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  11842. if (subAdd < 1) return Ok(JsonView(false));
  11843. }
  11844. else //upd
  11845. {
  11846. var subUpd = await _sqlSugar.Updateable(subInfo)
  11847. .UpdateColumns(x => new
  11848. {
  11849. x.Index,
  11850. x.SetDataId,
  11851. x.Cost,
  11852. x.Currency,
  11853. x.SubTotal,
  11854. x.Remark
  11855. })
  11856. .WhereColumns(x => new { x.Id })
  11857. .ExecuteCommandAsync();
  11858. if (subUpd < 1) return Ok(JsonView(false));
  11859. }
  11860. #endregion
  11861. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == id).Sum(x => x.SubTotal);
  11862. ////消息通知
  11863. //await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  11864. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  11865. }
  11866. /// <summary>
  11867. /// 团组模块 - 出入境费用-草稿-移动端 - 3-6子项删除
  11868. /// </summary>
  11869. /// <returns></returns>
  11870. [HttpPost]
  11871. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11872. public async Task<IActionResult> EnterExitCostDraftMobileSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  11873. {
  11874. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  11875. if (data.Code != 0)
  11876. {
  11877. return Ok(JsonView(false, data.Msg));
  11878. }
  11879. return Ok(JsonView(true, "操作成功!", data.Data));
  11880. }
  11881. /// <summary>
  11882. /// 团组模块 - 出入境费用-草稿-移动端 - 其他费用删除
  11883. /// </summary>
  11884. /// <param name="dto"></param>
  11885. /// <returns></returns>
  11886. [HttpPost]
  11887. public IActionResult EnterExitCostDraftMobileOtherFeeDel(EnterExitCostDraftSubItemDelDto dto)
  11888. {
  11889. var data = new Grp_DayOtherPriceDraft()
  11890. {
  11891. Id = dto.Id,
  11892. IsDel = 1,
  11893. DeleteUserId = dto.DeleteUserId,
  11894. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  11895. };
  11896. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  11897. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  11898. return Ok(JsonView(false, "删除失败!"));
  11899. }
  11900. #endregion
  11901. #endregion
  11902. #region 团组经理模块 出入境费用报价表
  11903. /// <summary>
  11904. /// 团组模块 - 出入境费用报价表 - 初始化数据源(币种类型)
  11905. /// </summary>
  11906. /// <returns></returns>
  11907. [HttpPost]
  11908. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11909. public async Task<IActionResult> EnterExitCostQuoteInitData(PortDtoBase dto)
  11910. {
  11911. var initRates = await GeneralMethod.EnterExitCostInitRate();
  11912. var liveRates = await GeneralMethod.EnterExitCostLiveRate();
  11913. var cnyInfo = new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.0000M };
  11914. initRates.Insert(0, cnyInfo);
  11915. liveRates.Insert(0, cnyInfo);
  11916. return Ok(JsonView(true, "查询成功!", new
  11917. {
  11918. InitRates = initRates,
  11919. LiveRates = liveRates
  11920. }));
  11921. }
  11922. /// <summary>
  11923. /// 团组模块 - 出入境费用报价表 - 报价表名称列表
  11924. /// </summary>
  11925. /// <returns></returns>
  11926. [HttpPost]
  11927. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11928. public async Task<IActionResult> EnterExitCostQuoteNameList(EnterExitCostQuoteNameListDto dto)
  11929. {
  11930. return Ok(await _enterExitCostQuoteRep.QuoteNameListAsync(dto));
  11931. }
  11932. /// <summary>
  11933. /// 团组模块 - 出入境费用报价表 - 团组名称列表
  11934. /// </summary>
  11935. /// <returns></returns>
  11936. [HttpPost]
  11937. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11938. public async Task<IActionResult> EnterExitCostQuoteGroupNameList(EnterExitCostQuoteGroupNameListDto dto)
  11939. {
  11940. return Ok(await _enterExitCostQuoteRep.GroupNameListAsync(dto));
  11941. }
  11942. /// <summary>
  11943. /// 团组模块 - 出入境费用报价表 - 根据团组Id获出入境费用相关信息
  11944. /// </summary>
  11945. /// <returns></returns>
  11946. [HttpPost]
  11947. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11948. public async Task<IActionResult> EnterExitCostQuoteEntryExitCosts(EnterExitCostInfobyDiIdDto dto)
  11949. {
  11950. int groupId = dto.DiId,
  11951. currUserId = dto.CurrUserId;
  11952. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId;"));
  11953. if (currUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId;"));
  11954. //验证报价数据是否存在
  11955. var isNull = await _sqlSugar.Queryable<Grp_EnterExitCostQuote>().FirstAsync(x => x.IsDel == 0 && x.GroupId == dto.DiId);
  11956. if (isNull != null)
  11957. {
  11958. var info1 = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { Id = isNull.Id });
  11959. if (!info1.Rates.Any())
  11960. {
  11961. var rates = await GeneralMethod.EnterExitCostInitRate();
  11962. rates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  11963. info1.Rates = rates.ToArray();
  11964. }
  11965. return Ok(JsonView(info1));
  11966. }
  11967. var result = await _enterExitCostQuoteRep.InfoByGroupIdAsync(dto.DiId);
  11968. result.GroupId = groupId;
  11969. //处理报价名称
  11970. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.DiId && x.IsDel == 0);
  11971. if (groupInfo != null)
  11972. {
  11973. var visitCountry = groupInfo.VisitCountry;
  11974. if (!string.IsNullOrEmpty(visitCountry))
  11975. {
  11976. string quoteName = string.Empty;
  11977. if (visitCountry.Contains("|"))
  11978. {
  11979. var countrys = visitCountry.Split("|");
  11980. quoteName = string.Join("、", countrys);
  11981. }
  11982. else quoteName = visitCountry;
  11983. quoteName += $"团组报价表";
  11984. result.Name = quoteName;
  11985. }
  11986. }
  11987. var info = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  11988. if (info.Code != StatusCodes.Status200OK)
  11989. {
  11990. if (!result.Rates.Any())
  11991. {
  11992. var rates = await GeneralMethod.EnterExitCostInitRate();
  11993. result.Rates = rates.ToArray();
  11994. }
  11995. return Ok(JsonView(true, $"出入境费用明细未填写!", result));
  11996. }
  11997. var infoView = info.Data as EnterExitCostInfoView;
  11998. if (infoView == null) return Ok(JsonView(false, "数据类型转换失败!;"));
  11999. var countryFees = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).ToListAsync();
  12000. var cityFilter = new List<string>() { "全部城市", "其他城市" };
  12001. var currencys = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  12002. var eecRates = infoView.Currencys;
  12003. //默认添加人名币
  12004. if (!eecRates.Any(x => x.CurrencyCode.Equals("CNY")))
  12005. {
  12006. eecRates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  12007. }
  12008. //处理团组人数
  12009. int pplNum = 1;
  12010. if (groupInfo != null) pplNum = groupInfo.VisitPNumber;
  12011. var views = new List<QuoteSubItemInfo>();
  12012. #region 数据填充
  12013. var intTravelCosts = new List<QuoteSubItemInfo>();
  12014. #region 机票费用 1354
  12015. int intTravelIndex = 1;
  12016. if (infoView.SumJJC == 1)
  12017. {
  12018. intTravelCosts.Add(new QuoteSubItemInfo
  12019. {
  12020. ItemId = 1354,
  12021. Index = intTravelIndex,
  12022. FeeName = "经济舱",
  12023. UnitPrice = infoView.AirJJ,
  12024. Currency = "CNY",
  12025. Quantity = 1,
  12026. PplNum = 1,
  12027. TotalAmt = infoView.AirJJ,
  12028. Remark = "",
  12029. });
  12030. intTravelIndex++;
  12031. }
  12032. if (infoView.SumGWC == 1)
  12033. {
  12034. intTravelCosts.Add(new QuoteSubItemInfo
  12035. {
  12036. ItemId = 1354,
  12037. Index = intTravelIndex,
  12038. FeeName = "公务舱",
  12039. UnitPrice = infoView.AirGW,
  12040. Currency = "CNY",
  12041. Quantity = 1,
  12042. PplNum = 1,
  12043. TotalAmt = infoView.AirGW,
  12044. Remark = "",
  12045. });
  12046. intTravelIndex++;
  12047. }
  12048. if (infoView.SumTDC == 1)
  12049. {
  12050. intTravelCosts.Add(new QuoteSubItemInfo
  12051. {
  12052. ItemId = 1354,
  12053. Index = intTravelIndex,
  12054. FeeName = "头等舱",
  12055. UnitPrice = infoView.AirTD,
  12056. Currency = "CNY",
  12057. Quantity = 1,
  12058. PplNum = 1,
  12059. TotalAmt = infoView.AirTD,
  12060. Remark = "",
  12061. });
  12062. intTravelIndex++;
  12063. }
  12064. intTravelCosts.Add(new QuoteSubItemInfo
  12065. {
  12066. ItemId = 1354,
  12067. Index = intTravelIndex,
  12068. FeeName = "城市间交通费用",
  12069. UnitPrice = infoView.CityTranffic,
  12070. Currency = "CNY",
  12071. Quantity = 1,
  12072. PplNum = pplNum,
  12073. TotalAmt = infoView.CityTranffic * pplNum,
  12074. Remark = "",
  12075. });
  12076. views.AddRange(intTravelCosts);
  12077. #endregion
  12078. var accomCosts = new List<QuoteSubItemInfo>();
  12079. #region 住宿费 1355
  12080. if (infoView.QuarterageData.Any())
  12081. {
  12082. int accomIndex = 1;
  12083. int accomItemTypeId = 1355;
  12084. var groupData = infoView.QuarterageData.GroupBy(x => x.NationalTravelFeeId);
  12085. foreach (var item in groupData)
  12086. {
  12087. string feeName = string.Empty;
  12088. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  12089. if (countryInfo != null)
  12090. {
  12091. feeName = countryInfo.Country;
  12092. var city = countryInfo.City;
  12093. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  12094. {
  12095. feeName += $"-{city}";
  12096. }
  12097. }
  12098. var hotelInfo = item.FirstOrDefault();
  12099. if (hotelInfo == null) continue;
  12100. var thisCurrency = currencys.FirstOrDefault(x => x.Id == hotelInfo.Currency)?.Name ?? "nuknow";
  12101. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  12102. int quantity = item.ToList().Count;
  12103. accomCosts.Add(new QuoteSubItemInfo
  12104. {
  12105. ItemId = accomItemTypeId,
  12106. Index = accomIndex,
  12107. FeeName = feeName,
  12108. UnitPrice = hotelInfo.Cost,
  12109. Currency = thisCurrency,
  12110. Quantity = quantity,
  12111. PplNum = pplNum,
  12112. TotalAmt = hotelInfo.Cost * thisRate * quantity * pplNum,
  12113. Remark = "",
  12114. });
  12115. accomIndex++;
  12116. }
  12117. views.AddRange(accomCosts);
  12118. }
  12119. #endregion
  12120. var mealCosts = new List<QuoteSubItemInfo>();
  12121. #region 餐饮费 1356
  12122. if (infoView.BoardWagesData.Any())
  12123. {
  12124. var mealIndex = 1;
  12125. int mealItemTypeId = 1356;
  12126. var groupData = infoView.BoardWagesData.GroupBy(x => x.NationalTravelFeeId);
  12127. foreach (var item in groupData)
  12128. {
  12129. string feeName = string.Empty;
  12130. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  12131. if (countryInfo != null)
  12132. {
  12133. feeName = countryInfo.Country;
  12134. var city = countryInfo.City;
  12135. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  12136. {
  12137. feeName += $"-{city}";
  12138. }
  12139. }
  12140. var mealInfo = item.FirstOrDefault();
  12141. if (mealInfo == null) continue;
  12142. var thisCurrency = currencys.FirstOrDefault(x => x.Id == mealInfo.Currency)?.Name ?? "nuknow";
  12143. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  12144. int quantity = item.ToList().Count;
  12145. mealCosts.Add(new QuoteSubItemInfo
  12146. {
  12147. ItemId = mealItemTypeId,
  12148. Index = mealIndex,
  12149. FeeName = feeName,
  12150. UnitPrice = mealInfo.Cost,
  12151. Currency = thisCurrency,
  12152. Quantity = quantity,
  12153. PplNum = pplNum,
  12154. TotalAmt = mealInfo.Cost * thisRate * quantity * pplNum,
  12155. Remark = "",
  12156. });
  12157. mealIndex++;
  12158. }
  12159. views.AddRange(mealCosts);
  12160. }
  12161. #endregion
  12162. var miscCosts = new List<QuoteSubItemInfo>();
  12163. #region 公杂费 1364
  12164. if (infoView.MiscellaneousFeeData.Any())
  12165. {
  12166. var miscIndex = 1;
  12167. int miscItemTypeId = 1364;
  12168. var groupData = infoView.MiscellaneousFeeData.GroupBy(x => x.NationalTravelFeeId);
  12169. foreach (var item in groupData)
  12170. {
  12171. string feeName = string.Empty;
  12172. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  12173. if (countryInfo != null)
  12174. {
  12175. feeName = countryInfo.Country;
  12176. var city = countryInfo.City;
  12177. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  12178. {
  12179. feeName += $"-{city}";
  12180. }
  12181. }
  12182. var miscInfo = item.FirstOrDefault();
  12183. if (miscInfo == null) continue;
  12184. var thisCurrency = currencys.FirstOrDefault(x => x.Id == miscInfo.Currency)?.Name ?? "nuknow";
  12185. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  12186. int quantity = item.ToList().Count;
  12187. miscCosts.Add(new QuoteSubItemInfo
  12188. {
  12189. ItemId = miscItemTypeId,
  12190. Index = miscIndex,
  12191. FeeName = feeName,
  12192. UnitPrice = miscInfo.Cost,
  12193. Currency = thisCurrency,
  12194. Quantity = quantity,
  12195. PplNum = pplNum,
  12196. TotalAmt = miscInfo.Cost * thisRate * quantity * pplNum,
  12197. Remark = "",
  12198. });
  12199. miscIndex++;
  12200. }
  12201. views.AddRange(miscCosts);
  12202. }
  12203. #endregion
  12204. #region 签证+保险 1362
  12205. int visaInsIndex = 1;
  12206. int visaInsItemTypeId = 1362;
  12207. if (infoView.Visa > 0)
  12208. {
  12209. views.Add(new QuoteSubItemInfo()
  12210. {
  12211. ItemId = visaInsItemTypeId,
  12212. Index = visaInsIndex,
  12213. FeeName = $"签证",
  12214. UnitPrice = infoView.Visa,
  12215. Currency = $"CNY",
  12216. Quantity = 1,
  12217. PplNum = pplNum,
  12218. TotalAmt = infoView.Visa * pplNum,
  12219. Remark = "",
  12220. });
  12221. visaInsIndex++;
  12222. }
  12223. if (infoView.Safe > 0)
  12224. {
  12225. views.Add(new QuoteSubItemInfo()
  12226. {
  12227. ItemId = visaInsItemTypeId,
  12228. Index = visaInsIndex,
  12229. FeeName = $"保险",
  12230. UnitPrice = infoView.Safe,
  12231. Currency = $"CNY",
  12232. Quantity = 1,
  12233. PplNum = pplNum,
  12234. TotalAmt = infoView.Safe * pplNum,
  12235. Remark = "",
  12236. });
  12237. }
  12238. #endregion
  12239. #region 服务费 1363
  12240. int serviceFeeIndex = 1;
  12241. int serviceFeeItemTypeId = 1363;
  12242. if (infoView.Service > 0)
  12243. {
  12244. views.Add(new QuoteSubItemInfo()
  12245. {
  12246. ItemId = serviceFeeItemTypeId,
  12247. Index = serviceFeeIndex,
  12248. FeeName = $"服务费",
  12249. UnitPrice = infoView.Service,
  12250. Currency = $"CNY",
  12251. Quantity = 1,
  12252. PplNum = pplNum,
  12253. TotalAmt = infoView.Service * pplNum,
  12254. Remark = "",
  12255. });
  12256. }
  12257. #endregion
  12258. #endregion
  12259. if (result.FeeItems.Any())
  12260. {
  12261. result.FeeItems.Select(x =>
  12262. {
  12263. var feeInfos = views.Where(y => y.ItemId == x.ItemId).OrderBy(y => y.Index).ToArray();
  12264. if (feeInfos.Any()) x.Infos = feeInfos;
  12265. return x;
  12266. }
  12267. ).OrderBy(x => x.Index)
  12268. .ToList();
  12269. if (!result.Rates.Any())
  12270. {
  12271. if (eecRates.Any()) result.Rates = eecRates?.ToArray() ?? Array.Empty<CurrencyInfo>();
  12272. else
  12273. {
  12274. var rates = await GeneralMethod.EnterExitCostInitRate();
  12275. rates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  12276. result.Rates = rates.ToArray();
  12277. }
  12278. }
  12279. }
  12280. return Ok(JsonView(result));
  12281. }
  12282. /// <summary>
  12283. /// 团组模块 - 出入境费用报价表 - Info
  12284. /// </summary>
  12285. /// <returns></returns>
  12286. [HttpPost]
  12287. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12288. public async Task<IActionResult> EnterExitCostQuoteInfo(EnterExitCostQuoteInfoDto dto)
  12289. {
  12290. var info = await _enterExitCostQuoteRep.InfoAsync(dto);
  12291. if (!info.Rates.Any())
  12292. {
  12293. var rates = await GeneralMethod.EnterExitCostInitRate();
  12294. rates.Add(new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  12295. info.Rates = rates.ToArray();
  12296. }
  12297. return Ok(JsonView(info));
  12298. }
  12299. /// <summary>
  12300. /// 团组模块 - 出入境费用报价表 - OP
  12301. /// </summary>
  12302. /// <returns></returns>
  12303. [HttpPost]
  12304. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12305. public async Task<IActionResult> EnterExitCostQuoteOp(EnterExitCostQuoteOpDto dto)
  12306. {
  12307. return Ok(await _enterExitCostQuoteRep.OpAsync(dto));
  12308. }
  12309. /// <summary>
  12310. /// 团组模块 - 出入境费用报价表 - 删除 项
  12311. /// </summary>
  12312. /// <returns></returns>
  12313. [HttpPost]
  12314. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12315. public async Task<IActionResult> EnterExitCostQuoteItemDel(EnterExitCostQuoteItemDelDto dto)
  12316. {
  12317. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  12318. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12319. return Ok(await _enterExitCostQuoteRep.ItemDelAsync(dto));
  12320. }
  12321. /// <summary>
  12322. /// 团组模块 - 出入境费用报价表 - 导出
  12323. /// </summary>
  12324. /// <returns></returns>
  12325. [HttpPost]
  12326. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12327. public async Task<IActionResult> EnterExitCostQuoteExcelExport(EnterExitCostQuoteExcelExportDto dto)
  12328. {
  12329. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  12330. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12331. var info = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { Id = dto.Id });
  12332. if (info == null) return Ok(JsonView(false, "报价信息未填写!"));
  12333. var rates = info.Rates;
  12334. var intTravelCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1354);//国际旅费
  12335. var accomCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1355); //住宿费
  12336. var mealCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1356); //餐饮费
  12337. var vehArranges = info.FeeItems.FirstOrDefault(x => x.ItemId == 1357); //车辆安排
  12338. var inviteTo = info.FeeItems.FirstOrDefault(x => x.ItemId == 1358); //邀请函发放对象
  12339. var inviteCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1359); //邀请函费用
  12340. var inviteTime = info.FeeItems.FirstOrDefault(x => x.ItemId == 1360); //邀请函发放时间
  12341. var officialActs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1361); //公务活动
  12342. var visaIns = info.FeeItems.FirstOrDefault(x => x.ItemId == 1362); //签证+保险
  12343. var serviceCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1363); //服务费
  12344. var pubMiscs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1364); //公杂费
  12345. var taxCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1365); //税费
  12346. //获取模板
  12347. string tempPath = AppSettingsHelper.Get("ExcelBasePath") + "Template/出入境费用明细报价表模板.xlsx";
  12348. var designer = new WorkbookDesigner();
  12349. designer.Workbook = new Workbook(tempPath);
  12350. designer.SetDataSource("QuoteName", info.Name);
  12351. designer.SetDataSource("CompanyTitle", "公司名称");
  12352. designer.SetDataSource("CompanyLabel", "");
  12353. #region 国际旅费
  12354. designer.SetDataSource("IntTravelTitle", intTravelCosts?.ItemWrapName ?? "国际旅费\r\n(公务舱和经济舱分别罗列)");
  12355. if (intTravelCosts != null && intTravelCosts.Infos.Any())
  12356. {
  12357. var cabClassFilter = new string[] { "经济舱", "公务舱", "头等舱" };
  12358. var label = new StringBuilder();
  12359. var infos = intTravelCosts.Infos.Where(x => cabClassFilter.Contains(x.FeeName)).ToArray();
  12360. if (infos.Any())
  12361. {
  12362. label.Append(infos.Sum(x => x.PplNum));
  12363. label.Append("人全程机票:");
  12364. label.Append(infos.Sum(x => x.TotalAmt).TruncDecimals(2));
  12365. label.AppendLine("元");
  12366. }
  12367. foreach (var item in intTravelCosts.Infos)
  12368. {
  12369. label.Append(item.FeeName);
  12370. label.Append(":");
  12371. label.Append(item.UnitPrice.TruncDecimals(2));
  12372. label.Append("元/人*");
  12373. label.Append(item.PplNum);
  12374. label.AppendLine("人");
  12375. }
  12376. if (label.HasValue())
  12377. {
  12378. label.Append("\r\n以上小计:");
  12379. label.Append(intTravelCosts.TotalAmt.TruncDecimals(2));
  12380. label.Append("元");
  12381. }
  12382. designer.SetDataSource("IntTravelLabel", label.ToString());
  12383. }
  12384. #endregion
  12385. #region 住宿费
  12386. designer.SetDataSource("AccomTitle", accomCosts?.ItemWrapName ?? "住宿费\r\n(请备注明酒店星级)");
  12387. if (accomCosts != null && accomCosts.Infos.Any())
  12388. {
  12389. string currencyName = string.Empty,
  12390. countryName = string.Empty;
  12391. decimal rate = 1.0000M;
  12392. var label = new StringBuilder();
  12393. label.AppendLine("全程五星酒店,每人1间房");
  12394. foreach (var item in accomCosts.Infos)
  12395. {
  12396. //乌兹别克斯坦: 塔什干:120美金/间/晚*2*6人
  12397. string name = string.Empty, thisCountryName = string.Empty;
  12398. if (item.FeeName.Contains('-'))
  12399. {
  12400. var feeName = item.FeeName.Split('-');
  12401. thisCountryName = feeName[0];
  12402. if (!thisCountryName.Equals(countryName)) countryName = feeName[0];
  12403. name = feeName[1];
  12404. }
  12405. else name = item.FeeName;
  12406. string thisFeeName = string.Empty;
  12407. if (!thisCountryName.Equals(countryName)) thisFeeName = $"{countryName}:\r\n{name}:";
  12408. else thisFeeName = $"\r\n{name}:";
  12409. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  12410. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  12411. rate = rateInfo?.Rate ?? 1.0000M;
  12412. string subLabel = string.Format("{0}{1}{2}/间/晚*{3}*{4}人", thisFeeName, item.UnitPrice.TruncDecimals(2), currencyName, item.Quantity.ToString("#0"), item.PplNum.ToString("#0"));
  12413. label.AppendLine(subLabel);
  12414. }
  12415. if (label.HasValue())
  12416. {
  12417. //以上小计:52440元(美金汇率:7.5 )
  12418. string subLabel = string.Format("\r\n以上小计:{0}元({1}汇率:{2})", accomCosts.TotalAmt.TruncDecimals(2), currencyName, rate.TruncDecimals(4));
  12419. label.AppendLine(subLabel);
  12420. }
  12421. designer.SetDataSource("AccomLabel", label.ToString());
  12422. }
  12423. #endregion
  12424. #region 餐饮费
  12425. designer.SetDataSource("MealTitle", mealCosts?.ItemWrapName ?? "餐饮费");
  12426. if (mealCosts != null && mealCosts.Infos.Any())
  12427. {
  12428. string currencyName = string.Empty;
  12429. decimal rate = 1.0000M;
  12430. var label = new StringBuilder();
  12431. label.Append("全程酒店含早,\r\n若因航班过早,\r\n酒店准备路早。\r\n\r\n");
  12432. foreach (var item in mealCosts.Infos)
  12433. {
  12434. string name = string.Empty;
  12435. if (item.FeeName.Contains('-'))
  12436. {
  12437. var feeName = item.FeeName.Split('-');
  12438. name = $"\r\n{feeName[0]}:\r\n{feeName[1]}:";
  12439. }
  12440. else name = $"\r\n{item.FeeName}:";
  12441. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  12442. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  12443. rate = rateInfo?.Rate ?? 1.0000M;
  12444. label.Append(name);
  12445. label.Append(item.UnitPrice.TruncDecimals(2));
  12446. label.Append(currencyName);
  12447. label.Append("/天*");
  12448. label.Append(item.Quantity.ToString("#0"));
  12449. label.Append('*');
  12450. label.Append(item.PplNum);
  12451. label.Append("人\r\n");
  12452. }
  12453. if (label.HasValue())
  12454. {
  12455. label.Append("\r\n以上小计:");
  12456. label.Append(accomCosts.TotalAmt.TruncDecimals(2));
  12457. label.Append("元\r\n(");
  12458. label.Append("汇率:");
  12459. label.Append(rate.TruncDecimals(4));
  12460. label.Append(')');
  12461. }
  12462. designer.SetDataSource("MealLabel", label.ToString());
  12463. }
  12464. #endregion
  12465. #region 车辆安排
  12466. designer.SetDataSource("VehArrangeTitle", vehArranges?.ItemWrapName ?? "车辆安排\r\n(司兼导分开的情况下,车辆品牌、座位及费用)");
  12467. if (vehArranges != null && vehArranges.Infos.Any())
  12468. {
  12469. string currencyName = string.Empty;
  12470. //decimal rate = 1.0000M;
  12471. var label = new StringBuilder();
  12472. foreach (var item in vehArranges.Infos)
  12473. {
  12474. label.AppendLine();
  12475. label.AppendLine();
  12476. label.Append(item.FeeName);
  12477. label.Append($"\r\n\r\n费用:{item.TotalAmt.TruncDecimals(2)}元");
  12478. }
  12479. designer.SetDataSource("VehArrangeLabel", label.ToString());
  12480. }
  12481. #endregion
  12482. #region 邀请函发放对象
  12483. designer.SetDataSource("InviteToTitle", inviteTo?.ItemWrapName ?? "邀请函发放对象");
  12484. designer.SetDataSource("InviteToContent", "");
  12485. #endregion
  12486. #region 邀请函费
  12487. designer.SetDataSource("InviteCostTitle", inviteCosts?.ItemWrapName ?? "邀请函费用");
  12488. var is_label = new StringBuilder();
  12489. if (inviteCosts != null && inviteCosts.Infos.Any())
  12490. {
  12491. string currencyName = string.Empty;
  12492. decimal rate = 1.0000M;
  12493. foreach (var item in inviteCosts.Infos)
  12494. {
  12495. //乌兹别克斯坦:2000美金
  12496. currencyName = item.Currency;
  12497. rate = rates.FirstOrDefault(x => currencyName.Equals(x.CurrencyCode))?.Rate ?? 1.0000M;
  12498. string label = string.Format("{0}:{1}{2}", item.FeeName, item.UnitPrice.TruncDecimals(2), currencyName);
  12499. is_label.AppendLine(label);
  12500. }
  12501. if (is_label.HasValue())
  12502. {
  12503. //以上小计:28500元(美金汇率:7.5)
  12504. string label = string.Format("以上小计:{0}{1}({2}汇率:{3})", inviteCosts.TotalAmt.TruncDecimals(2), "元", currencyName, rate.TruncDecimals(4));
  12505. is_label.AppendLine(label);
  12506. }
  12507. }
  12508. designer.SetDataSource("InviteCostContent", is_label.ToString());
  12509. #endregion
  12510. #region 邀请函发放时间
  12511. designer.SetDataSource("InviteToTimeTitle", inviteTime?.ItemWrapName ?? "邀请函发放时间");
  12512. designer.SetDataSource("InviteToTimeContent", "拿到团员名单10-15工作日");
  12513. #endregion
  12514. #region 公务活动(含翻译)
  12515. designer.SetDataSource("OfficialActsTitle", officialActs?.ItemWrapName ?? "公务活动(含翻译)");
  12516. var oa_label = new StringBuilder();
  12517. if (officialActs != null && officialActs.Infos.Any())
  12518. {
  12519. string currencyName = string.Empty;
  12520. decimal rate = 1.0000M;
  12521. string label_title = string.Empty, label_content = "超出报价部分需额付费:\r\n";
  12522. foreach (var item in officialActs.Infos)
  12523. {
  12524. //乌兹别克斯坦:1000美金/场
  12525. currencyName = item.Currency;
  12526. rate = rates.FirstOrDefault(x => currencyName.Equals(x.CurrencyCode))?.Rate ?? 1.0000M;
  12527. string label_remark = string.Empty;
  12528. if (!string.IsNullOrEmpty(item.Remark)) label_remark = $"({item.Remark})";
  12529. label_content += string.Format("{0}:{1}{2}/场{3}\r\n", item.FeeName, item.UnitPrice.TruncDecimals(2), currencyName, label_remark);
  12530. }
  12531. label_content += "*总费用中未含超出公务活动价格";
  12532. //8场公务活动(以上小计:60000元)
  12533. var quantity = officialActs.Infos.Sum(x => x.Quantity);
  12534. label_title = string.Format("{0}场公务活动(以上小计:{1}元)", quantity, officialActs.TotalAmt.TruncDecimals(2));
  12535. oa_label.AppendLine(label_title);
  12536. oa_label.AppendLine(label_content);
  12537. }
  12538. designer.SetDataSource("OfficialActsContent", oa_label.ToString());
  12539. #endregion
  12540. #region 签证+保险
  12541. designer.SetDataSource("VisaInsTitle", visaIns?.ItemWrapName ?? "签证+保险\r\n(单位:元)");
  12542. var vi_label = new StringBuilder();
  12543. if (visaIns != null && visaIns.Infos.Any())
  12544. {
  12545. foreach (var item in visaIns.Infos)
  12546. {
  12547. //签证:500元/人
  12548. string label = string.Format("{0}:{1}元/人*{2}人", item.FeeName, item.UnitPrice.TruncDecimals(2), item.PplNum);
  12549. vi_label.AppendLine(label);
  12550. }
  12551. if (vi_label.HasValue())
  12552. {
  12553. //以上小计:6000元
  12554. string label = string.Format("以上小计:{0}元", visaIns.TotalAmt.TruncDecimals(2));
  12555. vi_label.AppendLine(label);
  12556. }
  12557. }
  12558. designer.SetDataSource("VisaInsContent", vi_label.ToString());
  12559. #endregion
  12560. #region 服务费
  12561. designer.SetDataSource("ServiceCostTitle", serviceCosts?.ItemWrapName ?? "服务费");
  12562. designer.SetDataSource("ServiceCostContent", serviceCosts?.TotalAmt.TruncDecimals(2) ?? 0.00M);
  12563. #endregion
  12564. #region 公杂费
  12565. designer.SetDataSource("PubMiscsTitle", pubMiscs?.ItemWrapName ?? "公杂费\r\n(发给团组成员)");
  12566. var pm_label = new StringBuilder();
  12567. if (pubMiscs != null && pubMiscs.Infos.Any())
  12568. {
  12569. string currencyName = string.Empty,
  12570. countryName = string.Empty;
  12571. decimal rate = 1.0000M;
  12572. foreach (var item in pubMiscs.Infos)
  12573. {
  12574. //乌兹别克斯坦:塔什干:32美金 / 天 * 3 * 6人
  12575. string name = string.Empty, thisCountryName = string.Empty;
  12576. if (item.FeeName.Contains('-'))
  12577. {
  12578. var feeName = item.FeeName.Split('-');
  12579. thisCountryName = feeName[0];
  12580. if (!thisCountryName.Equals(countryName)) countryName = feeName[0];
  12581. name = feeName[1];
  12582. }
  12583. else name = item.FeeName;
  12584. string thisFeeName = string.Empty;
  12585. if (!thisCountryName.Equals(countryName)) thisFeeName = $"{countryName}:\r\n{name}:";
  12586. else thisFeeName = $"\r\n{name}:";
  12587. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  12588. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  12589. rate = rateInfo?.Rate ?? 1.0000M;
  12590. string label = string.Format("{0}:{1}{2}/天*{3}*{4}人", thisFeeName, item.UnitPrice.TruncDecimals(2), currencyName, item.Quantity, item.PplNum);
  12591. pm_label.AppendLine(label);
  12592. }
  12593. if (pm_label.HasValue())
  12594. {
  12595. //以上小计:13497.6元\r\n(美金汇率:7.5 )\r\n部分发放成员
  12596. pm_label.AppendLine(string.Format("以上小计:{0}元", pubMiscs.TotalAmt.TruncDecimals(2)));
  12597. pm_label.AppendLine(string.Format("({0}汇率:{1})", currencyName, rate.TruncDecimals(4)));
  12598. pm_label.AppendLine(string.Format("部分发放成员"));
  12599. }
  12600. }
  12601. designer.SetDataSource("PubMiscsContent", pm_label.ToString());
  12602. #endregion
  12603. #region 税费
  12604. designer.SetDataSource("TaxCostTitle", taxCosts?.ItemWrapName ?? "税费");
  12605. designer.SetDataSource("TaxCostContent", taxCosts?.TotalAmt.TruncDecimals(2) ?? 0.00M);
  12606. #endregion
  12607. #region 合计(单位:元)
  12608. designer.SetDataSource("CostTotalTitle", "合计\r\n(单位:元)");
  12609. designer.SetDataSource("CostTotalContent", info.FeeItems.Sum(x => x.TotalAmt).TruncDecimals(2));
  12610. #endregion
  12611. #region 汇率 Remark
  12612. var rate_label = new StringBuilder();
  12613. var rateGroups = rates.GroupBy(x => x.CurrencyName);
  12614. foreach (var item in rateGroups)
  12615. {
  12616. //美元汇率按\r\n1:7.5
  12617. string label = string.Format("{0}汇率按\r\n1:{1}", item.Key, item.FirstOrDefault()?.Rate.TruncDecimals(4) ?? 0.0000M);
  12618. rate_label.AppendLine(label);
  12619. }
  12620. designer.SetDataSource("RateLabel", rate_label.ToString());
  12621. #endregion
  12622. designer.Process();
  12623. //文件名
  12624. string fileName = $"{info.Name}{DateTime.Now:yyyyMMddHHmmss}.xls";
  12625. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + "EnterExitCostQuote/" + fileName);
  12626. string url = AppSettingsHelper.Get("ExcelBaseUrl") + "Office/Excel/EnterExitCostQuote/" + fileName;
  12627. return Ok(JsonView(true, "成功", url));
  12628. }
  12629. #endregion
  12630. #region 签证费用录入
  12631. /// <summary>
  12632. /// 根据diid查询签证费用列表
  12633. /// </summary>
  12634. /// <param name="dto"></param>
  12635. /// <returns></returns>
  12636. [HttpPost]
  12637. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12638. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  12639. {
  12640. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  12641. if (groupData.Code != 0)
  12642. {
  12643. return Ok(JsonView(false, groupData.Msg));
  12644. }
  12645. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12646. }
  12647. /// <summary>
  12648. /// 根据签证费用Id查询单条数据及c表数据
  12649. /// </summary>
  12650. /// <param name="dto"></param>
  12651. /// <returns></returns>
  12652. [HttpPost]
  12653. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12654. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  12655. {
  12656. Result groupData = await _visaPriceRep.PostVisaById(dto);
  12657. if (groupData.Code != 0)
  12658. {
  12659. return Ok(JsonView(false, groupData.Msg));
  12660. }
  12661. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12662. }
  12663. /// <summary>
  12664. /// 签证费用删除
  12665. /// </summary>
  12666. /// <param name="dto"></param>
  12667. /// <returns></returns>
  12668. [HttpPost]
  12669. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12670. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  12671. {
  12672. _sqlSugar.BeginTran();
  12673. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  12674. if (!res)
  12675. {
  12676. _sqlSugar.RollbackTran();
  12677. return Ok(JsonView(false, "删除失败"));
  12678. }
  12679. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  12680. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  12681. .SetColumns(a => new Grp_CreditCardPayment()
  12682. {
  12683. IsDel = 1,
  12684. DeleteUserId = dto.DeleteUserId,
  12685. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12686. })
  12687. .ExecuteCommand();
  12688. if (resSub < 1)
  12689. {
  12690. _sqlSugar.RollbackTran();
  12691. return Ok(JsonView(false, "删除失败"));
  12692. }
  12693. _sqlSugar.CommitTran();
  12694. return Ok(JsonView(true, "删除成功!"));
  12695. }
  12696. /// <summary>
  12697. /// 签证费用录入下拉框初始化
  12698. /// </summary>
  12699. /// <returns></returns>
  12700. [HttpPost]
  12701. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12702. public async Task<IActionResult> VisaPriceAddSelect()
  12703. {
  12704. //支付方式
  12705. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  12706. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  12707. //币种
  12708. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  12709. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  12710. //乘客类型
  12711. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  12712. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  12713. //卡类型
  12714. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  12715. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  12716. //代办费类型
  12717. var agencyFeeTypeData = new List<dynamic>() {
  12718. new { id = 0 , Text = "未选择" },
  12719. new { id = 1 , Text = "小公务" },
  12720. new { id = 2 , Text = "大公务" },
  12721. };
  12722. //签证费用标准国家Data
  12723. var visaCountryFeeData = _sqlSugar.Queryable<Res_CountryFeeCost>().Where(x => x.IsDel == 0).Select(x => new { x.Id, Country = x.VisaCountry }).ToList();
  12724. var data = new
  12725. {
  12726. Payment = _Payment,
  12727. CurrencyList = _CurrencyList,
  12728. PassengerType = _PassengerType,
  12729. BankCard = _BankCard,
  12730. AgencyFeeType = agencyFeeTypeData,
  12731. CountryFeeData = visaCountryFeeData
  12732. };
  12733. return Ok(JsonView(true, "查询成功!", data));
  12734. }
  12735. /// <summary>
  12736. /// 签证费用录入操作(Status:1.新增,2.修改)
  12737. /// </summary>
  12738. /// <param name="dto"></param>
  12739. /// <returns></returns>
  12740. [HttpPost]
  12741. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12742. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  12743. {
  12744. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  12745. if (groupData.Code != 0)
  12746. {
  12747. return Ok(JsonView(false, groupData.Msg));
  12748. }
  12749. #region 应用推送
  12750. try
  12751. {
  12752. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  12753. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  12754. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  12755. //2024-10-21 新增LZ UID
  12756. var userIds = new List<int>() { 21 };
  12757. string title = $"系统通知";
  12758. string content = "";
  12759. var diId = dto.DiId;
  12760. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  12761. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  12762. if (dto.Status == 1) content = $"[新增-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  12763. else if (dto.Status == 2) content = $"[更新-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  12764. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  12765. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "80" };
  12766. await APNsTools.iOS_PushNotifications1("051", $"签证费用审核", "", content, true, "ExpenseAuditWebView", h5);
  12767. }
  12768. catch (Exception ex)
  12769. {
  12770. }
  12771. #endregion
  12772. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12773. }
  12774. #endregion
  12775. #region 签证提成录入
  12776. /// <summary>
  12777. /// 签证提成录入
  12778. /// 基础数据
  12779. /// </summary>
  12780. /// <returns></returns>
  12781. [HttpGet]
  12782. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12783. public async Task<IActionResult> VisaCommissionInit()
  12784. {
  12785. return Ok(await _visaCommissionRep.Init());
  12786. }
  12787. /// <summary>
  12788. /// 签证提成录入
  12789. /// Item
  12790. /// </summary>
  12791. /// <param name="_dto"></param>
  12792. /// <returns></returns>
  12793. [HttpPost]
  12794. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12795. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
  12796. {
  12797. var validator = new VisaCommissionItemDtoValidator();
  12798. var validatorRes = await validator.ValidateAsync(_dto);
  12799. if (!validatorRes.IsValid)
  12800. {
  12801. var sb = new StringBuilder();
  12802. foreach (var item in validatorRes.Errors)
  12803. {
  12804. sb.AppendLine(item.ErrorMessage);
  12805. }
  12806. return Ok(JsonView(false, sb.ToString()));
  12807. }
  12808. return Ok(await _visaCommissionRep.Item(_dto));
  12809. }
  12810. /// <summary>
  12811. /// 签证提成录入
  12812. /// Save
  12813. /// </summary>
  12814. /// <param name="_dto"></param>
  12815. /// <returns></returns>
  12816. [HttpPost]
  12817. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12818. public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
  12819. {
  12820. //参数验证
  12821. if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
  12822. foreach (var item in _dto.Items)
  12823. {
  12824. if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
  12825. if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
  12826. if (string.IsNullOrEmpty(item.Country)) return Ok(JsonView(false, "国家为空!"));
  12827. //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
  12828. }
  12829. return Ok(await _visaCommissionRep.Save(_dto));
  12830. }
  12831. /// <summary>
  12832. /// 签证提成录入
  12833. /// Create
  12834. /// </summary>
  12835. /// <param name="_dto"></param>
  12836. /// <returns></returns>
  12837. [HttpPost]
  12838. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12839. public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
  12840. {
  12841. var validator = new VisaCommissionCreateDtoValidator();
  12842. var validatorRes = await validator.ValidateAsync(_dto);
  12843. if (!validatorRes.IsValid)
  12844. {
  12845. var sb = new StringBuilder();
  12846. foreach (var item in validatorRes.Errors)
  12847. {
  12848. sb.AppendLine(item.ErrorMessage);
  12849. }
  12850. return Ok(JsonView(false, sb.ToString()));
  12851. }
  12852. return Ok(await _visaCommissionRep.Create(_dto));
  12853. }
  12854. /// <summary>
  12855. /// 签证提成录入
  12856. /// Put(编辑)
  12857. /// </summary>
  12858. /// <param name="id"></param>
  12859. /// <param name="_dto"></param>
  12860. /// <returns></returns>
  12861. [HttpPut]
  12862. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12863. public async Task<IActionResult> VisaCommissionEdit(int id, VisaCommissionCreateDto _dto)
  12864. {
  12865. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  12866. var validator = new VisaCommissionCreateDtoValidator();
  12867. var validatorRes = await validator.ValidateAsync(_dto);
  12868. if (!validatorRes.IsValid)
  12869. {
  12870. var sb = new StringBuilder();
  12871. foreach (var item in validatorRes.Errors)
  12872. {
  12873. sb.AppendLine(item.ErrorMessage);
  12874. }
  12875. return Ok(JsonView(false, sb.ToString()));
  12876. }
  12877. return Ok(await _visaCommissionRep.Edit(id, _dto));
  12878. }
  12879. /// <summary>
  12880. /// 签证提成录入
  12881. /// Del
  12882. /// </summary>
  12883. /// <param name="id"></param>
  12884. /// <param name="currUserId"></param>
  12885. /// <returns></returns>
  12886. [HttpPost]
  12887. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12888. public async Task<IActionResult> VisaCommissionDel(int id, int currUserId)
  12889. {
  12890. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  12891. if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
  12892. return Ok(await _visaCommissionRep.Del(id, currUserId));
  12893. }
  12894. #endregion
  12895. #region op费用录入
  12896. /// <summary>
  12897. /// 根据diid查询op费用列表
  12898. /// </summary>
  12899. /// <param name="dto"></param>
  12900. /// <returns></returns>
  12901. [HttpPost]
  12902. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12903. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  12904. {
  12905. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  12906. if (groupData.Code != 0)
  12907. {
  12908. return Ok(JsonView(false, groupData.Msg));
  12909. }
  12910. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12911. }
  12912. /// <summary>
  12913. /// 根据op费用Id查询单条数据及c表数据
  12914. /// </summary>
  12915. /// <param name="dto"></param>
  12916. /// <returns></returns>
  12917. [HttpPost]
  12918. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12919. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  12920. {
  12921. try
  12922. {
  12923. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  12924. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  12925. var data = new
  12926. {
  12927. CarTouristGuideGround = _groupData,
  12928. CreditCardPayment = _creditCardPayment
  12929. };
  12930. return Ok(JsonView(true, "查询成功!", data));
  12931. }
  12932. catch (Exception ex)
  12933. {
  12934. return Ok(JsonView(false, "程序错误!"));
  12935. }
  12936. }
  12937. /// <summary>
  12938. /// op费用删除
  12939. /// </summary>
  12940. /// <param name="dto"></param>
  12941. /// <returns></returns>
  12942. [HttpPost]
  12943. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12944. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  12945. {
  12946. try
  12947. {
  12948. _sqlSugar.BeginTran();
  12949. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  12950. if (!res)
  12951. {
  12952. return Ok(JsonView(false, "删除失败"));
  12953. }
  12954. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  12955. {
  12956. IsDel = 1,
  12957. DeleteUserId = dto.DeleteUserId,
  12958. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12959. }).ExecuteCommandAsync();
  12960. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  12961. {
  12962. IsDel = 1,
  12963. DeleteUserId = dto.DeleteUserId,
  12964. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12965. }).ExecuteCommandAsync();
  12966. #region 删除超支相关数据
  12967. //删除导入的超支数据
  12968. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  12969. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  12970. {
  12971. IsDel = 1,
  12972. DeleteUserId = dto.DeleteUserId,
  12973. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12974. }).ExecuteCommand();
  12975. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  12976. {
  12977. IsDel = 1,
  12978. DeleteUserId = dto.DeleteUserId,
  12979. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12980. }).ExecuteCommand();
  12981. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  12982. {
  12983. IsDel = 1,
  12984. DeleteUserId = dto.DeleteUserId,
  12985. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12986. }).ExecuteCommand();
  12987. #endregion
  12988. _sqlSugar.CommitTran();
  12989. return Ok(JsonView(true, "删除成功!"));
  12990. }
  12991. catch (Exception ex)
  12992. {
  12993. _sqlSugar.RollbackTran();
  12994. return Ok(JsonView(false, "程序错误!" + ex.Message));
  12995. }
  12996. }
  12997. /// <summary>
  12998. /// op费用录入操作(Status:1.新增,2.修改)
  12999. /// </summary>
  13000. /// <param name="dto"></param>
  13001. /// <returns></returns>
  13002. [HttpPost]
  13003. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13004. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  13005. {
  13006. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  13007. if (groupData.Code != 0)
  13008. {
  13009. return Ok(JsonView(false, groupData.Msg));
  13010. }
  13011. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  13012. }
  13013. /// <summary>
  13014. /// 填写费用详细页面初始化绑定
  13015. /// </summary>
  13016. /// <param name="dto"></param>
  13017. /// <returns></returns>
  13018. [HttpPost]
  13019. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13020. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  13021. {
  13022. try
  13023. {
  13024. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  13025. if (groupData.Code != 0)
  13026. {
  13027. return Ok(JsonView(false, groupData.Msg));
  13028. }
  13029. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  13030. }
  13031. catch (Exception ex)
  13032. {
  13033. return Ok(JsonView(false, ex.Message));
  13034. }
  13035. }
  13036. /// <summary>
  13037. /// 根据op费用Id查询详细数据
  13038. /// </summary>
  13039. /// <param name="dto"></param>
  13040. /// <returns></returns>
  13041. [HttpPost]
  13042. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13043. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  13044. {
  13045. try
  13046. {
  13047. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  13048. if (groupData.Code != 0)
  13049. {
  13050. return Ok(JsonView(false, groupData.Msg));
  13051. }
  13052. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  13053. }
  13054. catch (Exception ex)
  13055. {
  13056. return Ok(JsonView(false, ex.Message));
  13057. }
  13058. }
  13059. /// <summary>
  13060. /// OP费用录入填写详情
  13061. /// </summary>
  13062. /// <param name="dto"></param>
  13063. /// <returns></returns>
  13064. [HttpPost]
  13065. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13066. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  13067. {
  13068. try
  13069. {
  13070. #region 参数校验
  13071. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  13072. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  13073. if (di == null) return Ok(JsonView(false, "团组错误!"));
  13074. #endregion
  13075. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  13076. if (groupData.Code != 0)
  13077. {
  13078. return Ok(JsonView(false, groupData.Msg));
  13079. }
  13080. //自动审核
  13081. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  13082. #region 应用推送
  13083. try
  13084. {
  13085. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  13086. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  13087. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  13088. //2024-10-21 新增LZ UID
  13089. var userIds = new List<int>() { 21 };
  13090. string title = $"系统通知";
  13091. var diId = dto.DiId;
  13092. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  13093. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  13094. string content = $"[更新-OP费用录入填写详情({groupInfo?.TeamName ?? "-"})]一项费用:{(((ccpInfo.PayMoney * ccpInfo.DayRate) / 100) * ccpInfo.PayPercentage):#0.00} CNY;";
  13095. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  13096. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "79" };
  13097. await APNsTools.iOS_PushNotifications1("051", $"OP费用审核", "", content, true, "ExpenseAuditWebView", h5);
  13098. }
  13099. catch (Exception ex)
  13100. {
  13101. }
  13102. #endregion
  13103. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  13104. }
  13105. catch (Exception ex)
  13106. {
  13107. return Ok(JsonView(false, ex.Message));
  13108. }
  13109. }
  13110. /// <summary>
  13111. /// 获取三公详细所有城市
  13112. /// </summary>
  13113. /// <returns></returns>
  13114. [HttpGet]
  13115. public IActionResult OpCarCityResult()
  13116. {
  13117. var jw = JsonView(false);
  13118. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  13119. {
  13120. x.Id,
  13121. x.Country,
  13122. x.City,
  13123. }).ToList();
  13124. if (data.Count > 0)
  13125. {
  13126. jw = JsonView(true, "获取成功!", data);
  13127. }
  13128. else
  13129. {
  13130. jw.Msg = "城市数据为空!";
  13131. jw.Data = Array.Empty<string>();
  13132. }
  13133. return Ok(jw);
  13134. }
  13135. /// <summary>
  13136. /// 导出地接费用明细
  13137. /// </summary>
  13138. /// <param name="dto"></param>
  13139. /// <returns></returns>
  13140. [HttpPost]
  13141. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  13142. {
  13143. var jw = JsonView(false);
  13144. if (dto.Diid < 1)
  13145. {
  13146. jw.Msg = "请输入正确的diid!";
  13147. return Ok(jw);
  13148. }
  13149. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  13150. if (group == null)
  13151. {
  13152. jw.Msg = "未找到团组信息!";
  13153. return Ok(jw);
  13154. }
  13155. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  13156. if (localGuideArr.Count == 0)
  13157. {
  13158. jw.Msg = "该团组暂无地接信息!";
  13159. return Ok(jw);
  13160. }
  13161. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  13162. var overspendSoure = new Dictionary<int, int>
  13163. {
  13164. { 91, 982 }, //车
  13165. { 92 , 1059} ,//导游
  13166. { 994 , 1073}, //翻译
  13167. { 988 , 1074 }, //早餐
  13168. { 93 , 1075 }, //午餐
  13169. { 989 , 1076 }, //晚餐
  13170. };
  13171. var Zips = new Dictionary<string, Stream>();
  13172. foreach (var groupArr in localGroup)
  13173. {
  13174. var keyValue = groupArr.Key;
  13175. if (int.TryParse(keyValue, out int cityid))
  13176. {
  13177. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  13178. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  13179. }
  13180. var contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  13181. foreach (var item in groupArr)
  13182. {
  13183. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  13184. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  13185. new Grp_CarTouristGuideGroundReservationsContentExtend
  13186. {
  13187. Count = a.Count,
  13188. CreateTime = a.CreateTime,
  13189. CreateUserId = a.CreateUserId,
  13190. CTGGRId = a.CTGGRId,
  13191. Currency = a.Currency,
  13192. DatePrice = a.DatePrice,
  13193. DeleteTime = a.DeleteTime,
  13194. DeleteUserId = a.DeleteUserId,
  13195. DiId = a.DiId,
  13196. Id = a.Id,
  13197. IsDel = a.IsDel,
  13198. Price = a.Price,
  13199. PriceContent = a.PriceContent,
  13200. Remark = a.Remark,
  13201. SId = a.SId,
  13202. SidName = b.Name,
  13203. Units = a.Units,
  13204. }
  13205. ).ToList();
  13206. if (content.Count > 0)
  13207. {
  13208. contentArr.Add(content);
  13209. }
  13210. }
  13211. //open excel
  13212. //set excel
  13213. //save excel
  13214. try
  13215. {
  13216. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  13217. IWorkbook workbook;
  13218. if (Path.GetExtension(filePath).ToLower() == ".xls")
  13219. {
  13220. workbook = new NPOI.HSSF.UserModel.HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  13221. }
  13222. else
  13223. {
  13224. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  13225. }
  13226. ISheet sheet = workbook.GetSheetAt(0);
  13227. var rowStartIndex = 2;
  13228. var clounmCount = 10;
  13229. var initStyleRow = sheet.GetRow(2);
  13230. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  13231. //var overspendArrDetail =
  13232. var existsId = new List<CarCompare>();
  13233. var lastElem = arr.Last();
  13234. var thisSid = -1;
  13235. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  13236. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  13237. {
  13238. Name = "未知币种!",
  13239. Remark = "未知币种!",
  13240. };
  13241. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  13242. Action cloneRowFn = () =>
  13243. {
  13244. rowStartIndex++;
  13245. var cloneRow = sheet.CreateRow(rowStartIndex);
  13246. // 复制样式
  13247. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  13248. {
  13249. ICell sourceCell = initStyleRow.GetCell(i);
  13250. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  13251. // 确保单元格存在样式
  13252. if (sourceCell.CellStyle != null)
  13253. {
  13254. targetCell.CellStyle = sourceCell.CellStyle;
  13255. }
  13256. }
  13257. };
  13258. var mergeRow = () =>
  13259. {
  13260. for (int i = 2; i < sheet.LastRowNum; i++)
  13261. {
  13262. var row = sheet.GetRow(i);
  13263. var cellFirst = row.GetCell(0);
  13264. var thisIndex = i + 1;
  13265. while (thisIndex < sheet.LastRowNum)
  13266. {
  13267. var nextRow = sheet.GetRow(thisIndex);
  13268. var nextCellFirst = nextRow.GetCell(0);
  13269. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  13270. {
  13271. thisIndex++;
  13272. }
  13273. else
  13274. {
  13275. break;
  13276. }
  13277. }
  13278. thisIndex--;
  13279. if (thisIndex != i)
  13280. {
  13281. //合并row
  13282. var cellRangeAddress = new CellRangeAddress(
  13283. i, // 起始行索引(0-based)
  13284. thisIndex, // 结束行索引(0-based)
  13285. 0, // 起始列索引(0-based)
  13286. 0 // 结束列索引(0-based)
  13287. );
  13288. sheet.AddMergedRegion(cellRangeAddress);
  13289. i = thisIndex;
  13290. }
  13291. }
  13292. };
  13293. var chaoshiNumber = 0;
  13294. var totalNumber = 0.00M;
  13295. string lastStr = "";
  13296. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  13297. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  13298. {
  13299. b.IsAuditGM,
  13300. x.Id,
  13301. x.Area,
  13302. b.PayPercentage,
  13303. b.PayMoney,
  13304. }).ToList();
  13305. string yesPayment = "", noPayment = "";
  13306. foreach (var item in queryCarArrByCityAndDiid)
  13307. {
  13308. if (item.IsAuditGM == 1)
  13309. {
  13310. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  13311. }
  13312. else
  13313. {
  13314. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  13315. }
  13316. }
  13317. lastStr = yesPayment + noPayment;
  13318. foreach (var item in arr)
  13319. {
  13320. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.ContainsValue(item.SId))
  13321. {
  13322. if (thisSid != item.SId)
  13323. {
  13324. if (thisSid == -1)
  13325. {
  13326. thisSid = item.SId;
  13327. }
  13328. else
  13329. {
  13330. //合并小计行
  13331. //创建合并区域的实例
  13332. var cellRangeAddress = new CellRangeAddress(
  13333. rowStartIndex, // 起始行索引(0-based)
  13334. rowStartIndex, // 结束行索引(0-based)
  13335. 0, // 起始列索引(0-based)
  13336. 3 // 结束列索引(0-based)
  13337. );
  13338. sheet.AddMergedRegion(cellRangeAddress);
  13339. var CellStyle = workbook.CreateCellStyle();
  13340. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  13341. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  13342. CellStyle.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground; // 填充方式
  13343. for (int i = 0; i <= clounmCount; i++)
  13344. {
  13345. if (i > 6)
  13346. {
  13347. var CellStyle1 = workbook.CreateCellStyle();
  13348. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  13349. IFont Font = workbook.CreateFont(); // 创建字体
  13350. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  13351. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  13352. CellStyle1.SetFont(Font);
  13353. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  13354. }
  13355. else
  13356. {
  13357. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  13358. }
  13359. }
  13360. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  13361. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  13362. //超时合计
  13363. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  13364. //超时数
  13365. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  13366. //超时合计费用
  13367. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  13368. thisSid = item.SId;
  13369. cloneRowFn();
  13370. chaoshiNumber = 0;
  13371. totalNumber = 0;
  13372. }
  13373. }
  13374. IRow row = sheet.GetRow(rowStartIndex);
  13375. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  13376. var isOpenOverspendSoure = overspendSoure.ContainsKey(item.SId);
  13377. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  13378. if (isOpenOverspendSoure)
  13379. {
  13380. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  13381. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  13382. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  13383. }
  13384. for (int i = 0; i <= clounmCount; i++)
  13385. {
  13386. var cell = row.GetCell(i);
  13387. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  13388. if (cell == null)
  13389. {
  13390. cell = row.CreateCell(i);
  13391. }
  13392. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  13393. fontRed.CloneStyleFrom(cell.CellStyle);
  13394. IFont Font = workbook.CreateFont(); // 创建字体
  13395. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  13396. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  13397. fontRed.SetFont(Font);
  13398. byte[] rgb = new byte[3] { 255, 242, 204 };
  13399. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  13400. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  13401. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  13402. if (workbook is XSSFWorkbook)
  13403. {
  13404. BackgroundColor255_242_204.FillForegroundColor = 0;
  13405. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  13406. BackgroundColor255_242_204.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground;
  13407. }
  13408. else
  13409. {
  13410. BackgroundColor255_242_204.FillForegroundColor = (((NPOI.HSSF.UserModel.HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  13411. }
  13412. if (i == 1 || i > 6)
  13413. {
  13414. if (i > 6)
  13415. {
  13416. fontRed.FillForegroundColor = 0;
  13417. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  13418. fontRed.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground;
  13419. }
  13420. cell.CellStyle = fontRed;
  13421. }
  13422. if (i > 2 && i < 7)
  13423. {
  13424. cell.CellStyle = BackgroundColor255_242_204;
  13425. }
  13426. cell.SetCellValue(setCellValue); //写入单元格
  13427. }
  13428. if (overspendSoure.ContainsKey(thisSid))
  13429. {
  13430. var overspendId = overspendSoure[thisSid];
  13431. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  13432. }
  13433. cloneRowFn();
  13434. existsId.Add(new CarCompare
  13435. {
  13436. DataPrice = item.DatePrice.ObjToDate(),
  13437. Sid = item.SId
  13438. });
  13439. }
  13440. if (item.Equals(lastElem))
  13441. {
  13442. //合并小计行
  13443. //创建合并区域的实例
  13444. var cellRangeAddress = new CellRangeAddress(
  13445. rowStartIndex, // 起始行索引(0-based)
  13446. rowStartIndex, // 结束行索引(0-based)
  13447. 0, // 起始列索引(0-based)
  13448. 3 // 结束列索引(0-based)
  13449. );
  13450. sheet.AddMergedRegion(cellRangeAddress);
  13451. var CellStyle = workbook.CreateCellStyle();
  13452. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  13453. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  13454. CellStyle.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground; // 填充方式
  13455. for (int i = 0; i <= clounmCount; i++)
  13456. {
  13457. if (i > 6)
  13458. {
  13459. var CellStyle1 = workbook.CreateCellStyle();
  13460. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  13461. IFont Font = workbook.CreateFont(); // 创建字体
  13462. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  13463. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  13464. CellStyle1.SetFont(Font);
  13465. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  13466. }
  13467. else
  13468. {
  13469. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  13470. }
  13471. }
  13472. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  13473. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  13474. //超时合计
  13475. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  13476. //超时数
  13477. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  13478. //超时合计费用
  13479. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  13480. cloneRowFn();
  13481. // 创建合并区域的实例
  13482. cellRangeAddress = new CellRangeAddress(
  13483. rowStartIndex, // 起始行索引(0-based)
  13484. rowStartIndex, // 结束行索引(0-based)
  13485. 0, // 起始列索引(0-based)
  13486. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  13487. );
  13488. // 添加合并区域
  13489. sheet.AddMergedRegion(cellRangeAddress);
  13490. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  13491. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  13492. }
  13493. }
  13494. mergeRow();
  13495. // 保存修改后的Excel文件到新文件
  13496. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  13497. // new FileStream(newFilePath, FileMode.CreateNew)
  13498. using (var stream = new MemoryStream())
  13499. {
  13500. workbook.Write(stream, true);
  13501. stream.Flush();
  13502. stream.Seek(0, SeekOrigin.Begin);
  13503. var memoryStream = new MemoryStream();
  13504. stream.CopyTo(memoryStream);
  13505. memoryStream.Seek(0, SeekOrigin.Begin);
  13506. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  13507. }
  13508. workbook.Close();
  13509. workbook.Dispose();
  13510. }
  13511. catch (Exception ex)
  13512. {
  13513. jw.Msg = "出现异常!" + ex.Message;
  13514. return Ok(jw);
  13515. }
  13516. }
  13517. if (Zips.Count > 0)
  13518. {
  13519. var io = new IOOperatorHelper();
  13520. var byts = io.ConvertZipStream(Zips);
  13521. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  13522. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  13523. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  13524. }
  13525. else
  13526. {
  13527. jw.Msg = "暂无生成文件!";
  13528. }
  13529. return Ok(jw);
  13530. }
  13531. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  13532. {
  13533. string outStr = string.Empty;
  13534. switch (i)
  13535. {
  13536. case 0:
  13537. outStr = arr[0].SidName;
  13538. break;
  13539. case 1:
  13540. outStr = arr[0].DataPriceStr;
  13541. break;
  13542. case 2:
  13543. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  13544. break;
  13545. case 4:
  13546. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  13547. break;
  13548. case 7:
  13549. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13550. {
  13551. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  13552. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  13553. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  13554. }
  13555. break;
  13556. case 8:
  13557. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13558. {
  13559. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  13560. }
  13561. break;
  13562. case 9:
  13563. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13564. {
  13565. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  13566. }
  13567. break;
  13568. case 10:
  13569. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13570. {
  13571. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  13572. }
  13573. break;
  13574. }
  13575. return outStr;
  13576. }
  13577. #region OP行程单
  13578. /// <summary>
  13579. /// OP行程单初始化
  13580. /// </summary>
  13581. /// <param name="dto"></param>
  13582. /// <returns></returns>
  13583. [HttpPost]
  13584. public IActionResult InitOpTravel(InitOpTravelDto dto)
  13585. {
  13586. var jw = JsonView(false);
  13587. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  13588. var group = groupList.First();
  13589. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  13590. if (group == null)
  13591. {
  13592. jw.Msg = "暂无团组!";
  13593. return Ok(jw);
  13594. }
  13595. group = groupList.Find(x => x.Id == diid);
  13596. if (group == null)
  13597. {
  13598. jw.Msg = "请输入正确的团组ID!";
  13599. return Ok(jw);
  13600. }
  13601. string city = string.Empty;
  13602. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  13603. if (blackCode.Count > 0)
  13604. {
  13605. var black = blackCode.First();
  13606. black.BlackCode = black.BlackCode ?? "";
  13607. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  13608. if (blackSp.Length > 0)
  13609. {
  13610. try
  13611. {
  13612. var cityArrCode = new List<string>(20);
  13613. foreach (var item in blackSp)
  13614. {
  13615. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  13616. var IndexSelect = itemSp[2];
  13617. var cityArrCodeLength = cityArrCode.Count - 1;
  13618. var startCity = IndexSelect.Substring(0, 3);
  13619. if (cityArrCodeLength > 0)
  13620. {
  13621. var arrEndCity = cityArrCode[cityArrCodeLength];
  13622. if (arrEndCity != startCity)
  13623. {
  13624. cityArrCode.Add(startCity.ToUpper());
  13625. }
  13626. }
  13627. else
  13628. {
  13629. cityArrCode.Add(startCity.ToUpper());
  13630. }
  13631. var endCity = IndexSelect.Substring(3, 3);
  13632. cityArrCode.Add(endCity.ToUpper());
  13633. }
  13634. var cityThree = string.Empty;
  13635. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  13636. cityThree = cityThree.TrimEnd(',');
  13637. if (string.IsNullOrWhiteSpace(cityThree))
  13638. {
  13639. throw new
  13640. Exception("error");
  13641. }
  13642. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  13643. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  13644. foreach (var item in cityArrCode)
  13645. {
  13646. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  13647. if (find != null)
  13648. {
  13649. city += find.City + "/";
  13650. }
  13651. else
  13652. {
  13653. city += item + "三字码未收入/";
  13654. }
  13655. }
  13656. city = city.TrimEnd('/');
  13657. }
  13658. catch (Exception e)
  13659. {
  13660. city = "黑屏代码格式不正确!";
  13661. }
  13662. }
  13663. }
  13664. else
  13665. {
  13666. city = "未录入黑屏代码";
  13667. }
  13668. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  13669. {
  13670. Date = x.Date,
  13671. Days = x.Days,
  13672. Diffgroup = x.Diffgroup,
  13673. Diid = x.Diid,
  13674. Traffic_First = x.Traffic_First,
  13675. Traffic_Second = x.Traffic_Second,
  13676. Trip = x.Trip,
  13677. WeekDay = x.WeekDay,
  13678. Id = x.Id
  13679. }).ToList();
  13680. jw.Data = new
  13681. {
  13682. groupList = groupList.Select(x => new
  13683. {
  13684. x.Id,
  13685. x.TeamName,
  13686. x.TourCode
  13687. }).ToList(),
  13688. groupInfo = new
  13689. {
  13690. group.VisitDays,
  13691. group.TourCode,
  13692. group.VisitPNumber,
  13693. group.TeamName,
  13694. city
  13695. },
  13696. OpTravelList
  13697. };
  13698. jw.Code = 200;
  13699. jw.Msg = "操作成功!";
  13700. return Ok(jw);
  13701. }
  13702. /// <summary>
  13703. /// 删除团组行程单
  13704. /// </summary>
  13705. /// <returns></returns>
  13706. [HttpPost]
  13707. public IActionResult DelTravel(DelOpTravelDto dto)
  13708. {
  13709. var jw = JsonView(false);
  13710. if (dto.UserId <= 0 || dto.Diid <= 0)
  13711. {
  13712. jw.Msg = "请输入正确的参数!";
  13713. return Ok(jw);
  13714. }
  13715. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  13716. .SetColumns(x => new Grp_TravelList
  13717. {
  13718. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  13719. DeleteUserId = dto.UserId,
  13720. IsDel = 1,
  13721. }).ExecuteCommand();
  13722. jw = JsonView(true);
  13723. return Ok(jw);
  13724. }
  13725. /// <summary>
  13726. /// 行程单保存
  13727. /// </summary>
  13728. /// <returns></returns>
  13729. [HttpPost]
  13730. public IActionResult TravelSave(TravelSaveDto dto)
  13731. {
  13732. var jw = JsonView(false);
  13733. if (dto.Arr.Count > 0)
  13734. {
  13735. try
  13736. {
  13737. var travelList_DB = _sqlSugar.Queryable<Grp_TravelList>()
  13738. .Where(x => dto.Arr.Select(x => x.Id).Contains(x.Id))
  13739. .ToList();
  13740. _sqlSugar.BeginTran();
  13741. foreach (var item in dto.Arr)
  13742. {
  13743. if (item.Id == 0)
  13744. {
  13745. throw new Exception("请传入正确的Id");
  13746. }
  13747. //比较上一次的差异
  13748. var findTravel = travelList_DB.Find(x => x.Id == item.Id);
  13749. if (findTravel != null)
  13750. {
  13751. item.Trip = item.Trip.Replace("[++]", string.Empty);
  13752. findTravel.Trip = findTravel.Trip.Replace("[++]", string.Empty);
  13753. item.Trip = CheckStr(findTravel.Trip, item.Trip);
  13754. }
  13755. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  13756. .SetColumns(x => new Grp_TravelList
  13757. {
  13758. Trip = item.Trip
  13759. }).ExecuteCommand();
  13760. }
  13761. _sqlSugar.CommitTran();
  13762. jw = JsonView(true);
  13763. }
  13764. catch (Exception ex)
  13765. {
  13766. _sqlSugar.RollbackTran();
  13767. jw.Msg = "程序异常!" + ex.Message;
  13768. }
  13769. }
  13770. else
  13771. {
  13772. jw.Msg = "请传入正确的参数!";
  13773. }
  13774. return Ok(jw);
  13775. }
  13776. private static string CheckStr(string original, string changed)
  13777. {
  13778. // 创建diff_match_patch对象
  13779. var dmp = new diff_match_patch();
  13780. // 计算差异
  13781. List<Diff> diffs = dmp.diff_main(original, changed);
  13782. // 清理和合并差异
  13783. dmp.diff_cleanupSemantic(diffs);
  13784. // 使用StringBuilder构建最终的字符串
  13785. var finalString = new StringBuilder();
  13786. // 输出差异结果,并构建变动后的字符串
  13787. foreach (Diff diff in diffs)
  13788. {
  13789. switch (diff.operation)
  13790. {
  13791. case Operation.EQUAL:
  13792. // 相等的部分,直接添加到最终字符串
  13793. finalString.Append(diff.text);
  13794. break;
  13795. case Operation.INSERT:
  13796. // 插入的部分,添加标记并添加到最终字符串
  13797. finalString.Append("[++]" + diff.text + "[++]");
  13798. break;
  13799. case Operation.DELETE:
  13800. // 删除的部分,不添加到最终字符串
  13801. //finalString.Append("[++]" + diff.text + "[++]");
  13802. break;
  13803. }
  13804. }
  13805. // 输出变动后的字符串
  13806. return finalString.ToString();
  13807. }
  13808. private class tagContent
  13809. {
  13810. public DateTime Date { get; set; }
  13811. public string StartTag { get; set; }
  13812. public string EndTag { get; set; }
  13813. public string Content { get; set; }
  13814. public static int tagLength { get { return 3; } }
  13815. public static Tuple<string, string> TagFormat { get { return new Tuple<string, string>("【#", "#】"); } }
  13816. public string QueryTag { get { return this.StartTag + this.EndTag; } }
  13817. public bool IsFinally { get; set; }
  13818. }
  13819. private static List<string> ExtractContentBetweenTags(string input, string tag)
  13820. {
  13821. var results = new List<string>();
  13822. // 构造正则表达式,匹配形如 [++]内容[++] 的部分
  13823. string pattern = $@"{Regex.Escape(tag)}(.*?){Regex.Escape(tag)}";
  13824. // 添加 RegexOptions.Singleline 选项使 . 匹配包括换行符在内的所有字符
  13825. MatchCollection matches = Regex.Matches(input, pattern, RegexOptions.Singleline);
  13826. string[] strValueArr = new string[1];
  13827. foreach (System.Text.RegularExpressions.Match match in matches)
  13828. {
  13829. var strValue = match.Groups[1].Value;
  13830. strValueArr = Regex.Split(strValue, @"\r\n|\n");
  13831. }
  13832. results.AddRange(strValueArr.Where(x => !string.IsNullOrWhiteSpace(x)));
  13833. return results;
  13834. }
  13835. /// <summary>
  13836. /// 导出行程单
  13837. /// </summary>
  13838. /// <param name="dto"></param>
  13839. /// <returns></returns>
  13840. [HttpPost]
  13841. public IActionResult ExportTravel(ExportTravelDto dto)
  13842. {
  13843. var jw = JsonView(false);
  13844. jw.Data = "";
  13845. int diid = 0;
  13846. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  13847. if (Find == null)
  13848. {
  13849. jw.Msg = "请选择正确的团组!";
  13850. return Ok(jw);
  13851. }
  13852. else
  13853. {
  13854. diid = Find.Id;
  13855. }
  13856. //数据源
  13857. var _travelList = new List<Grp_TravelList>();
  13858. DataTable dtBlack = null;
  13859. try
  13860. {
  13861. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  13862. }
  13863. catch (Exception)
  13864. {
  13865. jw.Msg = "机票黑屏代码有误!";
  13866. return Ok(jw);
  13867. }
  13868. string CityStr = string.Empty;
  13869. if (dtBlack.Rows.Count == 0)
  13870. {
  13871. jw.Msg = "机票黑屏代码有误!";
  13872. return Ok(jw);
  13873. }
  13874. else
  13875. {
  13876. foreach (DataRow row in dtBlack.Rows)
  13877. {
  13878. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  13879. {
  13880. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  13881. return Ok(jw);
  13882. }
  13883. }
  13884. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  13885. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  13886. }
  13887. // 指定的文字
  13888. var targetTextDic = new Dictionary<string, List<string>>();
  13889. //创建数据源Table
  13890. var dtSource = new DataTable();
  13891. dtSource.Columns.Add("Days", typeof(string));
  13892. dtSource.Columns.Add("Date", typeof(string));
  13893. dtSource.Columns.Add("Week", typeof(string));
  13894. dtSource.Columns.Add("Traffic", typeof(string));
  13895. dtSource.Columns.Add("Trip", typeof(string));
  13896. //获取数据,放到datatable
  13897. foreach (var item in _travelList)
  13898. {
  13899. targetTextDic.Add(item.Date, ExtractContentBetweenTags(item.Trip, "[++]"));
  13900. item.Trip = item.Trip.Replace(tagContent.TagFormat.Item1, string.Empty)
  13901. .Replace(tagContent.TagFormat.Item2, string.Empty)
  13902. .Replace("[++]", string.Empty);
  13903. DataRow dr = dtSource.NewRow();
  13904. dr["Days"] = item.Days;
  13905. dr["Date"] = item.Date;
  13906. dr["Week"] = item.WeekDay;
  13907. dr["Traffic"] = item.Traffic_First
  13908. + "\r\n"
  13909. + item.Traffic_Second;
  13910. dr["Trip"] = item.Trip;
  13911. dtSource.Rows.Add(dr);
  13912. }
  13913. var dic = new Dictionary<string, string>
  13914. {
  13915. { "Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()) },
  13916. { "City", CityStr },
  13917. { "Days", Find.VisitDays.ToString() },
  13918. { "DeleCode", Find.TourCode },
  13919. { "Pnum", Find.VisitPNumber.ToString() }
  13920. };
  13921. //模板路径
  13922. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  13923. //载入模板
  13924. Document doc = null;
  13925. DocumentBuilder builder = null;
  13926. try
  13927. {
  13928. //载入模板
  13929. doc = new Document(tempPath);
  13930. builder = new DocumentBuilder(doc);
  13931. }
  13932. catch (Exception)
  13933. {
  13934. jw.Msg = "模板位置不存在!";
  13935. return Ok(jw);
  13936. }
  13937. foreach (var key in dic.Keys)
  13938. {
  13939. Bookmark bookmark = doc.Range.Bookmarks[key];
  13940. if (bookmark != null)
  13941. {
  13942. builder.MoveToBookmark(key);
  13943. builder.Write(dic[key]);
  13944. }
  13945. }
  13946. //获取word里所有表格
  13947. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  13948. //获取所填表格的序数
  13949. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  13950. try
  13951. {
  13952. //循环赋值
  13953. for (int i = 0; i < dtSource.Rows.Count; i++)
  13954. {
  13955. builder.MoveToCell(0, i + 1, 0, 0);
  13956. builder.Write(dtSource.Rows[i]["Days"].ToString());
  13957. builder.MoveToCell(0, i + 1, 1, 0);
  13958. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  13959. builder.MoveToCell(0, i + 1, 2, 0);
  13960. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  13961. var trip = dtSource.Rows[i]["Trip"].ToString();
  13962. builder.MoveToCell(0, i + 1, 3, 0);
  13963. builder.Write(trip);
  13964. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  13965. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  13966. // 获取特定索引的段落
  13967. Paragraph paragraph = (Paragraph)paragraphs[0];
  13968. Run run = paragraph.Runs[0];
  13969. Aspose.Words.Font font = run.Font;
  13970. font.Name = "黑体";
  13971. //设置双休红色
  13972. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  13973. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  13974. paragraph = (Paragraph)paragraphs[1];
  13975. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  13976. {
  13977. run = paragraph.Runs[0];
  13978. font = run.Font;
  13979. font.Color = Color.Red;
  13980. }
  13981. }
  13982. }
  13983. catch (Exception ex)
  13984. {
  13985. }
  13986. //删除多余行
  13987. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  13988. {
  13989. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  13990. }
  13991. var targetTextList = new List<string>();
  13992. // 遍历文档中的表格
  13993. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  13994. {
  13995. foreach (Aspose.Words.Tables.Row row in table.Rows)
  13996. {
  13997. var cellIndex = 0;
  13998. foreach (Cell cell in row.Cells)
  13999. {
  14000. if (cellIndex == 1 && row.Cells.Count == 4)
  14001. {
  14002. foreach (var target in targetTextDic.Keys)
  14003. {
  14004. if (cell.GetText().Contains(target))
  14005. {
  14006. targetTextList = targetTextDic[target];
  14007. break;
  14008. }
  14009. }
  14010. }
  14011. // 遍历单元格中的所有段落
  14012. foreach (Paragraph paragraph in cell.Paragraphs)
  14013. {
  14014. // 使用临时列表存储原始 Runs,避免修改时影响遍历
  14015. var runs = new List<Run>();
  14016. foreach (Run run in paragraph.Runs)
  14017. {
  14018. runs.Add(run);
  14019. }
  14020. foreach (Run run in runs)
  14021. {
  14022. foreach (var targetText in targetTextList)
  14023. {
  14024. // 检查文字是否包含指定文字
  14025. if (run.Text.Contains(targetText))
  14026. {
  14027. // 将包含的部分设置为红色
  14028. HighlightText(run, targetText, Color.Red);
  14029. }
  14030. }
  14031. }
  14032. }
  14033. cellIndex++;
  14034. }
  14035. }
  14036. }
  14037. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  14038. if (!Directory.Exists(savePath))
  14039. {
  14040. try
  14041. {
  14042. Directory.CreateDirectory(savePath);
  14043. }
  14044. catch
  14045. {
  14046. }
  14047. }
  14048. string path = savePath + Find.TeamName + "出访日程";
  14049. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  14050. try
  14051. {
  14052. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  14053. string postfix = ".docx";
  14054. if (dto.IsPDF == 1)
  14055. {
  14056. saveFormat = Aspose.Words.SaveFormat.Pdf;
  14057. postfix = ".pdf";
  14058. }
  14059. doc.Save(path + postfix, saveFormat);
  14060. jw = JsonView(true, "导出成功", ftpPath + postfix);
  14061. }
  14062. catch (Exception)
  14063. {
  14064. jw = JsonView(false);
  14065. }
  14066. return Ok(jw);
  14067. }
  14068. /// <summary>
  14069. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  14070. /// </summary>
  14071. /// <param name="num"></param>
  14072. /// <returns></returns>
  14073. static string GetNum(string num)
  14074. {
  14075. string str = "";
  14076. switch (num)
  14077. {
  14078. case "1":
  14079. str = "一";
  14080. break;
  14081. case "2":
  14082. str = "二";
  14083. break;
  14084. case "3":
  14085. str = "三";
  14086. break;
  14087. case "4":
  14088. str = "四";
  14089. break;
  14090. case "5":
  14091. str = "五";
  14092. break;
  14093. case "6":
  14094. str = "六";
  14095. break;
  14096. case "7":
  14097. str = "七";
  14098. break;
  14099. case "8":
  14100. str = "八";
  14101. break;
  14102. case "9":
  14103. str = "九";
  14104. break;
  14105. case "10":
  14106. str = "十";
  14107. break;
  14108. case "11":
  14109. str = "十一";
  14110. break;
  14111. case "12":
  14112. str = "十二";
  14113. break;
  14114. case "一":
  14115. str = "1";
  14116. break;
  14117. case "二":
  14118. str = "2";
  14119. break;
  14120. case "三":
  14121. str = "3";
  14122. break;
  14123. case "四":
  14124. str = "4";
  14125. break;
  14126. case "五":
  14127. str = "5";
  14128. break;
  14129. case "六":
  14130. str = "6";
  14131. break;
  14132. case "七":
  14133. str = "7";
  14134. break;
  14135. case "八":
  14136. str = "8";
  14137. break;
  14138. case "九":
  14139. str = "9";
  14140. break;
  14141. case "十":
  14142. str = "10";
  14143. break;
  14144. case "十一":
  14145. str = "11";
  14146. break;
  14147. case "十二":
  14148. str = "12";
  14149. break;
  14150. }
  14151. return str;
  14152. }
  14153. /// <summary>
  14154. /// 高亮包含指定文字的部分
  14155. /// </summary>
  14156. /// <param name="run"></param>
  14157. /// <param name="targetText"></param>
  14158. /// <param name="color"></param>
  14159. static void HighlightText(Run run, string targetText, Color color)
  14160. {
  14161. string text = run.Text;
  14162. int startIndex = text.IndexOf(targetText, StringComparison.Ordinal);
  14163. if (startIndex >= 0)
  14164. {
  14165. Paragraph parentParagraph = (Paragraph)run.ParentNode;
  14166. // 前部分
  14167. if (startIndex > 0)
  14168. {
  14169. Run beforeRun = (Run)run.Clone(true);
  14170. beforeRun.Text = text.Substring(0, startIndex);
  14171. parentParagraph.InsertBefore(beforeRun, run);
  14172. }
  14173. // 匹配部分
  14174. Run matchRun = (Run)run.Clone(true);
  14175. matchRun.Text = text.Substring(startIndex, targetText.Length);
  14176. matchRun.Font.Color = color;
  14177. parentParagraph.InsertBefore(matchRun, run);
  14178. // 后部分
  14179. if (startIndex + targetText.Length < text.Length)
  14180. {
  14181. Run afterRun = (Run)run.Clone(true);
  14182. afterRun.Text = text.Substring(startIndex + targetText.Length);
  14183. parentParagraph.InsertBefore(afterRun, run);
  14184. }
  14185. // 删除原始Run
  14186. run.Remove();
  14187. }
  14188. }
  14189. #endregion
  14190. #endregion
  14191. #region 团组成本
  14192. /// <summary>
  14193. /// 团组成本数据初始化
  14194. /// </summary>
  14195. /// <param name="dto"></param>
  14196. /// <returns></returns>
  14197. [HttpPost]
  14198. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  14199. {
  14200. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  14201. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  14202. WHEN COUNT(*) >= 0 THEN 'True'
  14203. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  14204. Where TeamName != '' And IsDel = 0 Order By a.VisitStartDate Desc
  14205. ").ToList(); //团组列表
  14206. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  14207. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  14208. var visaCountryInfoArr = new List<Res_CountryFeeCost>();
  14209. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  14210. if (groupinfoValue != null)
  14211. {
  14212. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  14213. var spArr = new string[1] { countryArr };
  14214. if (countryArr.Contains("|"))
  14215. {
  14216. spArr = countryArr.Split("|");
  14217. }
  14218. else if (countryArr.Contains("、"))
  14219. {
  14220. spArr = countryArr.Split("、");
  14221. }
  14222. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  14223. {
  14224. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  14225. if (dbQueryCountry != null)
  14226. {
  14227. visaCountryInfoArr.Add(dbQueryCountry);
  14228. }
  14229. }
  14230. }
  14231. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  14232. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  14233. #region 屏蔽黑屏代码生成
  14234. //var create = _GroupCostRepository.
  14235. // CreateGroupCostByBlackCode(dto.Diid);
  14236. //if (groupCost.Count == 0 && create.Code == 0)
  14237. //{
  14238. // groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  14239. //}
  14240. #endregion
  14241. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  14242. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  14243. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  14244. groupCostMap = groupCostMap.Select(x =>
  14245. {
  14246. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  14247. {
  14248. x.Date = dataForamt.ToString("yyyy-MM-dd");
  14249. }
  14250. return x;
  14251. }).ToList();
  14252. //GroupCostParameter.Add(new
  14253. // Grp_GroupCostParameter());
  14254. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  14255. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == diid && x.IsDel == 0).Count() > 0;
  14256. var groupModuleOperators = GeneralMethod.GetGroupModuleOperators(diid);
  14257. return Ok(JsonView(new
  14258. {
  14259. groupList,
  14260. groupInfo,
  14261. groupChecks,
  14262. groupCost = groupCostMap,
  14263. hotelNumber,
  14264. GroupCostParameter = GroupCostParameterMap,
  14265. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  14266. {
  14267. x.VisaCountry,
  14268. x.VisaPrice,
  14269. x.Id,
  14270. IsVisaExemption = x.IsVisaExemption == 1 ? "否" : "是", //免签
  14271. IsElectronicSignature = x.IsElectronicSignature == 1 ? "否" : "是", //电子签
  14272. IsVisaOnArrival = x.IsVisaOnArrival == 1 ? "否" : "是", //落地签
  14273. x.VisaTime, // 一般签证时间
  14274. x.PettyBusinessAgencyFee, //小公务代办费
  14275. x.GrandBusinessAgencyFee //大公务代办费
  14276. }).ToList(),
  14277. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  14278. blackCodeIsTrue = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).Any(), //create.Code == 0 ? true : false,
  14279. hotelIsTrue,
  14280. groupModuleOperators
  14281. }));
  14282. }
  14283. /// <summary>
  14284. /// 团组成本信息保存
  14285. /// </summary>
  14286. /// <param name="dto"></param>
  14287. /// <returns></returns>
  14288. [HttpPost]
  14289. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  14290. {
  14291. if (dto.Diid <= 0 || dto.Userid <= 0)
  14292. {
  14293. return Ok(JsonView(false));
  14294. }
  14295. JsonView jw = null;
  14296. bool isTrue = false;
  14297. #region 复制团组成本
  14298. //if (dto.Diid == 2581)
  14299. //{
  14300. // dto.Diid = 2599;
  14301. // dto.CheckBoxs.ForEach(x =>
  14302. // {
  14303. // x.Diid = 2599;
  14304. // });
  14305. // dto.GroupCosts.ForEach(x =>
  14306. // {
  14307. // x.Diid = 2599;
  14308. // });
  14309. // dto.CostTypeHotelNumbers.ForEach(x =>
  14310. // {
  14311. // x.Diid = 2599;
  14312. // });
  14313. // dto.GroupCostParameters.ForEach(x =>
  14314. // {
  14315. // x.DiId = 2599;
  14316. // });
  14317. //}
  14318. #endregion
  14319. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  14320. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  14321. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  14322. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  14323. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  14324. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  14325. try
  14326. {
  14327. _sqlSugar.BeginTran();
  14328. isTrue = await _GroupCostRepository.
  14329. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  14330. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  14331. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  14332. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  14333. _sqlSugar.CommitTran();
  14334. jw = JsonView(true, "保存成功!", isTrue);
  14335. }
  14336. catch (Exception)
  14337. {
  14338. _sqlSugar.RollbackTran();
  14339. jw = JsonView(false);
  14340. }
  14341. return Ok(jw);
  14342. }
  14343. /// <summary>
  14344. /// 复制团组成本信息
  14345. /// </summary>
  14346. /// <param name="dto"></param>
  14347. /// <returns></returns>
  14348. [HttpPost]
  14349. public async Task<IActionResult> CopyGroupCost(CopyGroupCostDto dto)
  14350. {
  14351. if (dto.Diid <= 0 || dto.Userid <= 0 || dto.ToGroupId <= 0)
  14352. {
  14353. return Ok(JsonView(false, "参数有误!"));
  14354. }
  14355. #region 复制团组成本
  14356. dto.Diid = dto.ToGroupId;
  14357. dto.CheckBoxs.ForEach(x =>
  14358. {
  14359. x.Diid = dto.ToGroupId;
  14360. });
  14361. dto.GroupCosts.ForEach(x =>
  14362. {
  14363. x.Diid = dto.ToGroupId;
  14364. });
  14365. dto.CostTypeHotelNumbers.ForEach(x =>
  14366. {
  14367. x.Diid = dto.ToGroupId;
  14368. });
  14369. dto.GroupCostParameters.ForEach(x =>
  14370. {
  14371. x.DiId = dto.ToGroupId;
  14372. });
  14373. #endregion
  14374. JsonView jw = null;
  14375. bool isTrue = false;
  14376. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  14377. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  14378. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  14379. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  14380. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  14381. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  14382. try
  14383. {
  14384. _sqlSugar.BeginTran();
  14385. isTrue = await _GroupCostRepository.
  14386. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  14387. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  14388. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  14389. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  14390. _sqlSugar.CommitTran();
  14391. jw = JsonView(true, "保存成功!", isTrue);
  14392. }
  14393. catch (Exception)
  14394. {
  14395. _sqlSugar.RollbackTran();
  14396. jw = JsonView(false);
  14397. }
  14398. return Ok(jw);
  14399. }
  14400. /// <summary>
  14401. /// 司兼导数据
  14402. /// </summary>
  14403. /// <param name="dto"></param>
  14404. /// <returns></returns>
  14405. [HttpPost]
  14406. public IActionResult GetCarGuides(CarGuidesDto dto)
  14407. {
  14408. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  14409. return Ok(JsonView(true, "获取成功!", Data));
  14410. }
  14411. /// <summary>
  14412. /// 导游数据
  14413. /// </summary>
  14414. /// <param name="dto"></param>
  14415. /// <returns></returns>
  14416. [HttpPost]
  14417. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  14418. {
  14419. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  14420. // 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
  14421. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  14422. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  14423. return Ok(JsonView(true, "获取成功!", Data));
  14424. }
  14425. /// <summary>
  14426. /// 成本车数据
  14427. /// </summary>
  14428. /// <param name="dto"></param>
  14429. /// <returns></returns>
  14430. [HttpPost]
  14431. public IActionResult GetCarInfo(CarGuidesDto dto)
  14432. {
  14433. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  14434. return Ok(JsonView(true, "获取成功!", Data));
  14435. }
  14436. /// <summary>
  14437. /// 景点数据
  14438. /// </summary>
  14439. /// <param name="dto"></param>
  14440. /// <returns></returns>
  14441. [HttpPost]
  14442. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  14443. {
  14444. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  14445. return Ok(JsonView(true, "获取成功!", Data));
  14446. }
  14447. /// <summary>
  14448. /// 成本通知
  14449. /// </summary>
  14450. /// <param name="dto"></param>
  14451. /// <returns></returns>
  14452. [HttpPost]
  14453. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  14454. {
  14455. if (dto.Diid < 0)
  14456. {
  14457. return Ok(JsonView(false));
  14458. }
  14459. JsonView jw;
  14460. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  14461. if (GroupCostParameter != null)
  14462. {
  14463. int IsShare = 0;
  14464. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  14465. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  14466. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  14467. string msg = string.Empty;
  14468. if (isTrue)
  14469. {
  14470. if (IsShare == 0)
  14471. {
  14472. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  14473. }
  14474. else
  14475. {
  14476. #region 企微通知对应岗位用户
  14477. try
  14478. {
  14479. await AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  14480. }
  14481. catch (Exception)
  14482. {
  14483. }
  14484. #endregion
  14485. msg = "通知成功,其他模块操作人员可见此成本信息!";
  14486. }
  14487. jw = JsonView(isTrue, msg, new { IsShare });
  14488. }
  14489. else
  14490. {
  14491. msg = "修改失败!";
  14492. jw = JsonView(isTrue, msg);
  14493. }
  14494. }
  14495. else
  14496. {
  14497. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  14498. }
  14499. return Ok(jw);
  14500. }
  14501. /// <summary>
  14502. /// 导出报价单
  14503. /// </summary>
  14504. /// <param name="dto"></param>
  14505. /// <returns></returns>
  14506. [HttpPost]
  14507. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  14508. {
  14509. if (dto.Diid == 0)
  14510. {
  14511. return Ok(JsonView(false, "请传递团组id"));
  14512. }
  14513. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  14514. if (deleInfo.Code != 0)
  14515. {
  14516. return Ok(JsonView(false, "团组信息查询失败!"));
  14517. }
  14518. var di = deleInfo.Data as DelegationInfoWebView;
  14519. if (di != null)
  14520. {
  14521. di.TeamName = di.TeamName.Replace("|", "、");
  14522. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  14523. //文件名
  14524. string strFileName = di.TeamName + "-收款账单.doc";
  14525. //获取模板
  14526. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  14527. //载入模板
  14528. Document doc = new Document(tmppath);
  14529. decimal TotalPrice = 0.00M;
  14530. string itemStr = string.Empty;
  14531. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  14532. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  14533. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  14534. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  14535. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  14536. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  14537. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  14538. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  14539. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  14540. foreach (var cost in groupCostType)
  14541. {
  14542. var List = cost.ToList();
  14543. if (cost.Key == "A")
  14544. {
  14545. foreach (var ListItem in List)
  14546. {
  14547. if (ListItem.number > 0)
  14548. {
  14549. if (ListItem.code.Contains("TBR"))
  14550. {
  14551. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14552. }
  14553. else
  14554. {
  14555. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14556. }
  14557. TotalPrice += (ListItem.number * ListItem.price);
  14558. }
  14559. }
  14560. }
  14561. else
  14562. {
  14563. itemStr = itemStr.Insert(0, "A段\r\n");
  14564. itemStr += "B段\r\n";
  14565. foreach (var ListItem in List)
  14566. {
  14567. if (ListItem.number > 0)
  14568. {
  14569. if (ListItem.code.Contains("TBR"))
  14570. {
  14571. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14572. }
  14573. else
  14574. {
  14575. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14576. }
  14577. TotalPrice += (ListItem.number * ListItem.price);
  14578. }
  14579. }
  14580. }
  14581. }
  14582. #region 替换Word模板书签内容
  14583. Dictionary<string, string> marks = new Dictionary<string, string>();
  14584. marks.Add("To", di.ClientUnit);//付款方
  14585. marks.Add("ToTel", di.TellPhone);//付款方电话
  14586. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  14587. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  14588. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  14589. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  14590. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  14591. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  14592. marks.Add("PayItemContent", itemStr);//详细信息
  14593. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  14594. #endregion
  14595. ////注
  14596. //if (doc.Range.Bookmarks["Attention"] != null)
  14597. //{
  14598. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  14599. // mark.Text = frList[0].Attention;
  14600. //}
  14601. foreach (var item in marks.Keys)
  14602. {
  14603. if (doc.Range.Bookmarks[item] != null)
  14604. {
  14605. Bookmark mark = doc.Range.Bookmarks[item];
  14606. mark.Text = marks[item];
  14607. }
  14608. }
  14609. byte[] bytes = null;
  14610. using (MemoryStream stream = new MemoryStream())
  14611. {
  14612. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  14613. bytes = stream.ToArray();
  14614. }
  14615. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  14616. return Ok(JsonView(true, "", new
  14617. {
  14618. Data = bytes,
  14619. strFileName,
  14620. }));
  14621. }
  14622. else
  14623. {
  14624. return Ok(JsonView(false, "团组信息不存在!"));
  14625. }
  14626. }
  14627. /// <summary>
  14628. /// 导出团组成本
  14629. /// </summary>
  14630. /// <param name="dto"></param>
  14631. /// <returns></returns>
  14632. [HttpPost]
  14633. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  14634. {
  14635. var jw = JsonView(false);
  14636. if (dto.Diid == 0)
  14637. {
  14638. return Ok(JsonView(false, "请传递团组id"));
  14639. }
  14640. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  14641. if (deleInfo.Code != 0)
  14642. {
  14643. return Ok(JsonView(false, "团组信息查询失败!"));
  14644. }
  14645. var di = deleInfo.Data as DelegationInfoWebView;
  14646. if (di == null)
  14647. {
  14648. return Ok(JsonView(false, "团组信息查询失败!"));
  14649. }
  14650. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  14651. WorkbookDesigner designer = new WorkbookDesigner();
  14652. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  14653. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  14654. List<int> hideColumnList = new List<int>();
  14655. var ColumnSetting = new[]
  14656. {
  14657. new { tag = "VF", Index = 4, P = "CarCost" },
  14658. new { tag = "VN", Index = 5, P = "CarNumber" },
  14659. new { tag = "VRD", Index = 6, P = "CarTiming" },
  14660. new { tag = "T/G S", Index = 7, P = "TGS" },
  14661. new { tag = "TGWH", Index = 8, P = "TGWH" },
  14662. new { tag = "T/G OF", Index = 9, P = "TGOF" },
  14663. new { tag = "T/G M", Index = 10, P = "TGM" },
  14664. new { tag = "T/G A", Index = 11, P = "TGA" },
  14665. new { tag = "T/G TF", Index = 12, P = "TGTF" },
  14666. new { tag = "T/G EF", Index = 13, P = "TGEF" },
  14667. new { tag = "C/F S", Index = 14, P = "CFS" },
  14668. new { tag = "C/F M", Index = 15, P = "CFM" },
  14669. new { tag = "C/F OF", Index = 16, P = "CFOF" },
  14670. new { tag = "B", Index = 17, P = "B" },
  14671. new { tag = "L", Index = 18, P = "L" },
  14672. new { tag = "D", Index = 19, P = "D" },
  14673. new { tag = "TBR", Index = 20, P = "TBR" },
  14674. new { tag = "SGR", Index = 21, P = "SGR" },
  14675. new { tag = "JS/ES", Index = 22, P = "JS_ES" },
  14676. new { tag = "Suite", Index = 23, P = "Suite" },
  14677. new { tag = "ACCO N", Index = 24, P = "ACCON" },
  14678. new { tag = "T/V", Index = 25, P = "TV" },
  14679. new { tag = "1/L", Index = 26, P = "iL" },
  14680. new { tag = "I/F", Index = 27, P = "IF" },
  14681. new { tag = "EF", Index = 28, P = "EF" },
  14682. new { tag = "B/R/F", Index = 29, P = "B_R_F" },
  14683. new { tag = "TE", Index = 30, P = "TE" },
  14684. new { tag = "T/G T", Index = 31, P = "TGTips" },
  14685. new { tag = "DRV T", Index = 32, P = "DRVTips" },
  14686. new { tag = "P/C", Index = 33, P = "PC" },
  14687. new { tag = "T/L F", Index = 34, P = "TLF" },
  14688. new { tag = "E/C T", Index = 35, P = "ECT" }
  14689. };
  14690. Func<string, bool> isEmpty = (str) =>
  14691. {
  14692. if (decimal.TryParse(str, out decimal str_De) && str_De == 0)
  14693. {
  14694. return true;
  14695. }
  14696. if (string.IsNullOrWhiteSpace(str))
  14697. {
  14698. return true;
  14699. }
  14700. return false;
  14701. };
  14702. for (int i = 0; i < List_GC.Count; i++)
  14703. {
  14704. GroupCost_Excel gc = new GroupCost_Excel();
  14705. gc.Id = List_GC[i].Id;
  14706. gc.Diid = List_GC[i].Diid.ToString();
  14707. gc.DAY = List_GC[i].DAY;
  14708. string week = "";
  14709. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  14710. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  14711. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  14712. gc.ITIN = List_GC[i].ITIN;
  14713. gc.CarType = List_GC[i].CarType;
  14714. gc.CarTiming = isEmpty(List_GC[i].CarTiming.ToString()) ? "" : List_GC[i].CarTiming.ToString();
  14715. gc.CarCost = isEmpty(List_GC[i].CarCost.ToString()) ? "" : List_GC[i].CarCost.ToString();
  14716. gc.CarNumber = isEmpty(List_GC[i].CarNumber.ToString()) ? "" : List_GC[i].CarNumber.ToString();
  14717. gc.TGS = isEmpty(List_GC[i].TGS.ToString()) ? "" : List_GC[i].TGS.ToString();
  14718. gc.TGWH = isEmpty(List_GC[i].TGWH.ToString()) ? "" : List_GC[i].TGWH.ToString();
  14719. gc.TGN = isEmpty(List_GC[i].TGN.ToString()) ? "" : List_GC[i].TGN.ToString();
  14720. gc.TGOF = isEmpty(List_GC[i].TGOF.ToString()) ? "" : List_GC[i].TGOF.ToString();
  14721. gc.TGM = isEmpty(List_GC[i].TGM.ToString()) ? "" : List_GC[i].TGM.ToString();
  14722. gc.TGA = isEmpty(List_GC[i].TGA.ToString()) ? "" : List_GC[i].TGA.ToString();
  14723. gc.TGTF = isEmpty(List_GC[i].TGTF.ToString()) ? "" : List_GC[i].TGTF.ToString();
  14724. gc.TGEF = isEmpty(List_GC[i].TGEF.ToString()) ? "" : List_GC[i].TGEF.ToString();
  14725. gc.CFS = isEmpty(List_GC[i].CFS.ToString()) ? "" : List_GC[i].CFS.ToString();
  14726. gc.CFM = isEmpty(List_GC[i].CFM.ToString()) ? "" : List_GC[i].CFM.ToString();
  14727. gc.CFOF = isEmpty(List_GC[i].CFOF.ToString()) ? "" : List_GC[i].CFOF.ToString();
  14728. gc.B = isEmpty(List_GC[i].B.ToString()) ? "" : List_GC[i].B.ToString();
  14729. gc.L = isEmpty(List_GC[i].L.ToString()) ? "" : List_GC[i].L.ToString();
  14730. gc.D = isEmpty(List_GC[i].D.ToString()) ? "" : List_GC[i].D.ToString();
  14731. gc.TBR = isEmpty(List_GC[i].TBR.ToString()) ? "" : List_GC[i].TBR.ToString();
  14732. gc.SGR = isEmpty(List_GC[i].SGR.ToString()) ? "" : List_GC[i].SGR.ToString();
  14733. gc.JS_ES = isEmpty(List_GC[i].JS_ES.ToString()) ? "" : List_GC[i].JS_ES.ToString();
  14734. gc.Suite = isEmpty(List_GC[i].Suite.ToString()) ? "" : List_GC[i].Suite.ToString();
  14735. gc.ACCON = isEmpty(List_GC[i].ACCON.ToString()) ? "" : List_GC[i].ACCON.ToString();
  14736. gc.TV = isEmpty(List_GC[i].TV.ToString()) ? "" : List_GC[i].TV.ToString();
  14737. gc.iL = isEmpty(List_GC[i].iL.ToString()) ? "" : List_GC[i].iL.ToString();
  14738. gc.IF = isEmpty(List_GC[i].IF.ToString()) ? "" : List_GC[i].IF.ToString();
  14739. gc.EF = isEmpty(List_GC[i].EF.ToString()) ? "" : List_GC[i].EF.ToString();
  14740. gc.B_R_F = isEmpty(List_GC[i].B_R_F.ToString()) ? "" : List_GC[i].B_R_F.ToString();
  14741. gc.TE = isEmpty(List_GC[i].TE.ToString()) ? "" : List_GC[i].TE.ToString();
  14742. gc.TGTips = isEmpty(List_GC[i].TGTips.ToString()) ? "" : List_GC[i].TGTips.ToString();
  14743. gc.DRVTips = isEmpty(List_GC[i].DRVTips.ToString()) ? "" : List_GC[i].DRVTips.ToString();
  14744. gc.PC = isEmpty(List_GC[i].PC.ToString()) ? "" : List_GC[i].PC.ToString();
  14745. gc.TLF = isEmpty(List_GC[i].TLF.ToString()) ? "" : List_GC[i].TLF.ToString();
  14746. gc.ECT = isEmpty(List_GC[i].ECT.ToString()) ? "" : List_GC[i].ECT.ToString();
  14747. gc.EFR = List_GC[i].EFR;
  14748. List_GC1.Add(gc);
  14749. }
  14750. if (List_GC1.Count > 0)
  14751. {
  14752. var p = List_GC1[0];
  14753. var prs = p.GetType().GetProperties();
  14754. foreach (var item in prs)
  14755. {
  14756. var tp = item.PropertyType;
  14757. if (tp == typeof(int))
  14758. {
  14759. var val = List_GC1.Sum(x => (int)x.GetType().GetProperty(item.Name).GetValue(x));
  14760. if (val == 0)
  14761. {
  14762. var columnSetting = ColumnSetting.FirstOrDefault(x => x.P == item.Name);
  14763. if (columnSetting != null)
  14764. {
  14765. hideColumnList.Add(columnSetting.Index);
  14766. }
  14767. }
  14768. }
  14769. if (tp == typeof(decimal))
  14770. {
  14771. var val = List_GC1.Sum(x => (decimal)x.GetType().GetProperty(item.Name).GetValue(x));
  14772. if (val == 0)
  14773. {
  14774. var columnSetting = ColumnSetting.FirstOrDefault(x => x.P == item.Name);
  14775. if (columnSetting != null)
  14776. {
  14777. hideColumnList.Add(columnSetting.Index);
  14778. }
  14779. }
  14780. }
  14781. if (tp == typeof(string))
  14782. {
  14783. var val = List_GC1.Sum(x =>
  14784. {
  14785. var str = (string)x.GetType().GetProperty(item.Name).GetValue(x);
  14786. if (decimal.TryParse(str, out decimal str_De))
  14787. {
  14788. return str_De;
  14789. }
  14790. else
  14791. {
  14792. return string.IsNullOrEmpty((string)x.GetType().GetProperty(item.Name).GetValue(x)) ? 0 : 1;
  14793. }
  14794. });
  14795. if (val == 0)
  14796. {
  14797. var columnSetting = ColumnSetting.FirstOrDefault(x => x.P == item.Name);
  14798. if (columnSetting != null)
  14799. {
  14800. hideColumnList.Add(columnSetting.Index);
  14801. }
  14802. }
  14803. }
  14804. }
  14805. }
  14806. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  14807. dt.TableName = "TB";
  14808. //报表标题等不用dt的值
  14809. designer.SetDataSource("TeamName", dto.title.TeamName);
  14810. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  14811. designer.SetDataSource("Tax", dto.title.Tax);
  14812. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  14813. designer.SetDataSource("Currency", dto.title.Currency);
  14814. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  14815. designer.SetDataSource("Rate", dto.title.Rate);
  14816. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  14817. var Aparams = hotels.Find(x => x.Type == "Default");
  14818. if (Aparams == null)
  14819. {
  14820. return Ok(jw);
  14821. }
  14822. //酒店数量
  14823. var txtSGRNumber = Aparams.SGR.ToString();
  14824. var txtTBRNumber = Aparams.TBR.ToString();
  14825. var txtJSESNumber = Aparams.JSES.ToString();
  14826. var txtSUITENumbe = Aparams.SUITE.ToString();
  14827. if (dto.costType == "B")
  14828. {
  14829. Aparams = hotels.Find(x => x.Type == "A");
  14830. var Bparams = hotels.Find(x => x.Type == "B");
  14831. if (Aparams == null || Bparams == null)
  14832. {
  14833. return Ok(jw);
  14834. }
  14835. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  14836. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  14837. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  14838. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  14839. }
  14840. designer.SetDataSource("SGRNumber", txtSGRNumber);
  14841. designer.SetDataSource("TBRNumber", txtTBRNumber);
  14842. designer.SetDataSource("JSESNumber", txtJSESNumber);
  14843. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  14844. var ws = designer.Workbook.Worksheets[1];
  14845. int Row = List_GC.Count;
  14846. int startIndex = 0;
  14847. int HideRows = 0;
  14848. Row = 0;
  14849. List<int> hideRowsList = new List<int>();
  14850. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  14851. #region A段left数据
  14852. var left = dto.leftInfo.Find(x => x.Type == "A");
  14853. if (left == null)
  14854. {
  14855. return Ok(jw);
  14856. }
  14857. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  14858. if (leftBindData != null)
  14859. {
  14860. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  14861. designer.SetDataSource("VisaRS", leftBindData.rs);
  14862. designer.SetDataSource("VisaXS", leftBindData.xs);
  14863. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14864. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14865. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14866. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14867. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14868. }
  14869. else
  14870. {
  14871. hideRowsList.Add(Row + startIndex + HideRows);
  14872. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14873. }
  14874. HideRows += 2;
  14875. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  14876. if (leftBindData != null)
  14877. {
  14878. designer.SetDataSource("BXDRCB", leftBindData.cb);
  14879. designer.SetDataSource("BXRS", leftBindData.rs);
  14880. designer.SetDataSource("BXXS", leftBindData.xs);
  14881. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14882. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14883. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14884. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14885. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14886. }
  14887. else
  14888. {
  14889. hideRowsList.Add(Row + startIndex + HideRows);
  14890. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14891. }
  14892. HideRows += 2;
  14893. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  14894. if (leftBindData != null)
  14895. {
  14896. designer.SetDataSource("HSDRCB", leftBindData.cb);
  14897. designer.SetDataSource("HSRS", leftBindData.rs);
  14898. designer.SetDataSource("HSXS", leftBindData.xs);
  14899. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14900. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14901. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14902. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14903. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14904. }
  14905. else
  14906. {
  14907. hideRowsList.Add(Row + startIndex + HideRows);
  14908. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14909. }
  14910. HideRows += 2;
  14911. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  14912. if (leftBindData != null)
  14913. {
  14914. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  14915. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  14916. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  14917. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14918. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14919. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14920. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14921. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14922. }
  14923. else
  14924. {
  14925. hideRowsList.Add(Row + startIndex + HideRows);
  14926. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14927. }
  14928. HideRows += 2;
  14929. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  14930. if (leftBindData != null)
  14931. {
  14932. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  14933. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  14934. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  14935. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14936. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14937. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14938. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14939. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14940. }
  14941. else
  14942. {
  14943. hideRowsList.Add(Row + startIndex + HideRows);
  14944. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14945. }
  14946. HideRows += 2;
  14947. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  14948. if (leftBindData != null)
  14949. {
  14950. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  14951. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  14952. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  14953. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14954. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14955. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14956. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14957. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14958. }
  14959. else
  14960. {
  14961. hideRowsList.Add(Row + startIndex + HideRows);
  14962. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14963. }
  14964. HideRows += 2;
  14965. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  14966. if (leftBindData != null)
  14967. {
  14968. ////TBR
  14969. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  14970. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  14971. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  14972. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14973. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14974. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14975. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14976. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14977. }
  14978. else
  14979. {
  14980. hideRowsList.Add(Row + startIndex + HideRows);
  14981. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14982. }
  14983. HideRows += 2;
  14984. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  14985. if (leftBindData != null)
  14986. {
  14987. ////SGR
  14988. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  14989. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  14990. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  14991. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14992. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14993. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14994. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14995. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14996. }
  14997. else
  14998. {
  14999. hideRowsList.Add(Row + startIndex + HideRows);
  15000. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15001. }
  15002. HideRows += 2;
  15003. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  15004. if (leftBindData != null)
  15005. {
  15006. ////JS/ES
  15007. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  15008. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  15009. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  15010. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15011. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15012. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15013. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15014. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15015. }
  15016. else
  15017. {
  15018. hideRowsList.Add(Row + startIndex + HideRows);
  15019. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15020. }
  15021. HideRows += 2;
  15022. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  15023. if (leftBindData != null)
  15024. {
  15025. ////SUITE
  15026. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  15027. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  15028. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  15029. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15030. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15031. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15032. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15033. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15034. }
  15035. else
  15036. {
  15037. hideRowsList.Add(Row + startIndex + HideRows);
  15038. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15039. }
  15040. HideRows += 2;
  15041. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  15042. if (leftBindData != null)
  15043. {
  15044. designer.SetDataSource("DJDRCB", leftBindData.cb);
  15045. designer.SetDataSource("DJRS", leftBindData.rs);
  15046. designer.SetDataSource("DJXS", leftBindData.xs);
  15047. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15048. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15049. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15050. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15051. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15052. }
  15053. else
  15054. {
  15055. hideRowsList.Add(Row + startIndex + HideRows);
  15056. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15057. }
  15058. HideRows += 2;
  15059. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  15060. if (leftBindData != null)
  15061. {
  15062. designer.SetDataSource("HCPCB", leftBindData.cb);
  15063. designer.SetDataSource("HCPRS", leftBindData.rs);
  15064. designer.SetDataSource("HCPXS", leftBindData.xs);
  15065. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15066. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15067. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15068. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15069. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15070. }
  15071. else
  15072. {
  15073. hideRowsList.Add(Row + startIndex + HideRows);
  15074. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15075. }
  15076. HideRows += 2;
  15077. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  15078. if (leftBindData != null)
  15079. {
  15080. designer.SetDataSource("CPCB", leftBindData.cb);
  15081. designer.SetDataSource("CPRS", leftBindData.rs);
  15082. designer.SetDataSource("CPXS", leftBindData.xs);
  15083. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15084. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15085. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15086. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15087. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15088. }
  15089. else
  15090. {
  15091. hideRowsList.Add(Row + startIndex + HideRows);
  15092. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15093. }
  15094. HideRows += 2;
  15095. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  15096. if (leftBindData != null)
  15097. {
  15098. designer.SetDataSource("GWDRCD", leftBindData.cb);
  15099. designer.SetDataSource("GWRS", leftBindData.rs);
  15100. designer.SetDataSource("GWXS", leftBindData.xs);
  15101. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15102. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15103. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15104. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15105. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15106. }
  15107. else
  15108. {
  15109. hideRowsList.Add(Row + startIndex + HideRows);
  15110. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15111. }
  15112. HideRows += 2;
  15113. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  15114. if (leftBindData != null)
  15115. {
  15116. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  15117. designer.SetDataSource("LYJRS", leftBindData.rs);
  15118. designer.SetDataSource("LYJXS", leftBindData.xs);
  15119. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15120. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15121. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15122. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15123. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15124. }
  15125. else
  15126. {
  15127. hideRowsList.Add(Row + startIndex + HideRows);
  15128. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15129. }
  15130. #endregion
  15131. #region A段Right信息
  15132. var right = dto.rightInfo.Find(x => x.Type == "A");
  15133. if (right == null)
  15134. {
  15135. return Ok(jw);
  15136. }
  15137. HideRows += 4;
  15138. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  15139. if (rightBindData != null)
  15140. {
  15141. //经济舱 + 双人间 TBR
  15142. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  15143. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  15144. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15145. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  15146. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15147. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15148. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15149. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15150. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15151. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15152. }
  15153. else
  15154. {
  15155. hideRowsList.Add(Row + startIndex + HideRows);
  15156. }
  15157. HideRows += 2;
  15158. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  15159. if (rightBindData != null)
  15160. {
  15161. //经济舱 + 单人间 SGR
  15162. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  15163. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  15164. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15165. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  15166. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15167. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15168. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15169. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15170. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15171. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15172. }
  15173. else
  15174. {
  15175. hideRowsList.Add(Row + startIndex + HideRows);
  15176. }
  15177. HideRows += 2;
  15178. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  15179. if (rightBindData != null)
  15180. {
  15181. //公务舱 + 单人间 SGR
  15182. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  15183. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  15184. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15185. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  15186. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15187. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15188. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15189. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15190. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15191. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15192. }
  15193. else
  15194. {
  15195. hideRowsList.Add(Row + startIndex + HideRows);
  15196. }
  15197. HideRows += 2;
  15198. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  15199. if (rightBindData != null)
  15200. {
  15201. //公务舱 + 小套房 JSES
  15202. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  15203. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  15204. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15205. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  15206. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15207. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15208. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15209. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15210. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15211. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15212. }
  15213. else
  15214. {
  15215. hideRowsList.Add(Row + startIndex + HideRows);
  15216. }
  15217. HideRows += 2;
  15218. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  15219. if (rightBindData != null)
  15220. {
  15221. //公务舱 + 小套房 JSES
  15222. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  15223. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  15224. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15225. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  15226. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15227. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15228. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15229. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15230. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15231. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15232. }
  15233. else
  15234. {
  15235. hideRowsList.Add(Row + startIndex + HideRows);
  15236. }
  15237. HideRows += 2;
  15238. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  15239. if (rightBindData != null)
  15240. {
  15241. //经济舱 + 大套房
  15242. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  15243. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  15244. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15245. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  15246. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15247. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15248. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15249. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15250. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15251. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15252. }
  15253. else
  15254. {
  15255. hideRowsList.Add(Row + startIndex + HideRows);
  15256. }
  15257. HideRows += 2;
  15258. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  15259. if (rightBindData != null)
  15260. {
  15261. //头等舱 + 小套房 JSES
  15262. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  15263. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  15264. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15265. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  15266. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15267. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15268. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15269. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15270. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15271. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15272. }
  15273. else
  15274. {
  15275. hideRowsList.Add(Row + startIndex + HideRows);
  15276. }
  15277. HideRows += 2;
  15278. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  15279. if (rightBindData != null)
  15280. {
  15281. //头等舱 + 大套房
  15282. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  15283. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  15284. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15285. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  15286. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15287. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15288. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15289. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15290. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15291. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15292. }
  15293. else
  15294. {
  15295. hideRowsList.Add(Row + startIndex + HideRows);
  15296. }
  15297. #endregion
  15298. #region B段标题清空
  15299. designer.SetDataSource("CostBDRCB", "");
  15300. designer.SetDataSource("CostBRS", "");
  15301. designer.SetDataSource("CostBXS", "");
  15302. designer.SetDataSource("CostBZCB", "");
  15303. designer.SetDataSource("CostBDRBJ", "");
  15304. designer.SetDataSource("CostBZBJ", "");
  15305. designer.SetDataSource("CostBDRLR", "");
  15306. designer.SetDataSource("CostBZLR", "");
  15307. designer.SetDataSource("CostBDRCBOM", "");
  15308. designer.SetDataSource("CostBRSOM", "");
  15309. designer.SetDataSource("CostBZCBOM", "");
  15310. designer.SetDataSource("CostBDRBJOM", "");
  15311. designer.SetDataSource("CostBZBJOM", "");
  15312. designer.SetDataSource("CostBDRLROM", "");
  15313. designer.SetDataSource("CostBZLROM", "");
  15314. #endregion
  15315. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  15316. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  15317. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  15318. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  15319. designer.SetDataSource("DJName", "地接(CNY)");
  15320. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  15321. designer.SetDataSource("CPName", "地接-船票(CNY)");
  15322. designer.SetDataSource("GWName", "公务(CNY)");
  15323. designer.SetDataSource("YQHName", "邀请函(CNY)");
  15324. designer.SetDataSource("LYJName", "零用金(CNY)");
  15325. designer.SetDataSource("HSName", "核酸检测(CNY)");
  15326. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  15327. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  15328. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  15329. designer.SetDataSource("BXName", "保险(CNY)");
  15330. designer.SetDataSource("VisaName", "签证(CNY)");
  15331. #region B段基本数据
  15332. if (dto.costType == "B")
  15333. {
  15334. left = dto.leftInfo.Find(x => x.Type == "B");
  15335. if (left == null)
  15336. {
  15337. return Ok(jw);
  15338. }
  15339. #region B段left数据
  15340. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  15341. if (leftBindData != null)
  15342. {
  15343. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  15344. designer.SetDataSource("BHSRS", leftBindData.rs);
  15345. designer.SetDataSource("BHSXS", leftBindData.xs);
  15346. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15347. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15348. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15349. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15350. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15351. }
  15352. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  15353. if (leftBindData != null)
  15354. {
  15355. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  15356. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  15357. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  15358. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15359. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15360. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15361. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15362. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15363. }
  15364. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  15365. if (leftBindData != null)
  15366. {
  15367. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  15368. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  15369. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  15370. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15371. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15372. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15373. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15374. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15375. }
  15376. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  15377. if (leftBindData != null)
  15378. {
  15379. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  15380. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  15381. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  15382. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15383. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15384. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15385. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15386. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15387. }
  15388. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  15389. if (leftBindData != null)
  15390. {
  15391. designer.SetDataSource("BHCPCB", leftBindData.cb);
  15392. designer.SetDataSource("BHCPRS", leftBindData.rs);
  15393. designer.SetDataSource("BHCPXS", leftBindData.xs);
  15394. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15395. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15396. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15397. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15398. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15399. }
  15400. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  15401. if (leftBindData != null)
  15402. {
  15403. designer.SetDataSource("BCPCB", leftBindData.cb);
  15404. designer.SetDataSource("BCPRS", leftBindData.rs);
  15405. designer.SetDataSource("BCPXS", leftBindData.xs);
  15406. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15407. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15408. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15409. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15410. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15411. }
  15412. //TBR
  15413. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  15414. if (leftBindData != null)
  15415. {
  15416. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  15417. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  15418. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  15419. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15420. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15421. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15422. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15423. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15424. }
  15425. //SGR
  15426. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  15427. if (leftBindData != null)
  15428. {
  15429. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  15430. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  15431. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  15432. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15433. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15434. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15435. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15436. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15437. }
  15438. //JS/ES
  15439. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  15440. if (leftBindData != null)
  15441. {
  15442. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  15443. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  15444. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  15445. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15446. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15447. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15448. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15449. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15450. }
  15451. //SUITE
  15452. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  15453. if (leftBindData != null)
  15454. {
  15455. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  15456. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  15457. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  15458. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15459. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15460. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15461. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15462. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15463. }
  15464. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  15465. if (leftBindData != null)
  15466. {
  15467. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  15468. designer.SetDataSource("BDJRS", leftBindData.rs);
  15469. designer.SetDataSource("BDJXS", leftBindData.xs);
  15470. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15471. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15472. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15473. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15474. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15475. }
  15476. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  15477. if (leftBindData != null)
  15478. {
  15479. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  15480. designer.SetDataSource("BGWRS", leftBindData.rs);
  15481. designer.SetDataSource("BGWXS", leftBindData.xs);
  15482. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15483. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15484. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15485. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15486. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15487. }
  15488. #region 优化方案
  15489. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  15490. //excelBind.Add("零用金", new {
  15491. //cb="",
  15492. //rs="",
  15493. //xs ="",
  15494. //zcb = "",
  15495. //});
  15496. #endregion
  15497. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  15498. if (leftBindData != null)
  15499. {
  15500. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  15501. designer.SetDataSource("BLYJRS", leftBindData.rs);
  15502. designer.SetDataSource("BLYJXS", leftBindData.xs);
  15503. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15504. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15505. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15506. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15507. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15508. }
  15509. #endregion
  15510. #region B段Right信息
  15511. right = dto.rightInfo.Find(x => x.Type == "B");
  15512. if (right == null)
  15513. {
  15514. return Ok(jw);
  15515. }
  15516. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  15517. if (rightBindData != null)
  15518. {
  15519. //经济舱 + 双人间 TBR
  15520. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  15521. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  15522. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15523. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  15524. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15525. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15526. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15527. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15528. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15529. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15530. }
  15531. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  15532. if (rightBindData != null)
  15533. {
  15534. //经济舱 + 单人间 SGR
  15535. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  15536. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  15537. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15538. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  15539. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15540. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15541. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15542. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15543. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15544. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15545. }
  15546. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  15547. if (rightBindData != null)
  15548. {
  15549. //公务舱 + 单人间 SGR
  15550. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  15551. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  15552. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15553. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  15554. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15555. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15556. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15557. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15558. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15559. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15560. }
  15561. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  15562. if (rightBindData != null)
  15563. {
  15564. //公务舱 + 小套房 JSES
  15565. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  15566. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  15567. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15568. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  15569. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15570. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15571. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15572. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15573. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15574. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15575. }
  15576. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  15577. if (rightBindData != null)
  15578. {
  15579. //公务舱 + 小套房 JSES
  15580. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  15581. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  15582. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15583. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  15584. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15585. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15586. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15587. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15588. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15589. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15590. }
  15591. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  15592. if (rightBindData != null)
  15593. {
  15594. //经济舱 + 大套房
  15595. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  15596. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  15597. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15598. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  15599. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15600. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15601. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15602. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15603. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15604. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15605. }
  15606. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  15607. if (rightBindData != null)
  15608. {
  15609. //头等舱 + 小套房 JSES
  15610. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  15611. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  15612. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15613. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  15614. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15615. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15616. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15617. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15618. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15619. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15620. }
  15621. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  15622. if (rightBindData != null)
  15623. {
  15624. //头等舱 + 大套房
  15625. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  15626. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  15627. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15628. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  15629. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15630. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15631. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15632. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15633. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15634. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15635. }
  15636. #endregion
  15637. #region 标题
  15638. designer.SetDataSource("CostBDRCB", "单人成本");
  15639. designer.SetDataSource("CostBRS", "人数");
  15640. designer.SetDataSource("CostBXS", "系数");
  15641. designer.SetDataSource("CostBZCB", "总成本");
  15642. designer.SetDataSource("CostBDRBJ", "单人报价");
  15643. designer.SetDataSource("CostBZBJ", "总报价");
  15644. designer.SetDataSource("CostBDRLR", "单人利润");
  15645. designer.SetDataSource("CostBZLR", "总利润");
  15646. designer.SetDataSource("CostBDRCBOM", "单人成本");
  15647. designer.SetDataSource("CostBRSOM", "人数");
  15648. designer.SetDataSource("CostBZCBOM", "总成本");
  15649. designer.SetDataSource("CostBDRBJOM", "单人报价");
  15650. designer.SetDataSource("CostBZBJOM", "总报价");
  15651. designer.SetDataSource("CostBDRLROM", "单人利润");
  15652. designer.SetDataSource("CostBZLROM", "总利润");
  15653. #endregion
  15654. }
  15655. #endregion
  15656. designer.SetDataSource("TzZCB2", TzZCB2);
  15657. designer.SetDataSource("TzZBJ2", TzZBJ2);
  15658. designer.SetDataSource("TzZLR2", TzZLR2);
  15659. string[] dataSourceKeys = new string[]
  15660. {
  15661. "VF",
  15662. "TGS",
  15663. "TGOF",
  15664. "TGM",
  15665. "TGA",
  15666. "TGTF",
  15667. "TGEF",
  15668. "CFM",
  15669. "CFOF",
  15670. "B",
  15671. "L",
  15672. "D",
  15673. "TBR",
  15674. "SGR",
  15675. "JSES",
  15676. "Suite",
  15677. "TV",
  15678. "1L",
  15679. "IF",
  15680. "EF",
  15681. "BRF",
  15682. "TE",
  15683. "TGT",
  15684. "DRVT",
  15685. "PC",
  15686. "TLF",
  15687. "ECT"
  15688. };
  15689. foreach (var item in dataSourceKeys)
  15690. {
  15691. Func<TitleModel, bool> expr = x => x.label.Replace(" ", "").Replace("/", "") == item
  15692. || x.label.Replace(" ", "").Replace("/", "").ToUpper() == item.ToUpper();
  15693. var find = dto.titleModel.FirstOrDefault(expr);
  15694. if (find != null)
  15695. {
  15696. designer.SetDataSource(item, find.text);
  15697. }
  15698. else
  15699. {
  15700. designer.SetDataSource(item, 0);
  15701. }
  15702. }
  15703. designer.SetDataSource(dt);
  15704. //根据数据源处理生成报表内容
  15705. designer.Process();
  15706. designer.Workbook.Worksheets[0].Name = "费用明细";
  15707. designer.Workbook.Worksheets[1].Name = "费用总核算";
  15708. Worksheet sheet = designer.Workbook.Worksheets[0];
  15709. foreach (var Rowindex in hideRowsList)
  15710. {
  15711. ws.Cells.HideRows(Rowindex, 2);
  15712. }
  15713. ws = designer.Workbook.Worksheets[0];
  15714. foreach (var Column in hideColumnList)
  15715. {
  15716. ws.Cells.HideColumns(Column, 1);
  15717. }
  15718. byte[] bytes = null;
  15719. string strFileName = di.TeamName + "-团组-成本.xls";
  15720. using (MemoryStream stream = new MemoryStream())
  15721. {
  15722. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  15723. bytes = stream.ToArray();
  15724. }
  15725. return Ok(JsonView(true, "", new
  15726. {
  15727. Data = bytes,
  15728. strFileName,
  15729. }));
  15730. }
  15731. /// <summary>
  15732. /// 导出客户报表
  15733. /// </summary>
  15734. /// <returns></returns>
  15735. [HttpPost]
  15736. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  15737. {
  15738. var jw = JsonView(false);
  15739. if (dto.Diid == 0)
  15740. {
  15741. return Ok(JsonView(false, "请传递团组id"));
  15742. }
  15743. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  15744. if (deleInfo.Code != 0)
  15745. {
  15746. return Ok(JsonView(false, "团组信息查询失败!"));
  15747. }
  15748. var di = deleInfo.Data as DelegationInfoWebView;
  15749. if (di == null)
  15750. {
  15751. return Ok(JsonView(false, "团组信息查询失败!"));
  15752. }
  15753. //文件名
  15754. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  15755. //获取模板
  15756. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  15757. //载入模板
  15758. Document doc = new Document(tmppath);
  15759. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  15760. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  15761. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  15762. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  15763. var AParameter = ParameterList.Find(x => x.CostType == "A");
  15764. var BParameter = ParameterList.Find(x => x.CostType == "B");
  15765. if (AParameter == null)
  15766. {
  15767. return Ok(JsonView(false, "系数不存在!"));
  15768. }
  15769. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  15770. , TzAirDesc, TzZCost;
  15771. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  15772. = TzAirDesc = TzZCost = string.Empty;
  15773. TzNumber = AParameter.CostTypenumber.ToString();
  15774. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  15775. CarGuides1 = dto.CarGuides1;
  15776. Meal = dto.Meal;
  15777. SubsidizedMeals = dto.SubsidizedMeals;
  15778. NightRepair = dto.NightRepair;
  15779. AttractionsTickets = dto.AttractionsTickets;
  15780. MiscellaneousFees = dto.MiscellaneousFees;
  15781. ATip = dto.ATip;
  15782. TzHotelDesc = "";
  15783. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  15784. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  15785. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  15786. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  15787. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  15788. TzAirDesc = "";
  15789. TzZCost = dto.TzZCost;
  15790. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  15791. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  15792. var index = 1;
  15793. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  15794. foreach (var item in TzHotelDescArr)
  15795. {
  15796. if (AinfoArr != null)
  15797. {
  15798. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  15799. if (Ainfo != null)
  15800. {
  15801. if (int.Parse(Ainfo.rs) <= 0)
  15802. {
  15803. continue;
  15804. }
  15805. var hotelText = string.Empty;
  15806. switch (item)
  15807. {
  15808. case "SGR":
  15809. hotelText = "单人间";
  15810. break;
  15811. case "JSES":
  15812. hotelText = "小套房";
  15813. break;
  15814. case "SUITE":
  15815. hotelText = "套房";
  15816. break;
  15817. case "TBR":
  15818. hotelText = "双人间";
  15819. break;
  15820. }
  15821. if (item != "TBR")
  15822. {
  15823. 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";
  15824. }
  15825. else
  15826. {
  15827. 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";
  15828. }
  15829. index++;
  15830. }
  15831. }
  15832. }
  15833. index = 1;
  15834. foreach (var item in TzAirDescArr)
  15835. {
  15836. if (AinfoArr != null)
  15837. {
  15838. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  15839. if (Ainfo != null)
  15840. {
  15841. if (int.Parse(Ainfo.rs) <= 0)
  15842. {
  15843. continue;
  15844. }
  15845. 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";
  15846. index++;
  15847. }
  15848. }
  15849. }
  15850. if (dto.costType == "B")
  15851. {
  15852. if (BParameter == null)
  15853. {
  15854. return Ok(JsonView(false, "B段系数不存在!"));
  15855. }
  15856. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  15857. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  15858. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  15859. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  15860. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  15861. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  15862. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  15863. foreach (var item in TzHotelDescArr)
  15864. {
  15865. if (AinfoArr != null)
  15866. {
  15867. TzHotelDesc += "B段信息 \r\n";
  15868. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  15869. if (Ainfo != null)
  15870. {
  15871. if (int.Parse(Ainfo.rs) <= 0)
  15872. {
  15873. continue;
  15874. }
  15875. var hotelText = string.Empty;
  15876. switch (item)
  15877. {
  15878. case "SGR":
  15879. hotelText = "单人间";
  15880. break;
  15881. case "JSES":
  15882. hotelText = "小套房";
  15883. break;
  15884. case "SUITE":
  15885. hotelText = "套房";
  15886. break;
  15887. case "TBR":
  15888. hotelText = "双人间";
  15889. break;
  15890. }
  15891. if (item != "TBR")
  15892. {
  15893. 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";
  15894. }
  15895. else
  15896. {
  15897. 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";
  15898. }
  15899. index++;
  15900. }
  15901. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  15902. }
  15903. }
  15904. index = 1;
  15905. foreach (var item in TzAirDescArr)
  15906. {
  15907. if (AinfoArr != null)
  15908. {
  15909. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  15910. if (Ainfo != null)
  15911. {
  15912. if (int.Parse(Ainfo.rs) <= 0)
  15913. {
  15914. continue;
  15915. }
  15916. 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";
  15917. index++;
  15918. }
  15919. }
  15920. }
  15921. }
  15922. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  15923. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  15924. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  15925. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  15926. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  15927. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  15928. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  15929. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  15930. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  15931. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  15932. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  15933. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  15934. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  15935. DickeyValue.Add("Visa", Visa); // 签证单人报价
  15936. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  15937. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  15938. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  15939. DickeyValue.Add("TzZCost", TzZCost);
  15940. foreach (var key in DickeyValue.Keys)
  15941. {
  15942. if (doc.Range.Bookmarks[key] != null)
  15943. {
  15944. Bookmark mark = doc.Range.Bookmarks[key];
  15945. mark.Text = DickeyValue[key];
  15946. }
  15947. }
  15948. byte[] bytes = null;
  15949. string strFileName = di.TeamName + "-客户报价.doc";
  15950. using (MemoryStream stream = new MemoryStream())
  15951. {
  15952. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  15953. bytes = stream.ToArray();
  15954. }
  15955. return Ok(JsonView(true, "", new
  15956. {
  15957. Data = bytes,
  15958. strFileName,
  15959. }));
  15960. }
  15961. /// <summary>
  15962. /// 团组成本 各模块(酒店,地接,机票)成本提示
  15963. /// </summary>
  15964. /// <param name="dto"></param>
  15965. /// <returns></returns>
  15966. [HttpPost]
  15967. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15968. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  15969. {
  15970. try
  15971. {
  15972. #region 参数验证
  15973. if (dto.DiId < 0)
  15974. {
  15975. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  15976. }
  15977. List<int> cTableIds = new List<int>() {
  15978. 76 ,//酒店预订
  15979. 77 ,//行程
  15980. 79 ,//车/导游地接
  15981. 80 ,//签证
  15982. 81 ,//邀请/公务活
  15983. 82 ,//团组客户保险
  15984. 85 ,//机票预订
  15985. 98 ,//其他款项
  15986. 285 ,//收款退还
  15987. 751 ,//酒店早餐
  15988. 1015 // 超支费用
  15989. };
  15990. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  15991. {
  15992. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  15993. }
  15994. #endregion
  15995. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  15996. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  15997. if (_GroupCostParameters.Count <= 0)
  15998. {
  15999. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  16000. }
  16001. if (_GroupCostParameters[0].IsShare == 0)
  16002. {
  16003. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  16004. }
  16005. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  16006. //处理date为空问题
  16007. if (_GroupCosts.Count > 0)
  16008. {
  16009. for (int i = 0; i < _GroupCosts.Count; i++)
  16010. {
  16011. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  16012. {
  16013. if (i > 0)
  16014. {
  16015. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  16016. }
  16017. }
  16018. }
  16019. }
  16020. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  16021. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  16022. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  16023. string currCode = "";
  16024. #region currCode 验证
  16025. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  16026. if (isInt)
  16027. {
  16028. var currData = currDatas.Find(it => it.Id == intCurrency);
  16029. if (currData != null)
  16030. {
  16031. currCode = currData.Name;
  16032. }
  16033. }
  16034. else
  16035. {
  16036. currCode = _GroupCostParameters[0].Currency.Trim();
  16037. }
  16038. #endregion
  16039. //op,酒店单段模式存储
  16040. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  16041. {
  16042. CurrencyCode = currCode,
  16043. Rate = _GroupCostParameters[0].Rate,
  16044. CostType = _GroupCostParameters[0].CostType,
  16045. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  16046. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  16047. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  16048. };
  16049. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  16050. if (_GroupCostParameters.Count == 2)
  16051. {
  16052. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  16053. }
  16054. foreach (var item in _GroupCostParameters)
  16055. {
  16056. decimal _rate = 1;
  16057. decimal _rate1 = item.Rate;
  16058. decimal _scale = 1;
  16059. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  16060. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  16061. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  16062. //if (userInfo != null)
  16063. //{
  16064. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  16065. // {
  16066. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  16067. // {
  16068. // _scale = 1.00M;
  16069. // }
  16070. // }
  16071. //}
  16072. #endregion
  16073. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  16074. {
  16075. CurrencyCode = currCode,
  16076. Rate = _rate1,
  16077. CostType = item.CostType,
  16078. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  16079. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  16080. CostTypeNumber = item.CostTypenumber
  16081. };
  16082. if (_GroupCostParameters.Count > 1)
  16083. {
  16084. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  16085. }
  16086. else
  16087. {
  16088. modulePromptInfo.CostTypeNumber = item.LYJRS;
  16089. }
  16090. if (dto.CTable == 79)//
  16091. {
  16092. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  16093. modulePromptInfo.TotalCost = item.DJCB;
  16094. }
  16095. List<string> costTypes = new List<string>() { "A", "B" };
  16096. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  16097. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  16098. if (_GroupCostsDuplicates.Count() == 1)
  16099. {
  16100. _GroupCostsTypeData = _GroupCosts;
  16101. }
  16102. else
  16103. {
  16104. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  16105. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  16106. }
  16107. /*
  16108. * 76 酒店预订
  16109. * 77 行程
  16110. * 79 车/导游地接
  16111. * 80 签证
  16112. * 81 邀请/公务活动
  16113. * 82 团组客户保险
  16114. * 85 机票预订
  16115. * 98 其他款项
  16116. * 285 收款退还
  16117. * 751 酒店早餐
  16118. * 1015 超支费用
  16119. */
  16120. switch (dto.CTable)
  16121. {
  16122. case 76: // 酒店预订
  16123. _ModuleSubPromptInfo.AddRange(
  16124. _GroupCostsTypeData.Select(it => new
  16125. {
  16126. it.DAY,
  16127. it.Date,
  16128. it.ACCON,
  16129. it.ITIN,
  16130. it.SGR,
  16131. it.TBR,
  16132. it.JS_ES,
  16133. it.Suite
  16134. })
  16135. );
  16136. break;
  16137. case 79: // 车/导游地接
  16138. _ModuleSubPromptInfo.AddRange(
  16139. _GroupCostsTypeData.Select(it => new
  16140. {
  16141. Date = it.Date, //日期
  16142. CarFee = it.CarCost * _rate * _scale, //车费用
  16143. CarType = it.CarType, //车型
  16144. DriverFee = it.CFS * _rate * _scale, //司机工资
  16145. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  16146. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  16147. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  16148. GuideFee = it.TGS * _rate * _scale, //导游费用
  16149. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  16150. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  16151. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  16152. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  16153. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  16154. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  16155. Breakfast = it.B * _rate * _scale, //早餐费
  16156. Lunch = it.L * _rate * _scale, //午餐费
  16157. Dinner = it.D * _rate * _scale, //晚餐费
  16158. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  16159. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  16160. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  16161. TicketFee = it.EF * _rate * _scale, //门票费
  16162. TicketRemark = it.EFR, //门票费描述
  16163. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  16164. TravelSupplies = it.TE * _rate * _scale, //出行物资
  16165. SpentCash = it.PC * _rate * _scale, //零用金
  16166. LeadersFee = it.TLF * _rate * _scale, //领队费
  16167. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  16168. })
  16169. );
  16170. break;
  16171. case 85: // 机票
  16172. List<dynamic> datas = new List<dynamic>();
  16173. datas.Add(
  16174. new
  16175. {
  16176. AirType = "经济舱",
  16177. AirNum = item.JJCRS,
  16178. AirDRCB = item.JJCCB,
  16179. AirZCB = (item.JJCRS * item.JJCCB)
  16180. }
  16181. );
  16182. datas.Add(
  16183. new
  16184. {
  16185. AirType = "公务舱",
  16186. AirNum = item.GWCRS,
  16187. AirDRCB = item.GWCCB,
  16188. AirZCB = (item.GWCRS * item.GWCCB)
  16189. }
  16190. );
  16191. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  16192. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  16193. modulePromptInfo.Data = new
  16194. {
  16195. airFeeData = datas,
  16196. airInitData = initDatas
  16197. };
  16198. _ModulePromptInfos.Add(modulePromptInfo);
  16199. break;
  16200. default:
  16201. break;
  16202. }
  16203. }
  16204. if (dto.CTable != 85)
  16205. {
  16206. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  16207. _ModulePromptInfos.Add(_ModulePromptInfo);
  16208. }
  16209. _view.ModulePromptInfos = _ModulePromptInfos;
  16210. return Ok(JsonView(true, "操作成功!", _view));
  16211. }
  16212. catch (Exception ex)
  16213. {
  16214. return Ok(JsonView(false, ex.Message));
  16215. }
  16216. }
  16217. /// <summary>
  16218. /// 根据黑屏代码重新生成行程
  16219. /// </summary>
  16220. /// <param name="dto"></param>
  16221. /// <returns></returns>
  16222. [HttpPost]
  16223. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  16224. {
  16225. var jw = JsonView(false, "Error");
  16226. var Create = _sqlSugar.Queryable<Air_TicketBlackCode>()
  16227. .Where(x => x.IsDel == 0 && x.DiId == dto.Diid)
  16228. .Select(x => new
  16229. {
  16230. x.Id,
  16231. x.Title
  16232. })
  16233. .ToList();
  16234. if (Create.Any())
  16235. {
  16236. jw.Msg = "获取成功!";
  16237. jw.Code = 200;
  16238. jw.Data = new
  16239. {
  16240. BlackCodeListSelect = Create,
  16241. blackCodeIsTrue = true
  16242. };
  16243. }
  16244. else
  16245. {
  16246. jw.Code = 400;
  16247. jw.Data = new
  16248. {
  16249. BlackCodeListSelect = Create,
  16250. blackCodeIsTrue = false,
  16251. };
  16252. }
  16253. return Ok(jw);
  16254. }
  16255. /// <summary>
  16256. /// 根据黑屏代码Id重新生成行程
  16257. /// </summary>
  16258. /// <param name="dto"></param>
  16259. /// <returns></returns>
  16260. [HttpPost]
  16261. public IActionResult CraeteGroupCostTravelById(CraeteGroupCostTravelByIdDto dto)
  16262. {
  16263. var jw = JsonView(false, "Error");
  16264. var result = _GroupCostRepository.CreateGroupCostByBlackCode(dto.DiId, dto.BlackCodeId);
  16265. if (result.Code == 0)
  16266. {
  16267. jw.Msg = "获取成功!";
  16268. jw.Code = 200;
  16269. jw.Data = new
  16270. {
  16271. groupCost = result.Data,
  16272. blackCodeIsTrue = true
  16273. };
  16274. }
  16275. else
  16276. {
  16277. jw.Code = 400;
  16278. jw.Data = new
  16279. {
  16280. groupCost = result.Data,
  16281. blackCodeIsTrue = false,
  16282. };
  16283. }
  16284. return Ok(jw);
  16285. }
  16286. /// <summary>
  16287. /// 成本获取OP历史车费用
  16288. /// </summary>
  16289. /// <param name="dto"></param>
  16290. /// <returns></returns>
  16291. [HttpPost]
  16292. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  16293. {
  16294. var jw = JsonView(false);
  16295. try
  16296. {
  16297. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  16298. //获取现有所有车的数据
  16299. if (!dto.Param.IsNullOrWhiteSpace())
  16300. {
  16301. string sql = $@"
  16302. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  16303. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  16304. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  16305. 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
  16306. AND gctggr.ServiceEndTime is not NULL
  16307. ORDER by gctggrc.id DESC
  16308. ";
  16309. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  16310. var numeberResult = await Task.Run(() =>
  16311. {
  16312. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  16313. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  16314. return numberArr;
  16315. });
  16316. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  16317. foreach (var item in numeberResult)
  16318. {
  16319. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  16320. {
  16321. Country = "数据异常!",
  16322. City = string.Empty,
  16323. };
  16324. item.Area = find.Country + " " + find.City;
  16325. }
  16326. dbResult.AddRange(numeberResult);
  16327. if (dto.Param.Contains("、"))
  16328. {
  16329. var sp = dto.Param.Split("、");
  16330. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  16331. .Where(x =>
  16332. {
  16333. return System.Array.Exists(sp, e =>
  16334. {
  16335. bool where = false;
  16336. if (x.Area != null)
  16337. {
  16338. where = x.Area.Contains(e);
  16339. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  16340. {
  16341. return false;
  16342. }
  16343. }
  16344. if (x.PriceName != null && !where)
  16345. {
  16346. where = x.PriceName.Contains(e);
  16347. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  16348. {
  16349. return false;
  16350. }
  16351. }
  16352. return where;
  16353. });
  16354. }).ToList();
  16355. }
  16356. else
  16357. {
  16358. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  16359. .Where(x =>
  16360. {
  16361. bool where = false;
  16362. if (x.Area != null)
  16363. {
  16364. where = x.Area.Contains(dto.Param);
  16365. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  16366. {
  16367. return false;
  16368. }
  16369. }
  16370. if (x.PriceName != null && !where)
  16371. {
  16372. where = x.PriceName.Contains(dto.Param);
  16373. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  16374. {
  16375. return false;
  16376. }
  16377. }
  16378. return where;
  16379. }
  16380. )
  16381. .ToList();
  16382. }
  16383. }
  16384. var view = dbResult.Select(x =>
  16385. {
  16386. decimal dp = 0.00M;
  16387. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  16388. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  16389. if (string.IsNullOrWhiteSpace(x.DatePrice))
  16390. {
  16391. if (startB && endB)
  16392. {
  16393. var timesp = endD.Subtract(startD);
  16394. if ((timesp.Days + 1) != 0)
  16395. {
  16396. dp = x.Price / (timesp.Days + 1);
  16397. }
  16398. }
  16399. }
  16400. else
  16401. {
  16402. dp = x.Price;
  16403. }
  16404. return new
  16405. {
  16406. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  16407. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  16408. x.Area,
  16409. x.id,
  16410. price = x.Price.ToString("F2"),
  16411. x.PriceName,
  16412. x.PriceContent,
  16413. x.TeamName,
  16414. x.DatePrice,
  16415. dayPrice = dp.ToString("F2"),
  16416. };
  16417. }).OrderByDescending(x => x.id).ToList();
  16418. jw = JsonView(true, "获取成功!", view);
  16419. }
  16420. catch (Exception e)
  16421. {
  16422. jw = JsonView(false, e.Message);
  16423. }
  16424. return Ok(jw);
  16425. }
  16426. [HttpPost]
  16427. public async Task<IActionResult> SearchGroupByKeyword(SearchGroupByKeywordDto dto)
  16428. {
  16429. var jw = JsonView(true);
  16430. List<DelegationInfoAndIsTrueView> matches = new List<DelegationInfoAndIsTrueView>();
  16431. #region SQL语句
  16432. //if (string.IsNullOrWhiteSpace(dto.Keyword))
  16433. //{
  16434. // matches = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  16435. // Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  16436. // WHEN COUNT(*) >= 0 THEN 'True'
  16437. // ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  16438. // Where TeamName != '' And IsDel = 0 Order By a.VisitStartDate Desc
  16439. // ")
  16440. // .ToList();
  16441. //}
  16442. //else
  16443. //{
  16444. // string likeKey = string.Empty;
  16445. // foreach (var item in dto.Keyword)
  16446. // {
  16447. // likeKey += "%" + item;
  16448. // }
  16449. // likeKey += "%";
  16450. // matches = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  16451. // Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  16452. // WHEN COUNT(*) >= 0 THEN 'True'
  16453. // ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  16454. // Where TeamName != '' And IsDel = 0 And TeamName LIKE '{likeKey}' Order By a.VisitStartDate Desc
  16455. // ")
  16456. // .ToList();
  16457. //}
  16458. #endregion
  16459. var table = _sqlSugar.Ado.UseStoredProcedure().GetDataTable("SearchGroupByKeyword", new
  16460. {
  16461. @KeyWord = dto.Keyword
  16462. });
  16463. if (table != null && table.Rows.Count > 0)
  16464. {
  16465. foreach (DataRow row in table.Rows)
  16466. {
  16467. matches.Add(new DelegationInfoAndIsTrueView
  16468. {
  16469. Id = row.Field<int>("Id"),
  16470. GroupName = row.Field<string>("GroupName"),
  16471. isTrue = row.Field<string>("isTrue")
  16472. });
  16473. }
  16474. }
  16475. if (matches.Any())
  16476. {
  16477. jw.Data = matches;
  16478. }
  16479. else
  16480. {
  16481. jw.Code = 201;
  16482. jw.Msg = "empty list";
  16483. jw.Data = new List<string>(1);
  16484. }
  16485. return Ok(jw);
  16486. }
  16487. /// <summary>
  16488. /// 报价Word下载
  16489. /// </summary>
  16490. /// <param name="dto"></param>
  16491. /// <returns></returns>
  16492. [HttpPost]
  16493. public async Task<IActionResult> GroupQuotationsFileDown(GroupQuotationsFileDownDto dto)
  16494. {
  16495. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  16496. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  16497. if (di == null)
  16498. {
  16499. return Ok(JsonView(false, "团组不存在!"));
  16500. }
  16501. var mainPrice = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  16502. if (mainPrice == null || mainPrice.IsShare == 0)
  16503. {
  16504. return Ok(JsonView(false, "团组成本不存在!"));
  16505. }
  16506. var costTypeHotelNumbers = await _sqlSugar.Queryable<Grp_CostTypeHotelNumber>()
  16507. .FirstAsync(x => x.Type == "Default" && x.Diid == dto.Diid && x.IsDel == 0);
  16508. if (costTypeHotelNumbers == null)
  16509. {
  16510. return Ok(JsonView(false, "团组成本不存在!"));
  16511. }
  16512. //文件名
  16513. string strFileName = di.TeamName + "-收款账单.doc";
  16514. //获取模板
  16515. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  16516. //载入模板
  16517. Document doc = new Document(tmppath);
  16518. decimal allPrice = 0.00M;
  16519. string itemStr = string.Empty;
  16520. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  16521. airSouer.Add("经济舱TBR", "经济舱及酒店双人间");
  16522. airSouer.Add("经济舱SGR", "经济舱及酒店单人间");
  16523. airSouer.Add("公务舱SGR", "公务舱及酒店单人间");
  16524. airSouer.Add("公务舱JSES", "公务舱及酒店小套房");
  16525. airSouer.Add("公务舱SUITE", "公务舱及酒店套房");
  16526. airSouer.Add("经济舱SUITE", "经济舱及酒店套房");
  16527. airSouer.Add("头等舱JSES", "头等舱及酒店小套房");
  16528. airSouer.Add("头等舱SUITE", "头等舱及酒店套房");
  16529. airSouer.Add("经济舱JSES", "经济舱及酒店小套房");
  16530. var priceDataList = new List<(string rsName, string cbName, string xsName, string prefix)>
  16531. {
  16532. ("VisaRS", "VisaCB", "VisaXS", "qz"),
  16533. ("BXRS", "BXCB", "BXXS", "bx"),
  16534. ("HCPRS", "HCPCB", "HCPXS", "hcp"),
  16535. ("JJCRS", "JJCCB", "JJCXS", "jjc"),
  16536. ("GWCRS", "GWCCB", "GWCXS", "gwc"),
  16537. ("TDCRS", "TDCCB", "TDCXS", "tdc"),
  16538. ("CPRS", "CPCB", "CPXS", "cp"),
  16539. ("HSRS", "HSCB", "HSXS", "hsjc"),
  16540. ("TBRNumber", "TBRCB", "TBRXS", "tbr"),
  16541. ("SGRNumber", "SGRCB", "SGRXS", "sgr"),
  16542. ("JSESNumber", "JSESCB", "JSESXS", "jses"),
  16543. ("SUITENumber", "SUITECB", "SUITEXS", "suite"),
  16544. ("DJRS", "DJCB", "DJXS", "dj"),
  16545. ("GWRS", "GWCB", "GWXS", "gw"),
  16546. ("LYJRS", "LYJCB", "LYJXS", "lyj"),
  16547. };
  16548. var OtherCostPropertyBJ = new string[] { "qz", "hcp", "cp", "bx", "hsjc", "dj", "gw", "lyj" };
  16549. var rightSum = 0.00M;
  16550. foreach (var (rsName, cbName, xsName, prefix) in priceDataList)
  16551. {
  16552. var rsValue = (int)mainPrice.GetType().GetProperty(rsName).GetValue(mainPrice);
  16553. var cbValue = (decimal)mainPrice.GetType().GetProperty(cbName).GetValue(mainPrice);
  16554. var xsValue = (decimal)mainPrice.GetType().GetProperty(xsName).GetValue(mainPrice);
  16555. if (prefix == "tbr")
  16556. {
  16557. rsValue *= 2;
  16558. cbValue /= 2;
  16559. }
  16560. if (OtherCostPropertyBJ.Contains(prefix))
  16561. {
  16562. rightSum += cbValue * xsValue;
  16563. }
  16564. }
  16565. var hotelRooms = new Dictionary<string, int>
  16566. {
  16567. { "SGR", costTypeHotelNumbers.SGR },
  16568. { "TBR", costTypeHotelNumbers.TBR },
  16569. { "JSES", costTypeHotelNumbers.JSES },
  16570. { "SUITE", costTypeHotelNumbers.SUITE }
  16571. };
  16572. var flights = new Dictionary<string, int>
  16573. {
  16574. { "经济舱", mainPrice.JJCRS },
  16575. { "公务舱", mainPrice.GWCRS },
  16576. { "头等舱", mainPrice.TDCRS }
  16577. };
  16578. var flightRoomMatchingRules = new Dictionary<string, string[]>
  16579. {
  16580. { "经济舱", new[] { "TBR", "SGR", "JSES", "SUITE" } },
  16581. { "公务舱", new[] { "SUITE", "JSES", "SGR" } },
  16582. { "头等舱", new[] { "SUITE", "JSES" } }
  16583. };
  16584. var result = new Dictionary<string, int>();
  16585. List<AirHotelPrice> airHotelPriceList = new List<AirHotelPrice>();
  16586. foreach (var flight in flights.Keys)
  16587. {
  16588. // 获取当前舱位的匹配规则
  16589. if (flightRoomMatchingRules.TryGetValue(flight, out string[] roomTypes))
  16590. {
  16591. MatchRooms(ref hotelRooms, ref flights, roomTypes, flight, ref result);
  16592. }
  16593. }
  16594. #region right计算
  16595. if (result.Keys.Contains("经济舱TBR") && result["经济舱TBR"] > 0)
  16596. {
  16597. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16598. var hotel = (mainPrice.TBRCB * mainPrice.TBRXS) / 2;
  16599. airHotelPriceList.Add(new
  16600. AirHotelPrice
  16601. {
  16602. Name = "经济舱TBR",
  16603. Price = rightSum + air + hotel,
  16604. Count = result["经济舱TBR"] * 2
  16605. });
  16606. allPrice += (rightSum + air + hotel) * result["经济舱TBR"] * 2;
  16607. }
  16608. if (result.Keys.Contains("经济舱SGR") && result["经济舱SGR"] > 0)
  16609. {
  16610. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16611. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  16612. airHotelPriceList.Add(new
  16613. AirHotelPrice
  16614. {
  16615. Name = "经济舱SGR",
  16616. Price = rightSum + air + hotel,
  16617. Count = result["经济舱SGR"]
  16618. });
  16619. allPrice += (rightSum + air + hotel) * result["经济舱SGR"];
  16620. }
  16621. if (result.Keys.Contains("公务舱SGR") && result["公务舱SGR"] > 0)
  16622. {
  16623. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16624. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  16625. airHotelPriceList.Add(new
  16626. AirHotelPrice
  16627. {
  16628. Name = "公务舱SGR",
  16629. Price = rightSum + air + hotel,
  16630. Count = result["公务舱SGR"]
  16631. });
  16632. allPrice += (rightSum + air + hotel) * result["公务舱SGR"];
  16633. }
  16634. if (result.Keys.Contains("公务舱JSES") && result["公务舱JSES"] > 0)
  16635. {
  16636. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16637. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16638. airHotelPriceList.Add(new
  16639. AirHotelPrice
  16640. {
  16641. Name = "公务舱JSES",
  16642. Price = rightSum + air + hotel,
  16643. Count = result["公务舱JSES"]
  16644. });
  16645. allPrice += (rightSum + air + hotel) * result["公务舱JSES"];
  16646. }
  16647. if (result.Keys.Contains("公务舱SUITE") && result["公务舱SUITE"] > 0)
  16648. {
  16649. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16650. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16651. airHotelPriceList.Add(new
  16652. AirHotelPrice
  16653. {
  16654. Name = "公务舱SUITE",
  16655. Price = rightSum + air + hotel,
  16656. Count = result["公务舱SUITE"]
  16657. });
  16658. allPrice += (rightSum + air + hotel) * result["公务舱SUITE"];
  16659. }
  16660. if (result.Keys.Contains("经济舱SUITE") && result["经济舱SUITE"] > 0)
  16661. {
  16662. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16663. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16664. airHotelPriceList.Add(new
  16665. AirHotelPrice
  16666. {
  16667. Name = "经济舱SUITE",
  16668. Price = rightSum + air + hotel,
  16669. Count = result["经济舱SUITE"]
  16670. });
  16671. allPrice += (rightSum + air + hotel) * result["经济舱SUITE"];
  16672. }
  16673. if (result.Keys.Contains("头等舱JSES") && result["头等舱JSES"] > 0)
  16674. {
  16675. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  16676. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16677. airHotelPriceList.Add(new
  16678. AirHotelPrice
  16679. {
  16680. Name = "头等舱JSES",
  16681. Price = rightSum + air + hotel,
  16682. Count = result["头等舱JSES"]
  16683. });
  16684. allPrice += (rightSum + air + hotel) * result["头等舱JSES"];
  16685. }
  16686. if (result.Keys.Contains("头等舱SUITE") && result["头等舱SUITE"] > 0)
  16687. {
  16688. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  16689. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16690. airHotelPriceList.Add(new
  16691. AirHotelPrice
  16692. {
  16693. Name = "头等舱SUITE",
  16694. Price = rightSum + air + hotel,
  16695. Count = result["头等舱SUITE"]
  16696. });
  16697. allPrice += (rightSum + air + hotel) * result["头等舱SUITE"];
  16698. }
  16699. if (result.Keys.Contains("经济舱JSES") && result["经济舱JSES"] > 0)
  16700. {
  16701. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16702. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16703. airHotelPriceList.Add(new
  16704. AirHotelPrice
  16705. {
  16706. Name = "经济舱JSES",
  16707. Price = rightSum + air + hotel,
  16708. Count = result["经济舱JSES"]
  16709. });
  16710. allPrice += (rightSum + air + hotel) * result["经济舱JSES"];
  16711. }
  16712. #endregion
  16713. foreach (var item in airSouer.Keys)
  16714. {
  16715. var find = airHotelPriceList.FirstOrDefault(x => x.Name == item);
  16716. if (find != null && find.Count > 0)
  16717. {
  16718. if (item.Contains("TBR"))
  16719. {
  16720. itemStr += "团费(" + airSouer[item] + ") RMB " + find.Price.ToString("F2") + "/人*" + find.Count + "(" + (find.Count / 2) + "间) ............合计 RMB " + (find.Count * find.Price).ToString("#0.00") + "\n";
  16721. }
  16722. else
  16723. {
  16724. itemStr += "团费(" + airSouer[item] + ") RMB " + find.Price.ToString("F2") + "/人*" + find.Count + "(" + find.Count + "间) ............合计 RMB " + (find.Count * find.Price).ToString("#0.00") + "\n";
  16725. }
  16726. }
  16727. }
  16728. #region 替换Word模板书签内容
  16729. Dictionary<string, string> marks = new Dictionary<string, string>();
  16730. marks.Add("To", di.ClientUnit);//付款方
  16731. marks.Add("ToTel", di.TellPhone);//付款方电话
  16732. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  16733. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  16734. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  16735. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  16736. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  16737. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  16738. marks.Add("PayItemContent", itemStr);//详细信息
  16739. marks.Add("Total", allPrice.ToString("F2"));//合计
  16740. #endregion
  16741. foreach (var item in marks.Keys)
  16742. {
  16743. if (doc.Range.Bookmarks[item] != null)
  16744. {
  16745. Bookmark mark = doc.Range.Bookmarks[item];
  16746. mark.Text = marks[item];
  16747. }
  16748. }
  16749. string savePaht = $"{AppSettingsHelper.Get("WordBasePath")}GroupCostQuotations/{di.TeamName}_报批费用.doc";
  16750. doc.Save(savePaht);
  16751. var jw = new JsonView();
  16752. jw.Msg = "生成成功!";
  16753. jw.Code = 200;
  16754. jw.Data = new { Url = AppSettingsHelper.Get("WordBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("WordBasePath"), AppSettingsHelper.Get("WordFtpPath")) };
  16755. return Ok(jw);
  16756. }
  16757. /// <summary>
  16758. /// 详细报价费用Excel下载
  16759. /// </summary>
  16760. /// <param name="dto"></param>
  16761. /// <returns></returns>
  16762. [HttpPost]
  16763. public async Task<IActionResult> GroupQuotationsDetailFileDown(GroupQuotationsFileDownDto dto)
  16764. {
  16765. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  16766. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  16767. if (di == null)
  16768. {
  16769. return Ok(JsonView(false, "团组不存在!"));
  16770. }
  16771. var mainPrice = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  16772. if (mainPrice == null || mainPrice.IsShare == 0)
  16773. {
  16774. return Ok(JsonView(false, "团组成本不存在!"));
  16775. }
  16776. var costTypeHotelNumbers = await _sqlSugar.Queryable<Grp_CostTypeHotelNumber>()
  16777. .FirstAsync(x => x.Type == "Default" && x.Diid == dto.Diid && x.IsDel == 0);
  16778. if (costTypeHotelNumbers == null)
  16779. {
  16780. return Ok(JsonView(false, "团组成本不存在!"));
  16781. }
  16782. WorkbookDesigner designer = new WorkbookDesigner();
  16783. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/报价详细表.xls"));
  16784. List<int> hideRowsList = new List<int>();
  16785. int conterStartIndex = 3;
  16786. int rowIndex = conterStartIndex;
  16787. designer.SetDataSource("GroupName", di.TeamName);
  16788. var priceDataList = new List<(string rsName, string cbName, string xsName, string prefix)>
  16789. {
  16790. ("VisaRS", "VisaCB", "VisaXS", "qz"),
  16791. ("BXRS", "BXCB", "BXXS", "bx"),
  16792. ("HCPRS", "HCPCB", "HCPXS", "hcp"),
  16793. ("JJCRS", "JJCCB", "JJCXS", "jjc"),
  16794. ("GWCRS", "GWCCB", "GWCXS", "gwc") ,
  16795. ("TDCRS", "TDCCB", "TDCXS", "tdc") ,
  16796. ("CPRS", "CPCB", "CPXS", "cp") ,
  16797. ("HSRS", "HSCB", "HSXS", "hsjc") ,
  16798. ("TBRNumber", "TBRCB", "TBRXS", "tbr") ,
  16799. ("SGRNumber", "SGRCB", "SGRXS", "sgr") ,
  16800. ("JSESNumber", "JSESCB", "JSESXS", "jses") ,
  16801. ("SUITENumber", "SUITECB", "SUITEXS", "suite") ,
  16802. ("DJRS", "DJCB", "DJXS", "dj") ,
  16803. ("GWRS", "GWCB", "GWXS", "gw") ,
  16804. ("LYJRS", "LYJCB", "LYJXS", "lyj") ,
  16805. };
  16806. var OtherCostPropertyBJ = new string[] { "qz", "hcp", "cp", "bx", "hsjc", "dj", "gw", "lyj" };
  16807. var rightSum = 0.00M;
  16808. foreach (var (rsName, cbName, xsName, prefix) in priceDataList)
  16809. {
  16810. var rsValue = (int)mainPrice.GetType().GetProperty(rsName).GetValue(mainPrice);
  16811. var cbValue = (decimal)mainPrice.GetType().GetProperty(cbName).GetValue(mainPrice);
  16812. var xsValue = (decimal)mainPrice.GetType().GetProperty(xsName).GetValue(mainPrice);
  16813. if (prefix == "tbr")
  16814. {
  16815. rsValue *= 2;
  16816. cbValue /= 2;
  16817. }
  16818. if (OtherCostPropertyBJ.Contains(prefix))
  16819. {
  16820. rightSum += cbValue * xsValue;
  16821. }
  16822. if (rsValue == 0)
  16823. {
  16824. hideRowsList.Add(rowIndex);
  16825. }
  16826. else
  16827. {
  16828. designer.SetDataSource($"{prefix}rs", rsValue);
  16829. designer.SetDataSource($"{prefix}bj", cbValue * xsValue);
  16830. designer.SetDataSource($"{prefix}zbj", cbValue * xsValue * rsValue);
  16831. }
  16832. rowIndex += 2;
  16833. }
  16834. var hotelRooms = new Dictionary<string, int>
  16835. {
  16836. { "SGR", costTypeHotelNumbers.SGR },
  16837. { "TBR", costTypeHotelNumbers.TBR },
  16838. { "JSES", costTypeHotelNumbers.JSES },
  16839. { "SUITE", costTypeHotelNumbers.SUITE }
  16840. };
  16841. var flights = new Dictionary<string, int>
  16842. {
  16843. { "经济舱", mainPrice.JJCRS },
  16844. { "公务舱", mainPrice.GWCRS },
  16845. { "头等舱", mainPrice.TDCRS }
  16846. };
  16847. var flightRoomMatchingRules = new Dictionary<string, string[]>
  16848. {
  16849. { "经济舱", new[] { "TBR", "SGR", "JSES", "SUITE" } },
  16850. { "公务舱", new[] { "SUITE", "JSES", "SGR" } },
  16851. { "头等舱", new[] { "SUITE", "JSES" } }
  16852. };
  16853. var result = new Dictionary<string, int>();
  16854. foreach (var flight in flights.Keys)
  16855. {
  16856. // 获取当前舱位的匹配规则
  16857. if (flightRoomMatchingRules.TryGetValue(flight, out string[] roomTypes))
  16858. {
  16859. MatchRooms(ref hotelRooms, ref flights, roomTypes, flight, ref result);
  16860. }
  16861. }
  16862. var allPrice = 0.00M;
  16863. #region right计算
  16864. int airRowIndex = 35;
  16865. if (result.Keys.Contains("经济舱TBR") && result["经济舱TBR"] > 0)
  16866. {
  16867. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16868. var hotel = (mainPrice.TBRCB * mainPrice.TBRXS) / 2;
  16869. designer.SetDataSource("jjctbrrs", result["经济舱TBR"] * 2);
  16870. designer.SetDataSource("jjctbrbj", rightSum + air + hotel);
  16871. designer.SetDataSource("jjctbrzbj", (rightSum + air + hotel) * result["经济舱TBR"] * 2);
  16872. allPrice += (rightSum + air + hotel) * result["经济舱TBR"] * 2;
  16873. }
  16874. else
  16875. {
  16876. hideRowsList.Add(airRowIndex);
  16877. }
  16878. airRowIndex += 2;
  16879. if (result.Keys.Contains("经济舱SGR") && result["经济舱SGR"] > 0)
  16880. {
  16881. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16882. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  16883. designer.SetDataSource("jjcsgrrs", result["经济舱SGR"]);
  16884. designer.SetDataSource("jjcsgrbj", rightSum + air + hotel);
  16885. designer.SetDataSource("jjcsgrzbj", (rightSum + air + hotel) * result["经济舱SGR"]);
  16886. allPrice += (rightSum + air + hotel) * result["经济舱SGR"];
  16887. }
  16888. else
  16889. {
  16890. hideRowsList.Add(airRowIndex);
  16891. }
  16892. airRowIndex += 2;
  16893. if (result.Keys.Contains("公务舱SGR") && result["公务舱SGR"] > 0)
  16894. {
  16895. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16896. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  16897. designer.SetDataSource("gwcsgrrs", result["公务舱SGR"]);
  16898. designer.SetDataSource("gwcsgrbj", rightSum + air + hotel);
  16899. designer.SetDataSource("gwcsgrzbj", (rightSum + air + hotel) * result["公务舱SGR"]);
  16900. allPrice += (rightSum + air + hotel) * result["公务舱SGR"];
  16901. }
  16902. else
  16903. {
  16904. hideRowsList.Add(airRowIndex);
  16905. }
  16906. airRowIndex += 2;
  16907. if (result.Keys.Contains("公务舱JSES") && result["公务舱JSES"] > 0)
  16908. {
  16909. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16910. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16911. designer.SetDataSource("gwcjsesrs", result["公务舱JSES"]);
  16912. designer.SetDataSource("gwcjsesbj", rightSum + air + hotel);
  16913. designer.SetDataSource("gwcjseszbj", (rightSum + air + hotel) * result["公务舱JSES"]);
  16914. allPrice += (rightSum + air + hotel) * result["公务舱JSES"];
  16915. }
  16916. else
  16917. {
  16918. hideRowsList.Add(airRowIndex);
  16919. }
  16920. airRowIndex += 2;
  16921. if (result.Keys.Contains("公务舱SUITE") && result["公务舱SUITE"] > 0)
  16922. {
  16923. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16924. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16925. designer.SetDataSource("gwcsuiters", result["公务舱SUITE"]);
  16926. designer.SetDataSource("gwcsuitebj", rightSum + air + hotel);
  16927. designer.SetDataSource("gwcsuitezbj", (rightSum + air + hotel) * result["公务舱SUITE"]);
  16928. allPrice += (rightSum + air + hotel) * result["公务舱SUITE"];
  16929. }
  16930. else
  16931. {
  16932. hideRowsList.Add(airRowIndex);
  16933. }
  16934. airRowIndex += 2;
  16935. if (result.Keys.Contains("经济舱SUITE") && result["经济舱SUITE"] > 0)
  16936. {
  16937. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16938. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16939. designer.SetDataSource("jjcsuiters", result["经济舱SUITE"]);
  16940. designer.SetDataSource("jjcsuitebj", rightSum + air + hotel);
  16941. designer.SetDataSource("jjcsuitezbj", (rightSum + air + hotel) * result["经济舱SUITE"]);
  16942. allPrice += (rightSum + air + hotel) * result["经济舱SUITE"];
  16943. }
  16944. else
  16945. {
  16946. hideRowsList.Add(airRowIndex);
  16947. }
  16948. airRowIndex += 2;
  16949. if (result.Keys.Contains("头等舱JSES") && result["头等舱JSES"] > 0)
  16950. {
  16951. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  16952. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16953. designer.SetDataSource("tdcjsesrs", result["头等舱JSES"]);
  16954. designer.SetDataSource("tdcjsesbj", rightSum + air + hotel);
  16955. designer.SetDataSource("tdcjseszbj", (rightSum + air + hotel) * result["头等舱JSES"]);
  16956. allPrice += (rightSum + air + hotel) * result["头等舱JSES"];
  16957. }
  16958. else
  16959. {
  16960. hideRowsList.Add(airRowIndex);
  16961. }
  16962. airRowIndex += 2;
  16963. if (result.Keys.Contains("头等舱SUITE") && result["头等舱SUITE"] > 0)
  16964. {
  16965. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  16966. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16967. designer.SetDataSource("tdcsuiters", result["头等舱SUITE"]);
  16968. designer.SetDataSource("tdcsuitebj", rightSum + air + hotel);
  16969. designer.SetDataSource("tdcsuitezbj", (rightSum + air + hotel) * result["头等舱SUITE"]);
  16970. allPrice += (rightSum + air + hotel) * result["头等舱SUITE"];
  16971. }
  16972. else
  16973. {
  16974. hideRowsList.Add(airRowIndex);
  16975. }
  16976. airRowIndex += 2;
  16977. if (result.Keys.Contains("经济舱JSES") && result["经济舱JSES"] > 0)
  16978. {
  16979. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16980. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16981. designer.SetDataSource("jjcjsesrs", result["经济舱JSES"]);
  16982. designer.SetDataSource("jjcjsesbj", rightSum + air + hotel);
  16983. designer.SetDataSource("jjcjseszbj", (rightSum + air + hotel) * result["经济舱JSES"]);
  16984. allPrice += (rightSum + air + hotel) * result["经济舱JSES"];
  16985. }
  16986. else
  16987. {
  16988. hideRowsList.Add(airRowIndex);
  16989. }
  16990. #endregion
  16991. designer.SetDataSource("AllPrice", "总金额:" + allPrice.ToString("#0.00"));
  16992. string savePaht = AppSettingsHelper.Get("ExcelBasePath") + "GroupCostQuotations/" + di.TeamName + "_详细报批费用.xls";
  16993. var ws = designer.Workbook.Worksheets[0];
  16994. foreach (var Rowindex in hideRowsList)
  16995. {
  16996. ws.Cells.HideRows(Rowindex, 2);
  16997. }
  16998. designer.Process();
  16999. designer.Workbook.Save(savePaht);
  17000. return Ok(JsonView(true, "生成成功!", new
  17001. {
  17002. Url = AppSettingsHelper.Get("ExcelBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("ExcelBasePath"), AppSettingsHelper.Get("ExcelFtpPath"))
  17003. }));
  17004. }
  17005. private void MatchRooms(ref Dictionary<string, int> hotelRooms, ref Dictionary<string, int> flights, string[] roomTypes, string flightType, ref Dictionary<string, int> result)
  17006. {
  17007. foreach (var roomType in roomTypes)
  17008. {
  17009. while (hotelRooms[roomType] > 0 && flights[flightType] > 0)
  17010. {
  17011. hotelRooms[roomType]--;
  17012. flights[flightType]--;
  17013. if (roomType == "TBR")
  17014. {
  17015. flights[flightType]--; // 双人间在减少1
  17016. }
  17017. string key = flightType + roomType;
  17018. if (result.Keys.Contains(key))
  17019. {
  17020. result[key]++;
  17021. }
  17022. else
  17023. {
  17024. result.Add(key, 1);
  17025. }
  17026. }
  17027. }
  17028. }
  17029. private class AirHotelPrice
  17030. {
  17031. public string Name { get; set; }
  17032. public decimal Price { get; set; }
  17033. public int Count { get; set; }
  17034. }
  17035. private class HotelSum
  17036. {
  17037. internal decimal SGR { get; set; }
  17038. internal decimal TBR { get; set; }
  17039. internal decimal JSES { get; set; }
  17040. internal decimal SUITE { get; set; }
  17041. internal decimal AllPrice
  17042. {
  17043. get { return SGR + TBR + JSES + SUITE; }
  17044. }
  17045. }
  17046. [HttpPost]
  17047. public async Task<IActionResult> QueryGroupCostCoefficient(QueryGroupCostCoefficientDto dto)
  17048. {
  17049. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  17050. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  17051. if (di == null)
  17052. {
  17053. return Ok(JsonView(false, "团组不存在!"));
  17054. }
  17055. var groupCost = _sqlSugar.Queryable<Grp_GroupCost>()
  17056. .Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  17057. .ToList();
  17058. var groupHotelNumber = _sqlSugar.Queryable<Grp_CostTypeHotelNumber>()
  17059. .Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  17060. .ToList();
  17061. var groupHotelNumberDefault = groupHotelNumber.FirstOrDefault(x => x.Type == "Default");
  17062. HotelSum hotelSumP = new();
  17063. if (groupCost.Any())
  17064. {
  17065. hotelSumP.SGR = groupHotelNumberDefault.SGR > 0 ? groupCost.Sum(x => x.SGR) * groupHotelNumberDefault.SGR : 0;
  17066. hotelSumP.TBR = groupHotelNumberDefault.TBR > 0 ? groupCost.Sum(x => x.TBR) * groupHotelNumberDefault.TBR : 0;
  17067. hotelSumP.JSES = groupHotelNumberDefault.JSES > 0 ? groupCost.Sum(x => x.JS_ES) * groupHotelNumberDefault.JSES : 0;
  17068. hotelSumP.SUITE = groupHotelNumberDefault.SUITE > 0 ? groupCost.Sum(x => x.Suite) * groupHotelNumberDefault.SUITE : 0;
  17069. }
  17070. #region 地接系数
  17071. Func<int, decimal> coefficientByDJ = (number) =>
  17072. {
  17073. if (number < 1) return 0.00M;
  17074. return number switch
  17075. {
  17076. < 6 => 2.5M,
  17077. 6 => 2.4M,
  17078. 7 => 1.8M,
  17079. 8 => 2.0M,
  17080. 9 => 3.0M,
  17081. 10 => 1.75M,
  17082. > 10 => 1.9M,
  17083. };
  17084. };
  17085. #endregion
  17086. #region 酒店系数
  17087. #endregion
  17088. return Ok(JsonView(true, "查询成功", new
  17089. {
  17090. HotelSum = hotelSumP,
  17091. CoefficientByDJ = coefficientByDJ(di.VisitPNumber) // 示例调用
  17092. }));
  17093. }
  17094. #endregion
  17095. #region 酒店预订 New 2023-12-28 17:45
  17096. /// <summary>
  17097. /// 酒店预订
  17098. /// 酒店费用列表 根据团组Id查询
  17099. /// </summary>
  17100. /// <param name="_dto"></param>
  17101. /// <returns></returns>
  17102. [HttpPost]
  17103. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17104. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  17105. {
  17106. #region 参数验证
  17107. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17108. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17109. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  17110. #region 团组操作权限验证 76 酒店预定模块
  17111. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17112. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17113. #endregion
  17114. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17115. #region 页面操作权限验证
  17116. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17117. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  17118. #endregion
  17119. #endregion
  17120. return Ok(await _hotelPriceRep.ItemsByDiId(_dto.PortType, _dto.DiId));
  17121. }
  17122. /// <summary>
  17123. /// 酒店预订
  17124. /// 基础数据
  17125. /// </summary>
  17126. /// <param name="_dto"></param>
  17127. /// <returns></returns>
  17128. [HttpPost]
  17129. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17130. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  17131. {
  17132. #region 参数验证
  17133. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17134. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17135. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  17136. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17137. #region 页面操作权限验证
  17138. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17139. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  17140. #endregion
  17141. #region 团组操作权限验证 76 酒店预定模块
  17142. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17143. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17144. #endregion
  17145. #endregion
  17146. return Ok(await _hotelPriceRep.BasicsDataInit(_dto.PortType, _dto.DiId));
  17147. }
  17148. /// <summary>
  17149. /// 酒店预订
  17150. /// 创建 入住卷号码
  17151. /// </summary>
  17152. /// <param name="_dto"></param>
  17153. /// <returns></returns>
  17154. [HttpPost]
  17155. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17156. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  17157. {
  17158. #region 参数验证
  17159. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17160. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17161. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  17162. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17163. #region 页面操作权限验证
  17164. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17165. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  17166. #endregion
  17167. #region 团组操作权限验证 76 酒店预定模块
  17168. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17169. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17170. #endregion
  17171. #endregion
  17172. Result data = await _hotelPriceRep.CreateCheckVolumeNo(_dto.DiId);
  17173. if (data.Code != 0)
  17174. {
  17175. return Ok(JsonView(false, data.Msg));
  17176. }
  17177. return Ok(JsonView(true, data.Msg, data.Data));
  17178. }
  17179. /// <summary>
  17180. /// 酒店预订
  17181. /// 详情
  17182. /// </summary>
  17183. /// <param name="_dto"></param>
  17184. /// <returns></returns>
  17185. [HttpPost]
  17186. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17187. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  17188. {
  17189. #region 参数验证
  17190. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  17191. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17192. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  17193. #region 团组操作权限验证 76 酒店预定模块
  17194. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17195. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17196. #endregion
  17197. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17198. #region 页面操作权限验证
  17199. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17200. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  17201. #endregion
  17202. #endregion
  17203. return Ok(await _hotelPriceRep.Details(_dto.PortType, _dto.Id));
  17204. }
  17205. /// <summary>
  17206. /// 酒店预订
  17207. /// Add Or Edit
  17208. /// </summary>
  17209. /// <param name="_dto"></param>
  17210. /// <returns></returns>
  17211. [HttpPost]
  17212. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17213. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  17214. {
  17215. #region 参数验证
  17216. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17217. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17218. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  17219. #region 团组操作权限验证 76 酒店预定模块
  17220. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17221. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17222. #endregion
  17223. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17224. #region 页面操作权限验证
  17225. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17226. if (_dto.Id == 0) // Add
  17227. {
  17228. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  17229. }
  17230. else if (_dto.Id > 1) // Edit
  17231. {
  17232. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  17233. }
  17234. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  17235. #endregion
  17236. #endregion
  17237. JsonView _view = await _hotelPriceRep.AddOrEdit(_dto);
  17238. if (_view.Code != 200)
  17239. {
  17240. return Ok(_view);
  17241. }
  17242. #region 成本无酒店价格数据进入超支
  17243. _sqlSugar.BeginTran();
  17244. var start_Bool = DateTime.TryParse(_dto.CheckInDate, out DateTime start_Time);
  17245. var end_Bool = DateTime.TryParse(_dto.CheckOutDate, out DateTime end_Time);
  17246. var groupCost = _sqlSugar.Queryable<Grp_GroupCost>().Where(x => x.Diid == _dto.DiId && x.IsDel == 0).ToList();
  17247. for (int i = 0; i < groupCost.Count; i++)
  17248. {
  17249. if (groupCost[i].Date.IsNullOrWhiteSpace() && i != 0)
  17250. {
  17251. groupCost[i].Date = groupCost[i - 1].Date;
  17252. }
  17253. }
  17254. var groupCost_Grp = groupCost.GroupBy(x => x.Date).ToList();
  17255. List<Fin_GroupExtraCostDto_OP> extraCostList = new
  17256. List<Fin_GroupExtraCostDto_OP>();
  17257. if (start_Bool && end_Bool)
  17258. {
  17259. while (start_Time < end_Time)
  17260. {
  17261. foreach (var item in groupCost_Grp)
  17262. {
  17263. if (DateTime.TryParse(item.Key, out DateTime cost_Time))
  17264. {
  17265. if (DateTime.Compare(start_Time, cost_Time) == 0 && item.Sum(x => x.SGR + x.Suite + x.TBR + x.JS_ES) == 0)
  17266. {
  17267. extraCostList.Add(new
  17268. Fin_GroupExtraCostDto_OP
  17269. {
  17270. Area = _dto.AreaId,
  17271. coefficient = 1.5M,
  17272. createUser = _dto.UserId,
  17273. currency = _dto.CardPriceCurrency,
  17274. diId = _dto.DiId,
  17275. ManagerConfirm = 0,
  17276. SupervisorConfirm = 0,
  17277. SYsupervisorConfirm = 0,
  17278. editType = 1,
  17279. PortType = 1,
  17280. price = _dto.CardPrice,
  17281. PriceCount = 1,
  17282. priceType = 1027,
  17283. priceDetailType = 1044,
  17284. PriceDt = start_Time.ToString("yyyy-MM-dd"),
  17285. priceName = $"酒店超支费用-酒店导入-({start_Time.ToString("yyyy/MM/dd")})",
  17286. });
  17287. }
  17288. }
  17289. }
  17290. start_Time = start_Time.AddDays(1);
  17291. }
  17292. }
  17293. if (extraCostList.Any())
  17294. {
  17295. await _carTouristGuideGroundRep.GroupExtraCost_OperatorList(extraCostList);
  17296. }
  17297. _sqlSugar.CommitTran();
  17298. #endregion
  17299. #region 应用推送
  17300. try
  17301. {
  17302. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  17303. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  17304. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  17305. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  17306. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  17307. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  17308. var diId = _dto.DiId;
  17309. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  17310. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  17311. #region 操作记录
  17312. var opInfo = new Crm_TableOperationRecord()
  17313. {
  17314. TableName = "Grp_HotelReservations",
  17315. PortType = _dto.PortType,
  17316. DataId = hotelId,
  17317. CreateUserId = _dto.UserId
  17318. };
  17319. //var opStatus = OperationEnum.NoOperation;
  17320. if (_dto.Id < 1) //添加操作
  17321. {
  17322. opInfo.OperationItem = OperationEnum.Add;
  17323. }
  17324. else if (_dto.Id > 0)
  17325. {
  17326. opInfo.OperationItem = OperationEnum.Edit;
  17327. }
  17328. string opRemark = string.Empty;
  17329. if (ccpInfo != null)
  17330. {
  17331. // USD 1211.86、 CNY 8761.75、汇率:7.2300
  17332. var currency = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.Id == ccpInfo.PaymentCurrency).First()?.Name;
  17333. var cnyPrice = ccpInfo.PayMoney * ccpInfo.DayRate;
  17334. opRemark = $"{currency} {ccpInfo.PayMoney.ToString("#0.00")}、CNY {cnyPrice.ToString("#0.00")}、汇率:{ccpInfo.DayRate.ToString("#0.0000")}";
  17335. }
  17336. opInfo.Remark = opRemark;
  17337. await _tableorRep.AddAsync(opInfo);
  17338. #endregion
  17339. _logger.LogInformation($"【iOS推送通知Exception】Begin");
  17340. //2024-10-21 新增LZ UID
  17341. var userIds = new List<int>() { 21 };
  17342. string title = $"费用审核";
  17343. string content = "";
  17344. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  17345. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  17346. try
  17347. {
  17348. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "76" };
  17349. await APNsTools.iOS_PushNotifications1("051", title, "", content, true, "ExpenseAuditWebView", h5);
  17350. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】Start");
  17351. //var iosRes = await APNsTools.iOS_PushNotifications("051", title, "", content);
  17352. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】End Response:[{JsonConvert.SerializeObject(iosRes)}]");
  17353. }
  17354. catch (Exception ex)
  17355. {
  17356. Logs($"【iOS推送通知-PostHotelReservationsAddOrEdit-Exception】[{ex.Message}]");
  17357. }
  17358. }
  17359. catch (Exception ex)
  17360. {
  17361. Logs($"【iOS推送通知Exception】【{ex.Message}】");
  17362. }
  17363. try
  17364. {
  17365. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  17366. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  17367. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  17368. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  17369. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  17370. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  17371. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  17372. //自动审核
  17373. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  17374. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  17375. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  17376. //2024-10-21 新增LZ UID
  17377. var userIds = new List<int>() { 21 };
  17378. string title = $"系统通知";
  17379. var diId = _dto.DiId;
  17380. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  17381. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  17382. string content = "";
  17383. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  17384. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  17385. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  17386. }
  17387. catch (Exception ex)
  17388. {
  17389. }
  17390. #endregion
  17391. return Ok(_view);
  17392. }
  17393. /// <summary>
  17394. /// 酒店自动审核测试
  17395. /// Add Or Edit
  17396. /// </summary>
  17397. /// <param name="diid"></param>
  17398. /// <param name="dataId"></param>
  17399. /// <returns></returns>
  17400. [HttpPost]
  17401. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17402. public async Task<IActionResult> PostHotelAutoAuditTest(int diid, int dataId)
  17403. {
  17404. #region 应用推送
  17405. try
  17406. {
  17407. //自动审核
  17408. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  17409. }
  17410. catch (Exception ex)
  17411. {
  17412. return Ok(JsonView(false, ex.Message));
  17413. }
  17414. #endregion
  17415. return Ok(JsonView(false, "操作成功"));
  17416. }
  17417. /// <summary>
  17418. /// 酒店预订
  17419. /// Del
  17420. /// </summary>
  17421. /// <param name="_dto"></param>
  17422. /// <returns></returns>
  17423. [HttpPost]
  17424. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17425. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  17426. {
  17427. #region 参数验证
  17428. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17429. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17430. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  17431. #region 团组操作权限验证 76 酒店预定模块
  17432. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17433. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17434. #endregion
  17435. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17436. #region 页面操作权限验证
  17437. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17438. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  17439. #endregion
  17440. #endregion
  17441. var data = await _hotelPriceRep.Del(_dto.Id, _dto.UserId);
  17442. #region 操作记录
  17443. await _tableorRep.AddAsync(new Crm_TableOperationRecord()
  17444. {
  17445. TableName = "Grp_HotelReservations",
  17446. PortType = _dto.PortType,
  17447. OperationItem = OperationEnum.Del,
  17448. DataId = _dto.Id,
  17449. CreateUserId = _dto.UserId
  17450. });
  17451. #endregion
  17452. return Ok(data);
  17453. }
  17454. /// <summary>
  17455. /// 酒店预订
  17456. /// 生成VOUCHER
  17457. /// 2024.05.06 之前版本
  17458. /// </summary>
  17459. /// <param name="_dto"></param>
  17460. /// <returns></returns>
  17461. [HttpPost]
  17462. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17463. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  17464. {
  17465. try
  17466. {
  17467. #region 参数验证
  17468. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17469. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17470. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  17471. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  17472. #region 团组操作权限验证 76 酒店预定模块
  17473. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17474. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17475. #endregion
  17476. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17477. #region 页面操作权限验证
  17478. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17479. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  17480. #endregion
  17481. #endregion
  17482. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  17483. //判断数据是否完整
  17484. if (hr != null)
  17485. {
  17486. if (!string.IsNullOrEmpty(hr.DetermineNo))
  17487. {
  17488. string strFileName = "HotelStatement/";
  17489. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  17490. if (dele != null)
  17491. strFileName += dele.TourCode;
  17492. //载入模板
  17493. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  17494. Document doc = new Document(sss);
  17495. DocumentBuilder builder = new DocumentBuilder(doc);
  17496. #region 替换Word模板书签内容
  17497. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  17498. //入住卷预定号码
  17499. if (doc.Range.Bookmarks["VNO"] != null)
  17500. {
  17501. Bookmark mark = doc.Range.Bookmarks["VNO"];
  17502. mark.Text = hr.CheckNumber;
  17503. }
  17504. //酒店时间
  17505. if (doc.Range.Bookmarks["Date"] != null)
  17506. {
  17507. Bookmark mark = doc.Range.Bookmarks["Date"];
  17508. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  17509. }
  17510. //团号
  17511. if (doc.Range.Bookmarks["TNo"] != null)
  17512. {
  17513. Bookmark mark = doc.Range.Bookmarks["TNo"];
  17514. mark.Text = dele.TourCode;
  17515. }
  17516. //预定号码
  17517. if (doc.Range.Bookmarks["BookingId"] != null)
  17518. {
  17519. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  17520. mark.Text = hr.ReservationsNo;
  17521. }
  17522. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  17523. {
  17524. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  17525. mark.Text = hr.DetermineNo;
  17526. }
  17527. //酒店城市
  17528. if (doc.Range.Bookmarks["City"] != null)
  17529. {
  17530. Bookmark mark = doc.Range.Bookmarks["City"];
  17531. mark.Text = hr.City;
  17532. }
  17533. //酒店名称
  17534. if (doc.Range.Bookmarks["HName"] != null)
  17535. {
  17536. Bookmark mark = doc.Range.Bookmarks["HName"];
  17537. mark.Text = hr.HotelName;
  17538. }
  17539. //酒店地址
  17540. if (doc.Range.Bookmarks["Address"] != null)
  17541. {
  17542. Bookmark mark = doc.Range.Bookmarks["Address"];
  17543. mark.Text = hr.HotelAddress;
  17544. }
  17545. //酒店电话
  17546. if (doc.Range.Bookmarks["Tel"] != null)
  17547. {
  17548. Bookmark mark = doc.Range.Bookmarks["Tel"];
  17549. mark.Text = hr.HotelTel;
  17550. }
  17551. //酒店传真
  17552. if (doc.Range.Bookmarks["Fax"] != null)
  17553. {
  17554. Bookmark mark = doc.Range.Bookmarks["Fax"];
  17555. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  17556. {
  17557. mark.Text = hr.HotelFax;
  17558. }
  17559. }
  17560. //入住时间
  17561. if (doc.Range.Bookmarks["CIn"] != null)
  17562. {
  17563. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  17564. Bookmark mark = doc.Range.Bookmarks["CIn"];
  17565. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  17566. }
  17567. //退房时间
  17568. if (doc.Range.Bookmarks["COut"] != null)
  17569. {
  17570. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  17571. Bookmark mark = doc.Range.Bookmarks["COut"];
  17572. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  17573. }
  17574. //客户名称
  17575. if (doc.Range.Bookmarks["GName"] != null)
  17576. {
  17577. string guestName = "";
  17578. string[] clients = Array.Empty<string>();
  17579. if (hr.GuestName.Contains(","))
  17580. {
  17581. clients = hr.GuestName.Split(",");
  17582. }
  17583. else
  17584. {
  17585. clients = new string[] { hr.GuestName };
  17586. }
  17587. List<int> clientIds_int = new List<int>();
  17588. if (clients.Length > 0)
  17589. {
  17590. foreach (var item in clients)
  17591. {
  17592. if (item.IsNumeric())
  17593. {
  17594. clientIds_int.Add(int.Parse(item));
  17595. }
  17596. }
  17597. }
  17598. if (clientIds_int.Count > 0)
  17599. {
  17600. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  17601. foreach (var client in _clientDatas)
  17602. {
  17603. //男
  17604. if (client.Sex == 0) guestName += $"Mr.";
  17605. //女
  17606. else if (client.Sex == 1) guestName += $"Ms.";
  17607. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  17608. {
  17609. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  17610. }
  17611. //guestName += $"{client.Pinyin},";
  17612. }
  17613. if (guestName.Length > 0)
  17614. {
  17615. guestName = guestName.Substring(0, guestName.Length - 1);
  17616. }
  17617. }
  17618. else
  17619. {
  17620. guestName = hr.GuestName;
  17621. }
  17622. Bookmark mark = doc.Range.Bookmarks["GName"];
  17623. mark.Text = guestName;
  17624. }
  17625. //房间介绍
  17626. if (doc.Range.Bookmarks["ROOM"] != null)
  17627. {
  17628. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  17629. mark.Text = hr.RoomExplanation;
  17630. }
  17631. //报价描述
  17632. if (doc.Range.Bookmarks["NOTE"] != null)
  17633. {
  17634. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  17635. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  17636. if (ss != null)
  17637. mark.Text = ss.Name;
  17638. }
  17639. //入住时间
  17640. if (doc.Range.Bookmarks["CheckIn"] != null)
  17641. {
  17642. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  17643. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  17644. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  17645. }
  17646. //退房时间
  17647. if (doc.Range.Bookmarks["CheckOut"] != null)
  17648. {
  17649. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  17650. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  17651. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  17652. }
  17653. //日期
  17654. if (doc.Range.Bookmarks["DT"] != null)
  17655. {
  17656. Bookmark mark = doc.Range.Bookmarks["DT"];
  17657. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  17658. }
  17659. //名称
  17660. if (doc.Range.Bookmarks["VName"] != null)
  17661. {
  17662. Bookmark mark = doc.Range.Bookmarks["VName"];
  17663. mark.Text = hr.HotelName;
  17664. }
  17665. //号码
  17666. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  17667. {
  17668. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  17669. mark.Text = hr.CheckNumber;
  17670. }
  17671. #endregion
  17672. strFileName += "VOUCHER.doc";
  17673. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  17674. doc.Save(fileDir);
  17675. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  17676. return Ok(JsonView(true, "操作成功!", Url));
  17677. }
  17678. else
  17679. {
  17680. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  17681. }
  17682. }
  17683. else
  17684. {
  17685. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  17686. }
  17687. }
  17688. catch (Exception ex)
  17689. {
  17690. return Ok(JsonView(false, ex.Message));
  17691. }
  17692. }
  17693. /// <summary>
  17694. /// 酒店预订
  17695. /// 生成VOUCHER
  17696. /// 2024.05.06 之后版本
  17697. /// </summary>
  17698. /// <param name="_dto"></param>
  17699. /// <returns></returns>
  17700. [HttpPost]
  17701. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17702. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  17703. {
  17704. #region 参数验证
  17705. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  17706. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17707. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  17708. #region 团组操作权限验证 76 酒店预定模块
  17709. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17710. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  17711. #endregion
  17712. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17713. #region 页面操作权限验证
  17714. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17715. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  17716. #endregion
  17717. #endregion
  17718. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  17719. //判断数据是否完整
  17720. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  17721. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  17722. string strFileName = "HotelStatement/";
  17723. string guestNames = ""; //格式Mr.xxx Ms.xxx
  17724. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  17725. #region 数据处理
  17726. List<int> guestIds = new List<int>();
  17727. //int index = 0;
  17728. foreach (var item in hrDtas)
  17729. {
  17730. if (item.GuestName.Contains(","))
  17731. {
  17732. string[] guestIdArr = item.GuestName.Split(',');
  17733. foreach (var guestIdStr in guestIdArr)
  17734. {
  17735. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  17736. if (guestBool)
  17737. {
  17738. guestIds.Add(guestId);
  17739. }
  17740. }
  17741. }
  17742. else guestNames += item.GuestName;
  17743. var voucherInfo = new HotelVoucherInfoView()
  17744. {
  17745. HotelName = item.HotelName,
  17746. CheckInDate = item.CheckInDate,
  17747. CheckOutDate = item.CheckOutDate,
  17748. ConfirmationNumber = item.DetermineNo.Trim(),
  17749. RoomType = item.RoomExplanation
  17750. };
  17751. vouchers.Add(voucherInfo);
  17752. }
  17753. if (guestIds.Count > 0)
  17754. {
  17755. guestIds = guestIds.Distinct().ToList();
  17756. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  17757. if (guestDatas.Count > 0)
  17758. {
  17759. guestNames = "";
  17760. foreach (var guest in guestDatas)
  17761. {
  17762. string guestName = "";
  17763. if (guest.Sex == 0) guestName += @"MR.";
  17764. else if (guest.Sex == 1) guestName += @"MS.";
  17765. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  17766. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  17767. guestNames += @$"{guestName.Trim()}、";
  17768. }
  17769. if (guestNames.Length > 0)
  17770. {
  17771. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  17772. }
  17773. }
  17774. }
  17775. #endregion
  17776. //载入模板
  17777. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  17778. Document doc = new Document(sss);
  17779. DocumentBuilder builder = new DocumentBuilder(doc);
  17780. if (doc.Range.Bookmarks["GuestName"] != null)
  17781. {
  17782. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  17783. mark.Text = guestNames;
  17784. }
  17785. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  17786. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  17787. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  17788. for (int i = 1; i <= vouchers.Count; i++)
  17789. {
  17790. HotelVoucherInfoView hviv = vouchers[i - 1];
  17791. builder.MoveToCell(0, i, 0, 0);
  17792. builder.Write(hviv.HotelName);
  17793. builder.MoveToCell(0, i, 1, 0);
  17794. builder.Write(hviv.CheckInDate);
  17795. builder.MoveToCell(0, i, 2, 0);
  17796. builder.Write(hviv.CheckOutDate);
  17797. builder.MoveToCell(0, i, 3, 0);
  17798. builder.Write(hviv.RoomType);
  17799. builder.MoveToCell(0, i, 4, 0);
  17800. builder.Write(hviv.ConfirmationNumber);
  17801. }
  17802. //删除多余行
  17803. int currRowIndex = vouchers.Count + 1;
  17804. int delRows = 21 - currRowIndex;
  17805. if (delRows > 0)
  17806. {
  17807. for (int i = 0; i < delRows; i++)
  17808. {
  17809. table.Rows.RemoveAt(currRowIndex);
  17810. //cultivateRowIndex++;
  17811. }
  17812. }
  17813. strFileName += "VOUCHER.docx";
  17814. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  17815. doc.Save(fileDir);
  17816. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  17817. return Ok(JsonView(true, "操作成功!", Url));
  17818. }
  17819. /// <summary>
  17820. /// 酒店预订
  17821. /// 生成VOUCHER 批量生成
  17822. /// New
  17823. /// </summary>
  17824. /// <param name="_dto"></param>
  17825. /// <returns></returns>
  17826. [HttpPost]
  17827. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17828. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  17829. {
  17830. #region 参数验证
  17831. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  17832. if (_dto.PageId < 1) _dto.PageId = 28;
  17833. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  17834. #region 团组操作权限验证 76 酒店预定模块
  17835. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17836. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  17837. #endregion
  17838. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17839. #region 页面操作权限验证
  17840. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17841. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  17842. #endregion
  17843. #endregion
  17844. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  17845. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  17846. .OrderBy(x => x.CheckInDate)
  17847. .ToListAsync();
  17848. //判断数据是否完整
  17849. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  17850. string strFileName = "HotelStatement/";
  17851. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  17852. if (dele != null)
  17853. strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
  17854. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>()
  17855. .Select(x => new Crm_DeleClient { Id = x.Id, FirstName = x.FirstName, LastName = x.LastName, Pinyin = x.Pinyin })
  17856. .Where(it => it.IsDel == 0)
  17857. .ToListAsync();
  17858. foreach (var item in guestDatas) EncryptionProcessor.DecryptProperties(item);
  17859. for (int i = 0; i < hrDtas.Count; i++)
  17860. {
  17861. string guestNames = string.Empty;
  17862. List<int> guestIds = new List<int>();
  17863. var item = hrDtas[i];
  17864. //处理客户姓名
  17865. if (item.GuestName.Contains(","))
  17866. {
  17867. string[] guestIdArr = item.GuestName.Split(',');
  17868. foreach (var guestIdStr in guestIdArr)
  17869. if (int.TryParse(guestIdStr, out int guestId))
  17870. guestIds.Add(guestId);
  17871. }
  17872. else
  17873. {
  17874. bool guestIdBool = int.TryParse(item.GuestName, out int guestId);
  17875. if (guestIdBool)
  17876. {
  17877. guestIds.Add(guestId);
  17878. }
  17879. //NaN
  17880. if (item.GuestName.Contains("NaN"))
  17881. {
  17882. guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
  17883. }
  17884. }
  17885. if (guestIds.Count > 0)
  17886. {
  17887. guestIds = guestIds.Distinct().ToList();
  17888. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  17889. if (guestDatas1.Count > 0)
  17890. {
  17891. guestNames = "";
  17892. foreach (var guest in guestDatas1)
  17893. {
  17894. string guestName = "";
  17895. if (guest.Sex == 0) guestName += @"MR.";
  17896. else if (guest.Sex == 1) guestName += @"MS.";
  17897. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  17898. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  17899. guestNames += @$"{guestName.Trim()}、";
  17900. }
  17901. if (guestNames.Length > 0)
  17902. {
  17903. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  17904. }
  17905. }
  17906. }
  17907. //if (!string.IsNullOrEmpty(guestNames))
  17908. //{
  17909. hrDtas[i].GuestName = guestNames;
  17910. //}
  17911. }
  17912. strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  17913. Document doc = new Document();
  17914. DocumentBuilder builder = new DocumentBuilder(doc);
  17915. try
  17916. {
  17917. builder.MoveToDocumentStart();
  17918. foreach (var item in hrDtas)
  17919. {
  17920. //标题
  17921. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  17922. builder.ParagraphFormat.LineSpacing = 1;
  17923. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17924. builder.ParagraphFormat.Style.Font.Size = 9;
  17925. builder.ParagraphFormat.Style.Font.Bold = true;
  17926. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  17927. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  17928. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  17929. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  17930. builder.ParagraphFormat.LineSpacing = 1;
  17931. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17932. builder.ParagraphFormat.Style.Font.Size = 9;
  17933. builder.ParagraphFormat.Style.Font.Bold = true;
  17934. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  17935. builder.StartTable();
  17936. // 设置边框颜色
  17937. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  17938. //设置边框样式
  17939. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
  17940. //表格
  17941. #region 第一行
  17942. builder.InsertCell();
  17943. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17944. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17945. //builder.CellFormat.AllowAutoFit = false;
  17946. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17947. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17948. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17949. builder.CellFormat.WrapText = true; //自动换行
  17950. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17951. builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
  17952. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17953. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17954. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17955. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17956. builder.Write("TOUR NO:");
  17957. builder.InsertCell();
  17958. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17959. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17960. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17961. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17962. builder.ParagraphFormat.Style.Font.Bold = false;
  17963. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17964. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17965. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17966. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17967. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17968. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17969. builder.Write($"{dele?.TourCode ?? "-"}");
  17970. builder.InsertCell();
  17971. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17972. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17973. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17974. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17975. builder.ParagraphFormat.Style.Font.Bold = false;
  17976. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17977. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17978. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17979. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17980. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17981. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17982. builder.Write($"CITY:");
  17983. builder.InsertCell();
  17984. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17985. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17986. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17987. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17988. builder.ParagraphFormat.Style.Font.Bold = false;
  17989. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17990. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17991. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17992. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17993. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17994. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17995. builder.Write($"{item.City}");
  17996. builder.EndRow();
  17997. #endregion
  17998. #region 第二行
  17999. builder.InsertCell();
  18000. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18001. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18002. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18003. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18004. builder.ParagraphFormat.Style.Font.Bold = false;
  18005. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18006. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18007. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18008. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18009. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18010. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18011. builder.Write("CONFIRMATION NO:");
  18012. builder.InsertCell();
  18013. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18014. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18015. builder.ParagraphFormat.Style.Font.Size = 8;
  18016. builder.ParagraphFormat.Style.Font.Bold = false;
  18017. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18018. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18019. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18020. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18021. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18022. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18023. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18024. builder.CellFormat.HorizontalMerge = CellMerge.First;
  18025. builder.Write($"{item.DetermineNo}");
  18026. builder.InsertCell();
  18027. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18028. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18029. builder.InsertCell();
  18030. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18031. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18032. builder.EndRow();
  18033. #endregion
  18034. #region 第三行
  18035. builder.InsertCell();
  18036. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18037. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18038. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18039. builder.ParagraphFormat.Style.Font.Bold = false;
  18040. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18041. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18042. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18043. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18044. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18045. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18046. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18047. builder.Write($"HOTEL NAME:");
  18048. builder.InsertCell();
  18049. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18050. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18051. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18052. builder.ParagraphFormat.Style.Font.Bold = false;
  18053. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18054. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18055. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18056. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18057. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18058. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18059. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18060. builder.CellFormat.HorizontalMerge = CellMerge.First;
  18061. builder.Write($"{item.HotelName}");
  18062. builder.InsertCell();
  18063. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18064. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18065. builder.InsertCell();
  18066. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18067. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18068. builder.EndRow();
  18069. #endregion
  18070. #region 第四行
  18071. builder.InsertCell();
  18072. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18073. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18074. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18075. builder.ParagraphFormat.Style.Font.Bold = false;
  18076. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18077. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18078. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18079. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18080. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18081. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18082. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18083. builder.Write($"HOTEL ADDRESS:");
  18084. builder.InsertCell();
  18085. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18086. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18087. builder.ParagraphFormat.Style.Font.Size = 8;
  18088. builder.ParagraphFormat.Style.Font.Bold = false;
  18089. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18090. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18091. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18092. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18093. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18094. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18095. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18096. builder.CellFormat.HorizontalMerge = CellMerge.First;
  18097. builder.Write($"{item.HotelAddress}");
  18098. builder.InsertCell();
  18099. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18100. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18101. builder.InsertCell();
  18102. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18103. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18104. builder.EndRow();
  18105. #endregion
  18106. #region 第五行
  18107. builder.InsertCell();
  18108. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18109. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18110. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18111. builder.ParagraphFormat.Style.Font.Bold = false;
  18112. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18113. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18114. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18115. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18116. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18117. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18118. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18119. builder.Write("TEL:");
  18120. builder.InsertCell();
  18121. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18122. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18123. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18124. builder.ParagraphFormat.Style.Font.Bold = false;
  18125. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18126. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18127. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18128. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18129. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18130. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18131. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18132. builder.Write($"{item.HotelTel}");
  18133. builder.InsertCell();
  18134. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18135. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18136. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18137. builder.ParagraphFormat.Style.Font.Bold = false;
  18138. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18139. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18140. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18141. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18142. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18143. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18144. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18145. builder.Write($"FAX:");
  18146. builder.InsertCell();
  18147. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18148. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18149. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18150. builder.ParagraphFormat.Style.Font.Bold = false;
  18151. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18152. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18153. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18154. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18155. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18156. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18157. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18158. builder.Write($"{item.HotelFax}");
  18159. builder.EndRow();
  18160. #endregion
  18161. #region 第六行
  18162. builder.InsertCell();
  18163. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18164. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18165. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18166. builder.ParagraphFormat.Style.Font.Bold = false;
  18167. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18168. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18169. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18170. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18171. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18172. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18173. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18174. builder.Write("CHECK IN:");
  18175. builder.InsertCell();
  18176. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18177. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18178. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18179. builder.ParagraphFormat.Style.Font.Bold = false;
  18180. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18181. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18182. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18183. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18184. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18185. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18186. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18187. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  18188. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  18189. builder.Write($"{checkInStr}");
  18190. builder.InsertCell();
  18191. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18192. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18193. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18194. builder.ParagraphFormat.Style.Font.Bold = false;
  18195. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18196. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18197. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18198. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18199. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18200. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18201. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18202. builder.Write($"CHECK OUT:");
  18203. builder.InsertCell();
  18204. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18205. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18206. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18207. builder.ParagraphFormat.Style.Font.Bold = false;
  18208. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18209. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18210. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18211. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18212. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18213. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18214. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18215. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  18216. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  18217. builder.Write($"{checkOutStr}");
  18218. builder.EndRow();
  18219. #endregion
  18220. #region 第七行
  18221. builder.InsertCell();
  18222. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18223. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18224. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18225. builder.ParagraphFormat.Style.Font.Bold = false;
  18226. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18227. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18228. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18229. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18230. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18231. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18232. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18233. builder.Write($"GUEST NAME:");
  18234. builder.InsertCell();
  18235. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18236. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18237. builder.ParagraphFormat.Style.Font.Size = 8;
  18238. builder.ParagraphFormat.Style.Font.Bold = false;
  18239. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18240. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18241. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18242. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18243. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18244. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18245. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18246. builder.CellFormat.HorizontalMerge = CellMerge.First;
  18247. builder.Write($"{item.GuestName.Trim()}");
  18248. builder.InsertCell();
  18249. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18250. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18251. builder.InsertCell();
  18252. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18253. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18254. builder.EndRow();
  18255. #endregion
  18256. #region 第八行
  18257. builder.InsertCell();
  18258. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18259. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18260. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18261. builder.ParagraphFormat.Style.Font.Bold = false;
  18262. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18263. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18264. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18265. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18266. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18267. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18268. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18269. builder.Write($"ROOM TYPE:");
  18270. builder.InsertCell();
  18271. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18272. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18273. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18274. builder.ParagraphFormat.Style.Font.Bold = false;
  18275. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18276. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18277. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18278. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18279. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18280. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18281. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18282. builder.CellFormat.HorizontalMerge = CellMerge.First;
  18283. builder.Write($"{item.RoomExplanation}");
  18284. builder.InsertCell();
  18285. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18286. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18287. builder.InsertCell();
  18288. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18289. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18290. builder.EndRow();
  18291. #endregion
  18292. #region 第九行
  18293. builder.InsertCell();
  18294. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18295. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18296. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18297. builder.ParagraphFormat.Style.Font.Bold = false;
  18298. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18299. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18300. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18301. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18302. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18303. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18304. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18305. builder.Write($"NOTE:");
  18306. builder.InsertCell();
  18307. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18308. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18309. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18310. builder.ParagraphFormat.Style.Font.Bold = false;
  18311. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18312. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18313. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18314. builder.CellFormat.HorizontalMerge = CellMerge.First;
  18315. 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.");
  18316. builder.InsertCell();
  18317. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18318. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18319. builder.InsertCell();
  18320. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18321. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18322. builder.EndRow();
  18323. #endregion
  18324. builder.EndTable();
  18325. //换行
  18326. builder.Writeln("");
  18327. builder.Writeln("");
  18328. }
  18329. #region 获取文档中的所有表格 设置文字自适应
  18330. // 获取文档中的所有表格。
  18331. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  18332. {
  18333. // 遍历表格中的所有行。
  18334. foreach (Aspose.Words.Tables.Row row in table.Rows)
  18335. {
  18336. foreach (Cell cell in row.Cells)
  18337. {
  18338. Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
  18339. cellFormat.Width = 0;
  18340. }
  18341. }
  18342. }
  18343. #endregion
  18344. #region 设置页眉
  18345. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  18346. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  18347. if (System.IO.File.Exists(voucherHeaderPath))
  18348. {
  18349. byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
  18350. //Image image = Image.FromStream(imageBytes, ImageType.Png);
  18351. //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
  18352. Aspose.Words.Drawing.Shape shape = builder.InsertImage(imageBytes);
  18353. // 调整图片位置
  18354. shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
  18355. shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
  18356. shape.Top = 50; // 将图片距离页眉上边缘的距离
  18357. shape.Left = 0; // 将图片距离页面左边缘的距离
  18358. shape.Width = 81; // 设置图片宽度
  18359. shape.Height = 36; // 设置图片高度
  18360. }
  18361. //靠右
  18362. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  18363. //// 设置页脚上下边距
  18364. //builder.PageSetup.HeaderDistance = 42;
  18365. // 添加页眉线
  18366. Aspose.Words.Border borderHeader = null;
  18367. try
  18368. {
  18369. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  18370. }
  18371. catch (Exception e)
  18372. {
  18373. // TODO Auto-generated catch block
  18374. //e.printStackTrace();
  18375. }
  18376. borderHeader.Shadow = true;
  18377. borderHeader.DistanceFromText = 2;
  18378. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  18379. #endregion
  18380. }
  18381. catch (Exception ex)
  18382. {
  18383. }
  18384. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  18385. doc.Save(fileDir);
  18386. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  18387. return Ok(JsonView(true, "操作成功!", Url));
  18388. }
  18389. /// <summary>
  18390. /// 酒店预订
  18391. /// 生成 预定成本 Excel
  18392. /// </summary>
  18393. /// <param name="_dto"></param>
  18394. /// <returns></returns>
  18395. [HttpPost]
  18396. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18397. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  18398. {
  18399. #region 参数验证
  18400. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  18401. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  18402. if (!vadalitorRes.IsValid)
  18403. {
  18404. var errors = new StringBuilder();
  18405. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  18406. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  18407. }
  18408. #region 团组操作权限验证 76 酒店预定模块
  18409. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18410. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  18411. #endregion
  18412. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18413. #region 页面操作权限验证
  18414. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18415. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  18416. #endregion
  18417. #endregion
  18418. decimal _rate = 1.00M;
  18419. string _currency = string.Empty;
  18420. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  18421. var hrDtas = _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  18422. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  18423. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  18424. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  18425. var _GroupCostParameter = _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).First();
  18426. //if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  18427. if (_GroupCostParameter == null)
  18428. {
  18429. //return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  18430. bool isIntType = int.TryParse(_currency, out int currId);
  18431. if (isIntType)
  18432. {
  18433. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  18434. }
  18435. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  18436. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  18437. if (currInfo == null)
  18438. {
  18439. //return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  18440. }
  18441. else _rate = currInfo.Rate;
  18442. if (!string.IsNullOrEmpty(_currency) && !_currency.ToUpper().Equals("CNY"))
  18443. {
  18444. _rate = _GroupCostParameter.Rate;
  18445. }
  18446. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  18447. //string strFileName = "HotelStatement/";
  18448. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  18449. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  18450. var rateDatas = new List<dynamic>();
  18451. #region 数据处理
  18452. foreach (var item in hrDtas)
  18453. {
  18454. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  18455. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  18456. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  18457. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  18458. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  18459. if (ccpInfo == null || roomInfo == null || breakfastInfo == null || governmentRentInfo == null || cityTaxInfo == null)
  18460. {
  18461. continue;
  18462. }
  18463. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  18464. if (string.IsNullOrEmpty(_currency)) _currency = $"CNY";
  18465. string singleRoomFeeStr = string.Empty,
  18466. doubleRoomFeeStr = string.Empty,
  18467. suiteRoomFeeStr = string.Empty,
  18468. otherRoomFeeStr = string.Empty,
  18469. payMoneyStr = string.Empty,
  18470. cardPriceStr = string.Empty;
  18471. if (roomCurr.Equals("CNY"))
  18472. {
  18473. rateDatas.Add(new { code = "CNY", rate = 1.0000 });
  18474. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  18475. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  18476. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  18477. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  18478. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? ""}";
  18479. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {currDatas.Find(it => it.Id == item.CardPriceCurrency)?.Name ?? ""}";
  18480. }
  18481. else
  18482. {
  18483. //singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  18484. //doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  18485. //suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  18486. //otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  18487. //payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  18488. //cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  18489. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  18490. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  18491. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  18492. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  18493. rateDatas.Add(new { code = roomCurr, rate = roomInfo.Rate });
  18494. var ccpPaymentCurrency = currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? "";
  18495. if (ccpPaymentCurrency.Equals("CNY"))
  18496. {
  18497. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} CNY";
  18498. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  18499. }
  18500. else
  18501. {
  18502. rateDatas.Add(new { code = ccpPaymentCurrency, rate = ccpInfo.DayRate });
  18503. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {ccpPaymentCurrency}\r\n{((ccpInfo.PayMoney * ccpInfo.DayRate) / _rate).ToString("#0.00")} CNY";
  18504. }
  18505. var hotelcardPriceCurrency = currDatas.Find(it => it.Id == item?.CardPriceCurrency)?.Name ?? "";
  18506. if (hotelcardPriceCurrency.Equals("CNY"))
  18507. {
  18508. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  18509. }
  18510. else
  18511. {
  18512. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {hotelcardPriceCurrency}\r\n{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} CNY";
  18513. }
  18514. }
  18515. string breakfastPriceStr = string.Empty,
  18516. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  18517. governmentRentStr = string.Empty,
  18518. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  18519. cityTaxStr = string.Empty,
  18520. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  18521. var breakfastCurrency1 = currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name;
  18522. if (!string.IsNullOrEmpty(breakfastCurrency1))
  18523. {
  18524. if (breakfastCurrency1.Equals("CNY"))
  18525. {
  18526. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  18527. }
  18528. else
  18529. {
  18530. rateDatas.Add(new { code = breakfastCurrency1, rate = breakfastInfo.Rate });
  18531. var breakfastPriceCny = breakfastInfo.Price * breakfastInfo.Rate;
  18532. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}\r\n{breakfastPriceCny.ToString("#0.00")} CNY";
  18533. }
  18534. }
  18535. else breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  18536. var governmentRentCurrency1 = currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name;
  18537. if (!string.IsNullOrEmpty(governmentRentCurrency1))
  18538. {
  18539. if (governmentRentCurrency.Equals("CNY"))
  18540. {
  18541. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  18542. }
  18543. else
  18544. {
  18545. rateDatas.Add(new { code = governmentRentCurrency1, rate = governmentRentInfo.Rate });
  18546. var governmentRentCny = governmentRentInfo.Price * governmentRentInfo.Rate;
  18547. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}\r\n{governmentRentCny.ToString("#0.00")} CNY";
  18548. }
  18549. }
  18550. else governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  18551. var cityTaxStrCurrency1 = currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name;
  18552. if (!string.IsNullOrEmpty(cityTaxStrCurrency1))
  18553. {
  18554. if (cityTaxStrCurrency1.Equals("CNY"))
  18555. {
  18556. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  18557. }
  18558. else
  18559. {
  18560. rateDatas.Add(new { code = cityTaxStrCurrency1, rate = cityTaxInfo.Rate });
  18561. var cityTaxCny = cityTaxInfo.Price * cityTaxInfo.Rate;
  18562. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}\r\n{cityTaxCny.ToString("#0.00")} CNY";
  18563. }
  18564. }
  18565. else cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  18566. int payDId = roomInfo?.PayDId ?? 0;
  18567. pcfds.Add(new HotelReservations_PCFD_View()
  18568. {
  18569. City = item.City,
  18570. HotelName = item.HotelName,
  18571. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  18572. // SingleRoomCount = item.SingleRoomCount,
  18573. SingleRoomPrice = singleRoomFeeStr,
  18574. // DoubleRoomCount = item.DoubleRoomCount,
  18575. DoubleRoomPrice = doubleRoomFeeStr,
  18576. //SuiteRoomCount = item.SuiteRoomCount,
  18577. SuiteRoomPrice = suiteRoomFeeStr,
  18578. OtherRoomPrice = otherRoomFeeStr,
  18579. //OtherRoomCount = item.OtherRoomCount,
  18580. BreakfastPrice = breakfastPriceStr,
  18581. GovernmentRent = governmentRentStr,
  18582. CityTax = cityTaxStr,
  18583. RoomExplanation = item.RoomExplanation,
  18584. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  18585. PayTime = roomInfo?.ConsumptionDate,
  18586. BankNo = roomInfo?.BankNo,
  18587. PayMoney = payMoneyStr,
  18588. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  18589. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  18590. CardPrice = cardPriceStr,
  18591. Remark = ccpInfo.Remark
  18592. });
  18593. }
  18594. #endregion
  18595. //载入模板
  18596. WorkbookDesigner designer = new WorkbookDesigner();
  18597. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  18598. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  18599. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  18600. designer.SetDataSource("TourNo", groupInfo.TourCode);
  18601. var rateDatas1 = rateDatas.Distinct();
  18602. var rateStr = string.Empty;
  18603. foreach (var item in rateDatas1)
  18604. {
  18605. rateStr += $"{item.code} {item.rate.ToString("#0.0000")} \t\t";
  18606. }
  18607. designer.SetDataSource("TeamName", $"酒店模块汇率:{rateStr}");
  18608. designer.SetDataSource("Opertor", userInfo.CnName);
  18609. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  18610. dt.TableName = "ViewMyHotelReservations";
  18611. designer.SetDataSource(dt);
  18612. designer.Process();
  18613. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  18614. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  18615. designer.Workbook.Save(serverPath);
  18616. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  18617. #region 删除指定行
  18618. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  18619. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  18620. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  18621. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  18622. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  18623. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  18624. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  18625. cssIndex = dt.Columns["CityTax"].Ordinal,
  18626. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  18627. remarkIndex = dt.Columns["Remark"].Ordinal;
  18628. //删除指定列
  18629. foreach (DataRow item in dt.Rows)
  18630. {
  18631. string singleStr = item["SingleRoomPrice"].ToString();
  18632. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  18633. if (containsDigitButNotZero1) singleDel = false;
  18634. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  18635. string doubleStr = item["DoubleRoomPrice"].ToString();
  18636. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  18637. if (containsDigitButNotZero2) doubleDel = false;
  18638. string suiteStr = item["SuiteRoomPrice"].ToString();
  18639. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  18640. if (containsDigitButNotZero3) suiteDel = false;
  18641. string otherStr = item["OtherRoomPrice"].ToString();
  18642. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  18643. if (containsDigitButNotZero4) otherDel = false;
  18644. string zcStr = item["BreakfastPrice"].ToString();
  18645. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  18646. if (containsDigitButNotZero5) zcDel = false;
  18647. string dsStr = item["GovernmentRent"].ToString();
  18648. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  18649. if (containsDigitButNotZero6) dsDel = false;
  18650. string cssStr = item["CityTax"].ToString();
  18651. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  18652. if (containsDigitButNotZero7) cssDel = false;
  18653. string cpStr = item["ConsumptionPatterns"].ToString();
  18654. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  18655. string remarkStr = item["Remark"].ToString();
  18656. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  18657. }
  18658. DeleteColumn(serverPath, remarkIndex, remarkDel);
  18659. DeleteColumn(serverPath, cpIndex, cpDel);
  18660. DeleteColumn(serverPath, dsIndex, dsDel);
  18661. DeleteColumn(serverPath, cssIndex, cssDel);
  18662. DeleteColumn(serverPath, zcIndex, zcDel);
  18663. DeleteColumn(serverPath, otherIndex, otherDel);
  18664. DeleteColumn(serverPath, suiteIndex, suiteDel);
  18665. DeleteColumn(serverPath, doubleIndex, doubleDel);
  18666. DeleteColumn(serverPath, singleIndex, singleDel);
  18667. #endregion
  18668. //只保留第一个表格
  18669. DeleteSheet(serverPath);
  18670. return Ok(JsonView(true, "操作成功", url = rst));
  18671. }
  18672. else
  18673. {
  18674. _currency = _GroupCostParameter.Currency;
  18675. bool isIntType = int.TryParse(_currency, out int currId);
  18676. if (isIntType)
  18677. {
  18678. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  18679. }
  18680. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  18681. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  18682. if (currInfo == null)
  18683. {
  18684. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  18685. }
  18686. if (!_currency.ToUpper().Equals("CNY"))
  18687. {
  18688. _rate = _GroupCostParameter.Rate;
  18689. }
  18690. _rate = currInfo.Rate;
  18691. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  18692. //string strFileName = "HotelStatement/";
  18693. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  18694. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  18695. #region 数据处理
  18696. foreach (var item in hrDtas)
  18697. {
  18698. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  18699. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  18700. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  18701. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  18702. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  18703. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  18704. string singleRoomFeeStr = string.Empty,
  18705. doubleRoomFeeStr = string.Empty,
  18706. suiteRoomFeeStr = string.Empty,
  18707. otherRoomFeeStr = string.Empty,
  18708. payMoneyStr = string.Empty,
  18709. cardPriceStr = string.Empty;
  18710. if (roomCurr.Equals(_currency))
  18711. {
  18712. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  18713. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  18714. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  18715. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  18716. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  18717. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  18718. }
  18719. else
  18720. {
  18721. singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  18722. doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  18723. suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  18724. otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  18725. payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  18726. cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  18727. }
  18728. string breakfastPriceStr = string.Empty,
  18729. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  18730. governmentRentStr = string.Empty,
  18731. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  18732. cityTaxStrStr = string.Empty,
  18733. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  18734. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  18735. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  18736. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  18737. int payDId = roomInfo?.PayDId ?? 0;
  18738. pcfds.Add(new HotelReservations_PCFD_View()
  18739. {
  18740. City = item.City,
  18741. HotelName = item.HotelName,
  18742. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  18743. // SingleRoomCount = item.SingleRoomCount,
  18744. SingleRoomPrice = singleRoomFeeStr,
  18745. // DoubleRoomCount = item.DoubleRoomCount,
  18746. DoubleRoomPrice = doubleRoomFeeStr,
  18747. //SuiteRoomCount = item.SuiteRoomCount,
  18748. SuiteRoomPrice = suiteRoomFeeStr,
  18749. OtherRoomPrice = otherRoomFeeStr,
  18750. //OtherRoomCount = item.OtherRoomCount,
  18751. BreakfastPrice = breakfastPriceStr,
  18752. GovernmentRent = governmentRentStr,
  18753. CityTax = cityTaxStrStr,
  18754. RoomExplanation = item.RoomExplanation,
  18755. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  18756. PayTime = roomInfo?.ConsumptionDate,
  18757. BankNo = roomInfo?.BankNo,
  18758. PayMoney = payMoneyStr,
  18759. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  18760. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  18761. CardPrice = cardPriceStr,
  18762. Remark = ccpInfo.Remark
  18763. });
  18764. }
  18765. #endregion
  18766. //载入模板
  18767. WorkbookDesigner designer = new WorkbookDesigner();
  18768. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  18769. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  18770. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  18771. designer.SetDataSource("TourNo", groupInfo.TourCode);
  18772. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  18773. designer.SetDataSource("Opertor", userInfo.CnName);
  18774. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  18775. dt.TableName = "ViewMyHotelReservations";
  18776. designer.SetDataSource(dt);
  18777. designer.Process();
  18778. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  18779. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  18780. designer.Workbook.Save(serverPath);
  18781. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  18782. #region 删除指定行
  18783. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  18784. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  18785. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  18786. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  18787. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  18788. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  18789. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  18790. cssIndex = dt.Columns["CityTax"].Ordinal,
  18791. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  18792. remarkIndex = dt.Columns["Remark"].Ordinal;
  18793. //删除指定列
  18794. foreach (DataRow item in dt.Rows)
  18795. {
  18796. string singleStr = item["SingleRoomPrice"].ToString();
  18797. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  18798. if (containsDigitButNotZero1) singleDel = false;
  18799. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  18800. string doubleStr = item["DoubleRoomPrice"].ToString();
  18801. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  18802. if (containsDigitButNotZero2) doubleDel = false;
  18803. string suiteStr = item["SuiteRoomPrice"].ToString();
  18804. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  18805. if (containsDigitButNotZero3) suiteDel = false;
  18806. string otherStr = item["OtherRoomPrice"].ToString();
  18807. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  18808. if (containsDigitButNotZero4) otherDel = false;
  18809. string zcStr = item["BreakfastPrice"].ToString();
  18810. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  18811. if (containsDigitButNotZero5) zcDel = false;
  18812. string dsStr = item["GovernmentRent"].ToString();
  18813. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  18814. if (containsDigitButNotZero6) dsDel = false;
  18815. string cssStr = item["CityTax"].ToString();
  18816. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  18817. if (containsDigitButNotZero7) cssDel = false;
  18818. string cpStr = item["ConsumptionPatterns"].ToString();
  18819. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  18820. string remarkStr = item["Remark"].ToString();
  18821. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  18822. }
  18823. DeleteColumn(serverPath, remarkIndex, remarkDel);
  18824. DeleteColumn(serverPath, cpIndex, cpDel);
  18825. DeleteColumn(serverPath, dsIndex, dsDel);
  18826. DeleteColumn(serverPath, cssIndex, cssDel);
  18827. DeleteColumn(serverPath, zcIndex, zcDel);
  18828. DeleteColumn(serverPath, otherIndex, otherDel);
  18829. DeleteColumn(serverPath, suiteIndex, suiteDel);
  18830. DeleteColumn(serverPath, doubleIndex, doubleDel);
  18831. DeleteColumn(serverPath, singleIndex, singleDel);
  18832. #endregion
  18833. //只保留第一个表格
  18834. DeleteSheet(serverPath);
  18835. return Ok(JsonView(true, "操作成功", url = rst));
  18836. }
  18837. //return Ok(JsonView(false));
  18838. }
  18839. /// <summary>
  18840. /// 删除指定列
  18841. /// </summary>
  18842. /// <param name="file"></param>
  18843. /// <param name="columnIndex"></param>
  18844. /// <param name="isDel"></param>
  18845. private void DeleteColumn(string file, int columnIndex, bool isDel)
  18846. {
  18847. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  18848. //wb.Save(file);
  18849. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  18850. if (sheet1 != null)
  18851. {
  18852. if (isDel)
  18853. {
  18854. Cells cells = sheet1.Cells;
  18855. cells.DeleteColumn(columnIndex);
  18856. }
  18857. }
  18858. wb.Save(file);
  18859. }
  18860. /// <summary>
  18861. /// 删除sheet
  18862. /// </summary>
  18863. /// <param name="file"></param>
  18864. private void DeleteSheet(string file)
  18865. {
  18866. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  18867. //wb.Save(file);
  18868. List<string> sheets = new List<string>();
  18869. foreach (var item in wb.Worksheets)
  18870. {
  18871. sheets.Add(item.Name);
  18872. }
  18873. if (sheets.Count > 0)
  18874. {
  18875. sheets.RemoveAt(0);//不删除第一个sheet
  18876. foreach (var item in sheets)
  18877. {
  18878. wb.Worksheets.RemoveAt(item);
  18879. }
  18880. }
  18881. wb.Save(file);
  18882. }
  18883. /// <summary>
  18884. /// 酒店预订
  18885. /// 确认单
  18886. /// </summary>
  18887. /// <param name="_dto"></param>
  18888. /// <returns></returns>
  18889. [HttpPost]
  18890. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18891. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  18892. {
  18893. try
  18894. {
  18895. #region 参数验证
  18896. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  18897. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  18898. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  18899. #region 团组操作权限验证 76 酒店预定模块
  18900. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18901. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  18902. #endregion
  18903. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18904. #region 页面操作权限验证
  18905. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18906. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  18907. #endregion
  18908. #endregion
  18909. //团组信息
  18910. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  18911. //酒店数据
  18912. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  18913. if (listhoteldata.Count < 0)
  18914. {
  18915. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  18916. }
  18917. //利datatable存储
  18918. DataTable dt = new DataTable();
  18919. dt.Columns.Add("CheckInDate", typeof(string));
  18920. dt.Columns.Add("City", typeof(string));
  18921. dt.Columns.Add("Hotel", typeof(string));
  18922. dt.Columns.Add("Room", typeof(string));
  18923. for (int i = 0; i < listhoteldata.Count; i++)
  18924. {
  18925. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  18926. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  18927. while (dayStart < dayEnd)
  18928. {
  18929. string temp = "";
  18930. DataRow row = dt.NewRow();
  18931. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  18932. row["City"] = listhoteldata[i].City;
  18933. row["Hotel"] = listhoteldata[i].HotelName;
  18934. if (listhoteldata[i].SingleRoomCount > 0)
  18935. {
  18936. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  18937. }
  18938. if (listhoteldata[i].DoubleRoomCount > 0)
  18939. {
  18940. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  18941. }
  18942. if (listhoteldata[i].SuiteRoomCount > 0)
  18943. {
  18944. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  18945. }
  18946. if (listhoteldata[i].OtherRoomCount > 0)
  18947. {
  18948. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  18949. }
  18950. row["Room"] = temp;
  18951. dt.Rows.Add(row);
  18952. dayStart = dayStart.AddDays(1);
  18953. }
  18954. }
  18955. Dictionary<string, string> dic = new Dictionary<string, string>();
  18956. dic.Add("Dele", di.TeamName);
  18957. dic.Add("City", di.VisitCountry);
  18958. //模板路径
  18959. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  18960. //载入模板
  18961. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  18962. DocumentBuilder builder = new DocumentBuilder(doc);
  18963. foreach (var key in dic.Keys)
  18964. {
  18965. builder.MoveToBookmark(key);
  18966. builder.Write(dic[key]);
  18967. }
  18968. //获取word里所有表格
  18969. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  18970. //获取所填表格的序数
  18971. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  18972. var rowStart = tableOne.Rows[0]; //获取第1行
  18973. //循环赋值
  18974. for (int i = 0; i < dt.Rows.Count; i++)
  18975. {
  18976. builder.MoveToCell(0, i + 1, 0, 0);
  18977. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  18978. builder.MoveToCell(0, i + 1, 1, 0);
  18979. builder.Write(dt.Rows[i]["City"].ToString());
  18980. builder.MoveToCell(0, i + 1, 2, 0);
  18981. builder.Write(dt.Rows[i]["Hotel"].ToString());
  18982. builder.MoveToCell(0, i + 1, 3, 0);
  18983. builder.Write(dt.Rows[i]["Room"].ToString());
  18984. }
  18985. //删除多余行
  18986. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  18987. {
  18988. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  18989. }
  18990. string strFileName = di.TeamName + "酒店确认单.doc";
  18991. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  18992. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  18993. return Ok(JsonView(true, "成功", url));
  18994. }
  18995. catch (Exception ex)
  18996. {
  18997. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  18998. }
  18999. }
  19000. #endregion
  19001. #region 团组状态
  19002. /// <summary>
  19003. /// 团组状态列表 Page
  19004. /// </summary>
  19005. /// <param name="dto">团组列表请求dto</param>
  19006. /// <returns></returns>
  19007. [HttpPost]
  19008. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19009. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  19010. {
  19011. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  19012. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  19013. {
  19014. string sqlWhere = string.Empty;
  19015. if (dto.IsSure == 0) //未完成
  19016. {
  19017. sqlWhere += string.Format(@" And IsSure = 0");
  19018. }
  19019. else if (dto.IsSure == 1) //已完成
  19020. {
  19021. sqlWhere += string.Format(@" And IsSure = 1");
  19022. }
  19023. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  19024. {
  19025. string tj = dto.SearchCriteria;
  19026. 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}%')",
  19027. tj, tj, tj, tj, tj);
  19028. }
  19029. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  19030. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  19031. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  19032. From (
  19033. Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
  19034. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  19035. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  19036. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  19037. From Grp_DelegationInfo gdi
  19038. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  19039. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  19040. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  19041. Where gdi.IsDel = 0 {0}
  19042. ) temp ", sqlWhere);
  19043. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  19044. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  19045. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  19046. }
  19047. else
  19048. {
  19049. return Ok(JsonView(false, "查询失败"));
  19050. }
  19051. }
  19052. /// <summary>
  19053. /// 团组状态
  19054. /// 设置操作完成
  19055. /// </summary>
  19056. /// <param name="dto">团组列表请求dto</param>
  19057. /// <returns></returns>
  19058. [HttpPost]
  19059. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19060. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  19061. {
  19062. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  19063. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  19064. {
  19065. Id = dto.Id,
  19066. IsSure = 1
  19067. };
  19068. var result = await _sqlSugar.Updateable(_DelegationInfo)
  19069. .UpdateColumns(it => new { it.IsSure })
  19070. .WhereColumns(it => new { it.Id })
  19071. .ExecuteCommandAsync();
  19072. if (result > 0)
  19073. {
  19074. return Ok(JsonView(true, "操作完成!"));
  19075. }
  19076. return Ok(JsonView(false, "操作失败!"));
  19077. }
  19078. #endregion
  19079. #region 保险费用录入
  19080. /// <summary>
  19081. /// 根据团组Id查询保险费用列表
  19082. /// </summary>
  19083. /// <param name="dto"></param>
  19084. /// <returns></returns>
  19085. [HttpPost]
  19086. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19087. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  19088. {
  19089. Result groupData = await _customersRep.CustomersByDiId(dto);
  19090. if (groupData.Code != 0)
  19091. {
  19092. return Ok(JsonView(false, groupData.Msg));
  19093. }
  19094. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  19095. }
  19096. /// <summary>
  19097. /// 根据保险费用Id查询保险费用详细
  19098. /// </summary>
  19099. /// <param name="dto"></param>
  19100. /// <returns></returns>
  19101. [HttpPost]
  19102. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19103. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  19104. {
  19105. try
  19106. {
  19107. Result groupData = await _customersRep.CustomersById(dto);
  19108. if (groupData.Code != 0)
  19109. {
  19110. return Ok(JsonView(false, groupData.Msg));
  19111. }
  19112. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  19113. }
  19114. catch (Exception ex)
  19115. {
  19116. return Ok(JsonView(false, ex.Message));
  19117. }
  19118. }
  19119. /// <summary>
  19120. /// 保险费用录入页面初始化绑定
  19121. /// </summary>
  19122. /// <param name="dto"></param>
  19123. /// <returns></returns>
  19124. [HttpPost]
  19125. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19126. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  19127. {
  19128. try
  19129. {
  19130. Result groupData = await _customersRep.CustomersInitialize(dto);
  19131. if (groupData.Code != 0)
  19132. {
  19133. return Ok(JsonView(false, groupData.Msg));
  19134. }
  19135. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  19136. }
  19137. catch (Exception ex)
  19138. {
  19139. return Ok(JsonView(false, ex.Message));
  19140. }
  19141. }
  19142. /// <summary>
  19143. /// 保险费用操作(Status:1.新增,2.修改)
  19144. /// </summary>
  19145. /// <param name="dto"></param>
  19146. /// <returns></returns>
  19147. [HttpPost]
  19148. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19149. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  19150. {
  19151. Result groupData = await _customersRep.OpCustomers(dto);
  19152. if (groupData.Code != 0)
  19153. {
  19154. return Ok(JsonView(false, groupData.Msg));
  19155. }
  19156. #region 应用推送
  19157. try
  19158. {
  19159. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  19160. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  19161. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  19162. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  19163. //自动审核
  19164. await _feeAuditRep.FeeAutomaticAudit(4, dto.DiId, dataId);
  19165. //2024-10-21 新增LZ UID
  19166. var userIds = new List<int>() { 21 };
  19167. string title = $"系统通知";
  19168. var diId = dto.DiId;
  19169. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  19170. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  19171. string content = "";
  19172. if (dto.Status == 1) content = $"[新增-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  19173. else if (dto.Status == 2) content = $"[更新-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  19174. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  19175. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "82" };
  19176. await APNsTools.iOS_PushNotifications1("051", "保险费用审核", "", content, true, "ExpenseAuditWebView", h5);
  19177. }
  19178. catch (Exception ex)
  19179. {
  19180. }
  19181. #endregion
  19182. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  19183. }
  19184. /// <summary>
  19185. /// 保险文件上传
  19186. /// </summary>
  19187. /// <param name="file"></param>
  19188. /// <returns></returns>
  19189. [HttpPost]
  19190. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19191. public async Task<IActionResult> UploadCus(IFormFile file)
  19192. {
  19193. try
  19194. {
  19195. if (file != null)
  19196. {
  19197. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  19198. //文件名称
  19199. string projectFileName = file.FileName;
  19200. //上传的文件的路径
  19201. string filePath = "";
  19202. if (!Directory.Exists(fileDir))
  19203. {
  19204. Directory.CreateDirectory(fileDir);
  19205. }
  19206. //上传的文件的路径
  19207. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  19208. using (FileStream fs = System.IO.File.Create(filePath))
  19209. {
  19210. file.CopyTo(fs);
  19211. fs.Flush();
  19212. }
  19213. return Ok(JsonView(true, "上传成功!", projectFileName));
  19214. }
  19215. else
  19216. {
  19217. return Ok(JsonView(false, "上传失败!"));
  19218. }
  19219. }
  19220. catch (Exception ex)
  19221. {
  19222. return Ok(JsonView(false, ex.Message));
  19223. }
  19224. }
  19225. /// <summary>
  19226. /// 保险删除指定文件
  19227. /// </summary>
  19228. /// <param name="dto"></param>
  19229. /// <returns></returns>
  19230. [HttpPost]
  19231. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19232. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  19233. {
  19234. try
  19235. {
  19236. string filePath = "";
  19237. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  19238. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  19239. //int id = 0;
  19240. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  19241. // 删除该文件
  19242. try
  19243. {
  19244. System.IO.File.Delete(filePath);
  19245. 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()
  19246. {
  19247. Attachment = "",
  19248. }).ExecuteCommandAsync();
  19249. if (result != 0)
  19250. {
  19251. return Ok(JsonView(true, "成功!"));
  19252. }
  19253. else
  19254. {
  19255. return Ok(JsonView(false, "失败!"));
  19256. }
  19257. }
  19258. catch (Exception)
  19259. {
  19260. 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()
  19261. {
  19262. Attachment = "",
  19263. }).ExecuteCommandAsync();
  19264. if (result != 0)
  19265. {
  19266. return Ok(JsonView(true, "成功!"));
  19267. }
  19268. else
  19269. {
  19270. return Ok(JsonView(false, "失败!"));
  19271. }
  19272. }
  19273. }
  19274. catch (Exception ex)
  19275. {
  19276. return Ok(JsonView(false, "程序错误!"));
  19277. throw;
  19278. }
  19279. }
  19280. /// <summary>
  19281. /// 保险费用操作(删除)
  19282. /// </summary>
  19283. /// <param name="dto"></param>
  19284. /// <returns></returns>
  19285. [HttpPost]
  19286. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19287. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  19288. {
  19289. try
  19290. {
  19291. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  19292. if (!res)
  19293. {
  19294. return Ok(JsonView(false, "删除失败"));
  19295. }
  19296. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  19297. {
  19298. IsDel = 1,
  19299. DeleteUserId = dto.DeleteUserId,
  19300. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  19301. }).ExecuteCommandAsync();
  19302. return Ok(JsonView(true, "删除成功!"));
  19303. }
  19304. catch (Exception ex)
  19305. {
  19306. return Ok(JsonView(false, "程序错误!"));
  19307. throw;
  19308. }
  19309. }
  19310. #endregion
  19311. #region 接团客户名单 PageId 104
  19312. /// <summary>
  19313. /// 接团客户名单
  19314. /// 迁移数据(慎用!)
  19315. /// </summary>
  19316. /// <returns></returns>
  19317. [HttpPost]
  19318. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19319. public async Task<IActionResult> PostTourClientListChange()
  19320. {
  19321. try
  19322. {
  19323. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  19324. //var groupClinetData1
  19325. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  19326. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  19327. int updateCount = 0;
  19328. if (oldOAClientList.Count > 0)
  19329. {
  19330. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  19331. _sqlSugar.BeginTran();
  19332. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  19333. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  19334. foreach (var item in oldOAClientList)
  19335. {
  19336. int comId = 0;
  19337. string format = "yyyy-MM-dd HH:mm:ss";
  19338. string data11 = "1990-01-01 00:00";
  19339. var data1 = IsValidDate(item.OPdate, format);
  19340. if (data1) data11 = item.OPdate;
  19341. //客户公司验证
  19342. if (!string.IsNullOrEmpty(item.Company))
  19343. {
  19344. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  19345. if (clientComInfo == null) // add
  19346. {
  19347. var addInfo = new Crm_CustomerCompany()
  19348. {
  19349. CompanyAbbreviation = "",
  19350. CompanyFullName = item.Company,
  19351. Address = "",
  19352. PostCodes = "",
  19353. LastedOpUserId = item.OPer,
  19354. LastedOpDt = Convert.ToDateTime(data11),
  19355. CreateUserId = item.OPer,
  19356. CreateTime = Convert.ToDateTime(data11),
  19357. IsDel = 0
  19358. };
  19359. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  19360. if (comId1 > 0) comId = comId1;
  19361. }
  19362. else comId = clientComInfo.Id;
  19363. }
  19364. //客户人员验证
  19365. int clientId = 0;
  19366. string name = item.LastName + item.Name;
  19367. if (!string.IsNullOrEmpty(name))
  19368. {
  19369. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  19370. if (clientInfo == null)
  19371. {
  19372. DateTime? dateTime = null;
  19373. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  19374. if (isDt) dateTime = birthDayDt;
  19375. var addInfo1 = new Crm_DeleClient()
  19376. {
  19377. CrmCompanyId = comId,
  19378. DiId = -1,
  19379. LastName = item.LastName,
  19380. FirstName = item.Name,
  19381. OldName = "",
  19382. Pinyin = item.Pinyin,
  19383. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  19384. Marriage = 0,
  19385. Phone = item.Phone,
  19386. Job = item.Job,
  19387. BirthDay = dateTime
  19388. };
  19389. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  19390. if (clientId1 > 0) clientId = clientId1;
  19391. }
  19392. else clientId = clientInfo.Id;
  19393. }
  19394. if (clientId < 1)
  19395. {
  19396. continue;
  19397. }
  19398. int airType = 0;
  19399. if (item.AirType == "超经舱") airType = 459;
  19400. else if (item.AirType == "公务舱") airType = 458;
  19401. else if (item.AirType == "经济舱") airType = 460;
  19402. else if (item.AirType == "其他") airType = 565;
  19403. else if (item.AirType == "头等舱") airType = 457;
  19404. var _TourClientListEntity = new Grp_TourClientList()
  19405. {
  19406. DiId = item.Diid,
  19407. ClientId = clientId,
  19408. CreateUserId = item.OPer,
  19409. CreateTime = Convert.ToDateTime(data11),
  19410. Remark = item.Remark,
  19411. IsDel = item.Isdel,
  19412. ShippingSpaceTypeId = airType,
  19413. ShippingSpaceSpecialNeeds = item.AirRemark,
  19414. HotelSpecialNeeds = item.RoomType
  19415. };
  19416. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  19417. if (_TourClientList > 0)
  19418. {
  19419. updateCount++;
  19420. }
  19421. }
  19422. _sqlSugar.CommitTran();
  19423. }
  19424. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  19425. }
  19426. catch (Exception ex)
  19427. {
  19428. _sqlSugar.RollbackTran();
  19429. return Ok(JsonView(false, ex.Message));
  19430. }
  19431. //return Ok(JsonView(true));
  19432. }
  19433. private bool IsValidDate(string dateString, string format)
  19434. {
  19435. return DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime dateValue);
  19436. }
  19437. /// <summary>
  19438. /// 接团客户名单
  19439. /// 根据团组Id查询List
  19440. /// </summary>
  19441. /// <param name="_dto"></param>
  19442. /// <returns></returns>
  19443. [HttpPost]
  19444. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19445. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  19446. {
  19447. #region 参数验证
  19448. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  19449. if (_dto.PageId != 104) _dto.PageId = 104; //接团客户名单PageId
  19450. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  19451. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19452. #region 页面操作权限验证
  19453. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19454. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  19455. #endregion
  19456. #endregion
  19457. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  19458. if (viewData.Code != 0)
  19459. {
  19460. return Ok(JsonView(false, viewData.Msg));
  19461. }
  19462. return Ok(JsonView(viewData.Data));
  19463. }
  19464. /// <summary>
  19465. /// 接团客户名单
  19466. /// 基础数据 Init
  19467. /// </summary>
  19468. /// <param name="_dto"></param>
  19469. /// <returns></returns>
  19470. [HttpPost]
  19471. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19472. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  19473. {
  19474. #region 参数验证
  19475. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19476. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19477. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19478. #region 页面操作权限验证
  19479. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19480. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  19481. #endregion
  19482. #endregion
  19483. return Ok(await _tourClientListRep._BasicDataInit(_dto.PortType));
  19484. }
  19485. /// <summary>
  19486. /// 接团客户名单
  19487. /// 根据 Id查询 Details
  19488. /// </summary>
  19489. /// <param name="_dto"></param>
  19490. /// <returns></returns>
  19491. [HttpPost]
  19492. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19493. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  19494. {
  19495. #region 参数验证
  19496. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19497. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19498. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  19499. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19500. #region 页面操作权限验证
  19501. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19502. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  19503. #endregion
  19504. #endregion
  19505. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  19506. if (viewData.Code != 0)
  19507. {
  19508. return Ok(JsonView(false, viewData.Msg));
  19509. }
  19510. return Ok(JsonView(viewData.Data));
  19511. }
  19512. /// <summary>
  19513. /// 接团客户名单
  19514. /// Add Or Edit
  19515. /// </summary>
  19516. /// <param name="_dto"></param>
  19517. /// <returns></returns>
  19518. [HttpPost]
  19519. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19520. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  19521. {
  19522. #region 参数验证
  19523. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19524. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19525. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  19526. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19527. #region 页面操作权限验证
  19528. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19529. if (_dto.Id == 0) //添加
  19530. {
  19531. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  19532. }
  19533. else if (_dto.Id >= 0) //修改
  19534. {
  19535. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  19536. }
  19537. #endregion
  19538. #endregion
  19539. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  19540. if (viewData.Code != 0)
  19541. {
  19542. return Ok(JsonView(false, viewData.Msg));
  19543. }
  19544. return Ok(JsonView(true));
  19545. }
  19546. /// <summary>
  19547. /// 接团客户名单
  19548. /// json字符串 AddMultiple(添加多个)
  19549. /// </summary>
  19550. /// <param name="_dto"></param>
  19551. /// <returns></returns>
  19552. [HttpPost]
  19553. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19554. public async Task<IActionResult> PostTourClientListJsonFormatAddMultiple(PostTourClientListJsonFormatAddMultipleDto _dto)
  19555. {
  19556. #region 参数验证
  19557. string jsonLabel = _dto.JsonLabel;
  19558. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19559. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19560. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19561. #region 页面操作权限验证
  19562. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19563. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  19564. #endregion
  19565. #endregion
  19566. var request = new TourClientListAddMultipleDto();
  19567. request.DiId = _dto.DiId;
  19568. request.UserId = _dto.UserId;
  19569. if (!CommonFun.IsValidJson(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数不是合法的json格式!"));
  19570. if (string.IsNullOrEmpty(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数值不能为空"));
  19571. List<TourClientListInfoCN> datas = JsonConvert.DeserializeObject<List<TourClientListInfoCN>>(jsonLabel);
  19572. if (!datas.Any()) return Ok(JsonView(false, "JsonLabel参数值不能为空!"));
  19573. var infos = new List<TourClientListInfo>();
  19574. foreach (var data in datas)
  19575. {
  19576. (string lastName, string firstName) = CommonFun.GetLastNameAndFirstName(data.Name);
  19577. string lastNameEn = CommonFun.ConvertToPinyin(lastName),
  19578. firstNameEn = CommonFun.ConvertToPinyin(lastName);
  19579. if (string.IsNullOrEmpty(lastNameEn) || string.IsNullOrEmpty(firstNameEn))
  19580. {
  19581. continue;
  19582. }
  19583. infos.Add(new TourClientListInfo()
  19584. {
  19585. IsAccompany = 1,
  19586. LastName = lastName,
  19587. FirstName = firstName,
  19588. Pinyin = lastNameEn + @"/" + firstNameEn,
  19589. Sex = data.Sex.Equals("男") ? 0 : data.Sex.Equals("女") ? 1 : 2,
  19590. CompanyFullName = data.CompanyFullName,
  19591. Job = data.Job
  19592. });
  19593. }
  19594. if (infos.Any())
  19595. {
  19596. var viewData = await _tourClientListRep._AddMultiple(request);
  19597. if (viewData.Code != 0)
  19598. {
  19599. return Ok(JsonView(false, viewData.Msg));
  19600. }
  19601. return Ok(JsonView(true));
  19602. }
  19603. return Ok(JsonView(false));
  19604. }
  19605. /// <summary>
  19606. /// 接团客户名单
  19607. /// AddMultiple(添加多个)
  19608. /// </summary>
  19609. /// <param name="_dto"></param>
  19610. /// <returns></returns>
  19611. [HttpPost]
  19612. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19613. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  19614. {
  19615. #region 参数验证
  19616. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19617. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19618. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19619. #region 页面操作权限验证
  19620. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19621. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  19622. #endregion
  19623. #endregion
  19624. var viewData = await _tourClientListRep._AddMultiple(_dto);
  19625. if (viewData.Code != 0)
  19626. {
  19627. return Ok(JsonView(false, viewData.Msg));
  19628. }
  19629. return Ok(JsonView(true));
  19630. }
  19631. /// <summary>
  19632. /// 接团客户名单
  19633. /// Del
  19634. /// </summary>
  19635. /// <param name="_dto"></param>
  19636. /// <returns></returns>
  19637. [HttpPost]
  19638. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19639. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  19640. {
  19641. #region 参数验证
  19642. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19643. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19644. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19645. #region 页面操作权限验证
  19646. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19647. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  19648. #endregion
  19649. #endregion
  19650. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  19651. if (viewData.Code != 0)
  19652. {
  19653. return Ok(JsonView(false, viewData.Msg));
  19654. }
  19655. return Ok(JsonView(true));
  19656. }
  19657. /// <summary>
  19658. /// 接团客户名单
  19659. /// 文件下载 客户名单
  19660. /// </summary>
  19661. /// <param name="_dto"></param>
  19662. /// <returns></returns>
  19663. [HttpPost]
  19664. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19665. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  19666. {
  19667. #region 参数验证
  19668. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19669. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19670. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  19671. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19672. #region 页面操作权限验证
  19673. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19674. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  19675. #endregion
  19676. #endregion
  19677. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  19678. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  19679. From Grp_TourClientList tcl
  19680. Left Join
  19681. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  19682. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  19683. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  19684. From Crm_DeleClient dc
  19685. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  19686. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  19687. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  19688. Where dc.IsDel = 0) temp
  19689. On temp.DcId =tcl.ClientId
  19690. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  19691. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  19692. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  19693. //载入模板
  19694. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  19695. if (_dto.Language == 1)
  19696. {
  19697. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  19698. }
  19699. //载入模板
  19700. var doc = new Document(tempPath);
  19701. DocumentBuilder builder = new DocumentBuilder(doc);
  19702. //获取word里所有表格
  19703. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  19704. //获取所填表格的序数
  19705. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  19706. var rowStart = tableOne.Rows[0]; //获取第1行
  19707. if (_dto.Language == 0)
  19708. {
  19709. //循环赋值
  19710. for (int i = 0; i < DcList.Count; i++)
  19711. {
  19712. EncryptionProcessor.DecryptProperties(DcList[i]);
  19713. builder.MoveToCell(0, i + 1, 0, 0);
  19714. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  19715. builder.MoveToCell(0, i + 1, 1, 0);
  19716. int sex = DcList[i].Sex;
  19717. string sexStr = string.Empty;
  19718. if (sex == 0) sexStr = "男";
  19719. else if (sex == 1) sexStr = "女";
  19720. else sexStr = "未设置";
  19721. builder.Write(sexStr);
  19722. builder.MoveToCell(0, i + 1, 2, 0);
  19723. string birthDay = DcList[i].BirthDay;
  19724. string birthDayStr = string.Empty;
  19725. if (!string.IsNullOrEmpty(birthDay))
  19726. {
  19727. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  19728. }
  19729. builder.Write(birthDayStr);
  19730. builder.MoveToCell(0, i + 1, 3, 0);
  19731. string company = "";
  19732. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  19733. {
  19734. company = DcList[i].CompanyFullName.ToString();
  19735. }
  19736. builder.Write(company);
  19737. builder.MoveToCell(0, i + 1, 4, 0);
  19738. builder.Write(DcList[i].Job);
  19739. }
  19740. }
  19741. else if (_dto.Language == 1)
  19742. {
  19743. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  19744. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  19745. List<string> transArrayStr = new List<string>();
  19746. string transStrRes1 = "";
  19747. for (int i = 0; i < DcList.Count; i++)
  19748. {
  19749. var dc = DcList[i];
  19750. EncryptionProcessor.DecryptProperties(dc);
  19751. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  19752. if (dc.Job.Equals("暂无")) dc.Job = "-";
  19753. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  19754. if (DcList.Count - 1 == i) transStrRes1 += str1;
  19755. else transStrRes1 += $"{str1}|";
  19756. }
  19757. #region AI转英文
  19758. string jsonValue = JsonConvert.SerializeObject(DcList);
  19759. string text = @"将此JSON的中文部分全部翻译为英文,然后只给出修改后的JSON数据,不要其他任何文字";
  19760. List<SeedMessages> messages = new List<SeedMessages>()
  19761. {
  19762. new SeedMessages
  19763. {
  19764. Role = KimiRole.user,
  19765. Content = jsonValue + text
  19766. }
  19767. };
  19768. KiMiApiClient client = new KiMiApiClient();
  19769. var kimiApiResult = await client.SeedMessage(messages);
  19770. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  19771. string clients = kimiApiResult_JObject["content"].ToString();
  19772. string startStr = "```json", endStr = "```";
  19773. // 判断并清除开头部分
  19774. if (clients.StartsWith(startStr))
  19775. {
  19776. clients = clients.Remove(0, startStr.Length);
  19777. }
  19778. // 判断并清除结尾部分
  19779. if (clients.EndsWith(endStr))
  19780. {
  19781. clients = clients.Remove(clients.Length - endStr.Length);
  19782. }
  19783. var en_Json = JsonConvert.DeserializeObject<List<TourClientListDetailsView>>(clients);
  19784. //循环赋值
  19785. for (int i = 0; i < en_Json.Count; i++)
  19786. {
  19787. var dc = en_Json[i];
  19788. var dc1 = DcList.Find(x => x.Id == dc.Id);
  19789. string PYName = dc.FirstName + " " + dc.LastName;
  19790. builder.MoveToCell(0, i + 1, 0, 0);
  19791. builder.Write(PYName);
  19792. string sex = dc.Sex == 0 ? "Male" : dc.Sex == 1 ? "Female" : "";
  19793. builder.MoveToCell(0, i + 1, 1, 0);
  19794. builder.Write(sex);
  19795. DateTime birthDt;
  19796. bool b_birth = DateTime.TryParse(dc.BirthDay, out birthDt);
  19797. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  19798. builder.MoveToCell(0, i + 1, 2, 0);
  19799. builder.Write(birthday);
  19800. string company = string.Empty, job = string.Empty;
  19801. company = dc.CompanyFullName;
  19802. job = dc.Job;
  19803. if (dc1 != null && !string.IsNullOrEmpty(dc1.CompanyFullName))
  19804. {
  19805. //查询对照表
  19806. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(dc1.CompanyFullName.ToString().Trim()));
  19807. if (tempCec != null)
  19808. {
  19809. company = tempCec.enName;
  19810. }
  19811. }
  19812. builder.MoveToCell(0, i + 1, 3, 0);
  19813. builder.Write(company);
  19814. if (dc1 != null && !string.IsNullOrEmpty(dc1.Job))
  19815. {
  19816. //查询对照表
  19817. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == dc1.Job.ToString().Trim());
  19818. if (tempPec != null)
  19819. {
  19820. job = tempPec.enName;
  19821. }
  19822. }
  19823. builder.MoveToCell(0, i + 1, 4, 0);
  19824. builder.Write(job);
  19825. }
  19826. #endregion
  19827. #region 旧翻译英文处理
  19828. ////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";
  19829. //string transStrRes = "";
  19830. //if (transStrRes1.Length > 0)
  19831. //{
  19832. // transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  19833. //}
  19834. ////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
  19835. ////await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  19836. ////List<string> transArray = new List<string> { };
  19837. //List<TranslateInfo> transArray = new List<TranslateInfo>();
  19838. //if (transStrRes.Contains("|"))
  19839. //{
  19840. // string[] transArray1 = transStrRes.Split('|');
  19841. // if (transArray1.Length > 0)
  19842. // {
  19843. // foreach (var item in transArray1)
  19844. // {
  19845. // if (item.Contains("&"))
  19846. // {
  19847. // string[] transArray2 = item.Split('&');
  19848. // int index = 0;
  19849. // string companyName = "", job = "";
  19850. // if (transArray2.Length > 0)
  19851. // {
  19852. // bool success = int.TryParse(transArray2[0].Trim(), out index);
  19853. // if (1 < transArray2.Length) companyName = transArray2[1];
  19854. // if (2 < transArray2.Length) job = transArray2[2];
  19855. // }
  19856. // transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  19857. // }
  19858. // }
  19859. // }
  19860. //}
  19861. ////循环赋值
  19862. //for (int i = 0; i < DcList.Count; i++)
  19863. //{
  19864. // string PYName = "";
  19865. // if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  19866. // {
  19867. // string PY_Last = DcList[i].Pinyin.Split('/')[0];
  19868. // string PY_First = DcList[i].Pinyin.Split('/')[1];
  19869. // PYName = PY_First + " " + PY_Last;
  19870. // }
  19871. // else
  19872. // {
  19873. // string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  19874. // string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  19875. // PYName = PY_First + " " + PY_Last;
  19876. // }
  19877. // builder.MoveToCell(0, i + 1, 0, 0);
  19878. // builder.Write(PYName);
  19879. // string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  19880. // builder.MoveToCell(0, i + 1, 1, 0);
  19881. // builder.Write(sex);
  19882. // DateTime birthDt;
  19883. // bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  19884. // string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  19885. // builder.MoveToCell(0, i + 1, 2, 0);
  19886. // builder.Write(birthday);
  19887. // string company = string.Empty, job = string.Empty;
  19888. // var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  19889. // if (dcTransInfo != null)
  19890. // {
  19891. // company = dcTransInfo.CompanyName;
  19892. // job = dcTransInfo.Job;
  19893. // }
  19894. // if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  19895. // {
  19896. // //查询对照表
  19897. // Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  19898. // if (tempCec != null)
  19899. // {
  19900. // company = tempCec.enName;
  19901. // }
  19902. // //翻译
  19903. // else
  19904. // {
  19905. // }
  19906. // }
  19907. // builder.MoveToCell(0, i + 1, 3, 0);
  19908. // builder.Write(company);
  19909. // if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  19910. // {
  19911. // //查询对照表
  19912. // Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  19913. // if (tempPec != null)
  19914. // {
  19915. // job = tempPec.enName;
  19916. // }
  19917. // //翻译
  19918. // else
  19919. // {
  19920. // }
  19921. // }
  19922. // builder.MoveToCell(0, i + 1, 4, 0);
  19923. // builder.Write(job);
  19924. //}
  19925. #endregion
  19926. }
  19927. //删除多余行
  19928. while (tableOne.Rows.Count > DcList.Count + 1)
  19929. {
  19930. tableOne.Rows.RemoveAt(DcList.Count + 1);
  19931. }
  19932. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  19933. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  19934. doc.Save(fileDir);
  19935. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  19936. return Ok(JsonView(true, "操作成功!", Url));
  19937. }
  19938. private class TranslateInfo
  19939. {
  19940. public int Index { get; set; }
  19941. public string CompanyName { get; set; }
  19942. public string Job { get; set; }
  19943. }
  19944. [HttpPost]
  19945. public async Task<IActionResult> FileReadClient(List<IFormFile> files)
  19946. {
  19947. if (files.Count == 0)
  19948. {
  19949. return Ok(JsonView(false, "文件为空"));
  19950. }
  19951. KiMiApiClient KiMiApi = new KiMiApiClient();
  19952. var seedConter = await KiMiApi.UploadFilesAsync(files);
  19953. if (seedConter.Count == 0)
  19954. {
  19955. return Ok(JsonView(false, "上传结果为空!"));
  19956. }
  19957. var messages = new List<SeedMessages>
  19958. {
  19959. new SeedMessages { Role = KimiRole.system, Content = "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长中文和英文的对话。你会为用户提供安全,有帮助,准确的回答。同时,你会拒绝一切涉及恐怖主义,种族歧视,黄色暴力等问题的回答。Moonshot AI 为专有名词,不可翻译成其他语言。" },
  19960. new SeedMessages { Role = KimiRole.user, Content = "根据文件内容 ,按照“姓、名、姓名拼音、性别、单位、职务、出生日期”的json格式来排列整理(性别和出生日期通过身份证来识别 , 当识别到性别为男时值给0女给1 未识别到性别的情况下值给-1,出生日期按照yyyy-MM-dd来整理,文件存在拼音的情况读取对应的拼音不存在则设置拼音为中文名字全拼),只输出JSON数组数据 从'['开始 到']'结尾 ,不要除JSON数据外的任何文字以及符号" }
  19961. };
  19962. messages.InsertRange(1, seedConter);
  19963. var kimiApiResult = await KiMiApi.SeedMessage(messages);
  19964. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  19965. string clients = kimiApiResult_JObject["content"].ToString();
  19966. string startStr = "```json", endStr = "```";
  19967. // 判断并清除开头部分
  19968. if (clients.StartsWith(startStr))
  19969. {
  19970. clients = clients.Remove(0, startStr.Length);
  19971. }
  19972. // 判断并清除结尾部分
  19973. if (clients.EndsWith(endStr))
  19974. {
  19975. clients = clients.Remove(clients.Length - endStr.Length);
  19976. }
  19977. var clients_JObject = JsonConvert.DeserializeObject<List<JObject>>(clients);
  19978. Dictionary<string, string> clientFieldMap = new Dictionary<string, string>()
  19979. {
  19980. {"姓", "LastName" },
  19981. {"名", "FirstName" },
  19982. {"姓名拼音", "Pinyin" },
  19983. {"性别", "Sex" },
  19984. {"单位", "CompanyFullName" },
  19985. {"职务", "Job" },
  19986. {"出生日期", "Birthday" },
  19987. };
  19988. List<BaiduClientOCRView> crmClients = new List<BaiduClientOCRView>();
  19989. foreach (var item in clients_JObject)
  19990. {
  19991. BaiduClientOCRView cdc = new BaiduClientOCRView();
  19992. foreach (var field in clientFieldMap.Keys)
  19993. {
  19994. if (item.TryGetValue(field, out JToken value))
  19995. {
  19996. var getValue = value.ToString();
  19997. System.Type type = cdc.GetType();
  19998. PropertyInfo propertyInfo = type.GetProperty(clientFieldMap[field]);
  19999. var propertyValue = Convert.ChangeType(getValue, propertyInfo.PropertyType);
  20000. propertyInfo.SetValue(cdc, propertyValue);
  20001. }
  20002. }
  20003. crmClients.Add(cdc);
  20004. }
  20005. return Ok(JsonView(new
  20006. {
  20007. fileCount = files.Count,
  20008. UploadCount = seedConter.Count,
  20009. ApiResult = clients,
  20010. CrmClients = crmClients
  20011. }));
  20012. }
  20013. #endregion
  20014. #region 团组倒推表
  20015. /// <summary>
  20016. /// 倒推表基础数据
  20017. /// Init
  20018. /// </summary>
  20019. /// <returns></returns>
  20020. [HttpPost]
  20021. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20022. public async Task<IActionResult> PostInvertedListInit()
  20023. {
  20024. var viewData = await _invertedListRep._Init();
  20025. if (viewData.Code != 0)
  20026. {
  20027. return Ok(JsonView(false, viewData.Msg));
  20028. }
  20029. return Ok(JsonView(viewData.Data));
  20030. }
  20031. /// <summary>
  20032. /// 倒推表
  20033. /// Info
  20034. /// </summary>
  20035. /// <param name="dto"></param>
  20036. /// <returns></returns>
  20037. [HttpPost]
  20038. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20039. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  20040. {
  20041. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  20042. if (viewData.Code != 0)
  20043. {
  20044. return Ok(JsonView(false, viewData.Msg));
  20045. }
  20046. return Ok(JsonView(viewData.Data));
  20047. }
  20048. /// <summary>
  20049. /// 倒推表
  20050. /// Create
  20051. /// </summary>
  20052. /// <param name="dto"></param>
  20053. /// <returns></returns>
  20054. [HttpPost]
  20055. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20056. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  20057. {
  20058. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  20059. if (viewData.Code != 0)
  20060. {
  20061. return Ok(JsonView(false, viewData.Msg));
  20062. }
  20063. return Ok(JsonView(viewData.Data));
  20064. }
  20065. /// <summary>
  20066. /// 倒推表
  20067. /// Update
  20068. /// </summary>
  20069. /// <param name="dto"></param>
  20070. /// <returns></returns>
  20071. [HttpPost]
  20072. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20073. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  20074. {
  20075. var viewData = await _invertedListRep._Update(dto);
  20076. if (viewData.Code != 0)
  20077. {
  20078. return Ok(JsonView(false, viewData.Msg));
  20079. }
  20080. return Ok(JsonView(viewData.Data));
  20081. }
  20082. /// <summary>
  20083. /// 倒推表
  20084. /// File Download
  20085. /// </summary>
  20086. /// <param name="dto"></param>
  20087. /// <returns></returns>
  20088. [HttpPost]
  20089. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20090. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  20091. {
  20092. var info2 = await _invertedListRep._Info(1, dto.DiId);
  20093. if (info2.Code != 0)
  20094. {
  20095. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  20096. }
  20097. var info1 = info2.Data as InvertedListInfoView;
  20098. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  20099. string teamName = "";
  20100. if (info != null) teamName = info.TeamName;
  20101. var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20250121.doc";
  20102. var doc = new Document();
  20103. var builder = new DocumentBuilder(doc);
  20104. #region old insert
  20105. ////载入模板
  20106. //var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20200617.doc";
  20107. //Document doc = new Document(tempPath);
  20108. //DocumentBuilder builder = new DocumentBuilder(doc);
  20109. //利用键值对存放数据
  20110. //Dictionary<string, string> dic = new Dictionary<string, string>();
  20111. //dic.Add("TeamName", teamName);
  20112. //dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  20113. //dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  20114. //dic.Add("BPRemark", info1.ApprovalDataRemark);
  20115. //dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  20116. //dic.Add("SQRemark", info1.ApprovalRemark);
  20117. //dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  20118. //dic.Add("CPJRemark", info1.IssueApprovalRemark);
  20119. ////dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  20120. ////dic.Add("HZRemark", info1.ApplyPassportRemark);
  20121. //dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  20122. //dic.Add("QZRemark", info1.VisaInformationRemark);
  20123. //dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  20124. //dic.Add("SQQZRemark", info1.SendVisaRemark);
  20125. //dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  20126. //dic.Add("CQRemark", info1.IssueVisaRemark);
  20127. //dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  20128. //dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  20129. //dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  20130. //dic.Add("SJRemark", info1.AirportdDropOffRemark);
  20131. //#region 填充word模板书签内容
  20132. //foreach (var key in dic.Keys)
  20133. //{
  20134. // builder.MoveToBookmark(key);
  20135. // builder.Write(dic[key]);
  20136. //}
  20137. //#endregion
  20138. #endregion
  20139. #region New Insert
  20140. string titleFont = $"仿宋",
  20141. contentFont = $"仿宋";
  20142. var fontColor = Color.FromArgb(64, 64, 64);
  20143. //设置标题 团组名称
  20144. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  20145. builder.Font.Name = titleFont;
  20146. builder.Font.Color = fontColor;
  20147. builder.Font.Size = 12;
  20148. builder.Font.Bold = true;
  20149. builder.Writeln(teamName);
  20150. //设置副标题 团组出访时间
  20151. builder.Font.Size = 12;
  20152. builder.Writeln("出发时间:" + info1.AirportdDropOffDt.ConvertToDatetime());
  20153. builder.Writeln();
  20154. var backgroundColor = Color.FromArgb(199, 199, 199);
  20155. var table = builder.StartTable();
  20156. builder.InsertCell();
  20157. builder.CellFormat.Shading.BackgroundPatternColor = backgroundColor;
  20158. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Single;
  20159. builder.CellFormat.Borders.LineWidth = 1;
  20160. builder.CellFormat.Borders.Color = Color.FromArgb(183, 183, 183);
  20161. table.FirstRow.FirstCell.CellFormat.Width = 20; // 单位为百分比
  20162. builder.RowFormat.Height = 40;
  20163. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  20164. builder.Font.Name = contentFont;
  20165. builder.Font.Size = 12;
  20166. builder.Font.Bold = true;
  20167. builder.Font.Color = fontColor;
  20168. builder.Write("时间");
  20169. builder.InsertCell();
  20170. table.FirstRow.FirstCell.CellFormat.Width = 30; // 单位为百分比
  20171. builder.Write("流程");
  20172. builder.InsertCell();
  20173. table.FirstRow.FirstCell.CellFormat.Width = 50; // 单位为百分比
  20174. builder.Write("说明");
  20175. builder.EndRow();
  20176. //报批资料准备
  20177. if (info1.IsSelectedAirportd)
  20178. {
  20179. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDataDt.ConvertToDatetime(), "报批资料准备", info1.ApprovalDataRemark);
  20180. }
  20181. //报批/提供送签资料
  20182. if (info1.IsSelectedApprovalData)
  20183. {
  20184. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDt.ConvertToDatetime(), "报批/提供送签资料", info1.ApprovalRemark);
  20185. }
  20186. //出批件护照办理
  20187. if (info1.IsSelectedIssueApproval)
  20188. {
  20189. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueApprovalDt.ConvertToDatetime(), "出批件\r\n护照办理", info1.IssueApprovalRemark);
  20190. }
  20191. //签证资料准备
  20192. if (info1.IsSelectedVisaInfo)
  20193. {
  20194. InvertedListFileDownloadSetRow(builder, contentFont, info1.VisaInformationDt.ConvertToDatetime(), "签证资料准备", info1.VisaInformationRemark);
  20195. }
  20196. //送签
  20197. if (info1.IsSelectedSendVisa)
  20198. {
  20199. InvertedListFileDownloadSetRow(builder, contentFont, info1.SendVisaDt.ConvertToDatetime(), "送签", info1.SendVisaRemark);
  20200. }
  20201. //出签
  20202. if (info1.IsSelectedIssueVisa)
  20203. {
  20204. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueVisaDt.ConvertToDatetime(), "出签", info1.IssueVisaRemark);
  20205. }
  20206. //机票
  20207. if (info1.IsSelectedAirTicket)
  20208. {
  20209. if (string.IsNullOrEmpty(info1.AirTicketDt)) info1.AirTicketDt = info1.IssueVisaDt;
  20210. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirTicketDt.ConvertToDatetime(), "机票", info1.AirTicketRemark);
  20211. }
  20212. //酒店
  20213. if (info1.IsSelectedHotel)
  20214. {
  20215. if (string.IsNullOrEmpty(info1.HotelDt)) info1.HotelDt = info1.IssueVisaDt;
  20216. InvertedListFileDownloadSetRow(builder, contentFont, info1.HotelDt.ConvertToDatetime(), "酒店", info1.HotelRemark);
  20217. }
  20218. //开行前会
  20219. if (info1.IsSelectedPreTripMeeting)
  20220. {
  20221. InvertedListFileDownloadSetRow(builder, contentFont, info1.PreTripMeetingDt.ConvertToDatetime(), "开行前会", info1.PreTripMeetingRemark);
  20222. }
  20223. //送机
  20224. if (info1.IsSelectedAirportdDropOff)
  20225. {
  20226. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirportdDropOffDt.ConvertToDatetime(), "送机", info1.AirportdDropOffRemark);
  20227. }
  20228. builder.EndTable();
  20229. //table.PreferredWidth = PreferredWidth.FromPercent(100.00);
  20230. //table.AutoFit(AutoFitBehavior.FixedColumnWidths);
  20231. for (int i = 0; i < table.Rows.Count; i++)
  20232. {
  20233. var row = table.Rows[i];
  20234. //设置宽度
  20235. row.Cells[0].CellFormat.Width = 20.00;
  20236. row.Cells[1].CellFormat.Width = 30.00;
  20237. row.Cells[2].CellFormat.Width = 50.00;
  20238. if (i != 0)
  20239. {
  20240. //边框设置
  20241. InvertedListFileDownloadSetBorders(row.Cells, 0);
  20242. InvertedListFileDownloadSetBorders(row.Cells, 1);
  20243. InvertedListFileDownloadSetBorders(row.Cells, 2);
  20244. }
  20245. }
  20246. #region 页脚插入图片
  20247. // 创建页脚
  20248. Aspose.Words.HeaderFooter footer = new Aspose.Words.HeaderFooter(doc, HeaderFooterType.FooterPrimary);
  20249. doc.FirstSection.HeadersFooters.Add(footer);
  20250. Paragraph para = new Paragraph(doc);
  20251. para.ParagraphFormat.Alignment = ParagraphAlignment.Right;
  20252. footer.AppendChild(para);
  20253. builder.MoveTo(para);
  20254. string imagePath = "./Images/FMGJ_Log.png";
  20255. builder.InsertImage(imagePath);
  20256. #endregion
  20257. #endregion
  20258. var fileDir = AppSettingsHelper.Get("WordBasePath");
  20259. string fileName = $"{teamName}团出行准备流程表{CommonFun.GUID}.doc";
  20260. string filePath = fileDir + $@"InvertedList/{fileName}";
  20261. doc.Save(filePath);
  20262. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  20263. return Ok(JsonView(true, "操作成功!", Url));
  20264. }
  20265. private void InvertedListFileDownloadSetRow(DocumentBuilder builder, string fontName, string dateTime, string content, string reamrk)
  20266. {
  20267. var fontColor = Color.FromArgb(64, 64, 64);
  20268. builder.InsertCell();
  20269. builder.CellFormat.Shading.BackgroundPatternColor = Color.Empty;
  20270. builder.RowFormat.Height = 40;
  20271. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  20272. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  20273. builder.Font.Name = fontName;
  20274. builder.Font.Size = 8;
  20275. builder.Font.Bold = true;
  20276. builder.Font.Color = fontColor;
  20277. builder.Write(dateTime);
  20278. builder.InsertCell();
  20279. builder.Font.Size = 9;
  20280. builder.Font.Bold = true;
  20281. builder.Font.Color = fontColor;
  20282. builder.Write(content);
  20283. builder.InsertCell();
  20284. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  20285. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  20286. builder.Font.Size = 9;
  20287. builder.Font.Bold = false;
  20288. builder.Font.Color = fontColor;
  20289. builder.Write(reamrk);
  20290. builder.EndRow();
  20291. }
  20292. private void InvertedListFileDownloadSetBorders(CellCollection cell, int index)
  20293. {
  20294. cell[index].CellFormat.Borders.Top.LineStyle = Aspose.Words.LineStyle.None;
  20295. cell[index].CellFormat.Borders.Bottom.LineStyle = Aspose.Words.LineStyle.None;
  20296. cell[index].CellFormat.Borders.Left.LineStyle = Aspose.Words.LineStyle.None;
  20297. cell[index].CellFormat.Borders.Right.LineStyle = Aspose.Words.LineStyle.None;
  20298. //cell[index].CellFormat.Borders.Horizontal.LineStyle = Aspose.Words.LineStyle.None;
  20299. //cell[index].CellFormat.Borders.Vertical.LineStyle = Aspose.Words.LineStyle.None;
  20300. }
  20301. #endregion
  20302. #region 会务倒推表
  20303. /// <summary>
  20304. /// 会务倒推表
  20305. /// Init
  20306. /// </summary>
  20307. /// <returns></returns>
  20308. [HttpPost]
  20309. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20310. public async Task<IActionResult> InforRetrogressTableInit()
  20311. {
  20312. var groupData = await _groupRepository.PostShareGroupInfos(1);
  20313. if (groupData.Code == 0) return Ok(JsonView(groupData.Data));
  20314. return Ok(JsonView(false, groupData.Msg));
  20315. }
  20316. /// <summary>
  20317. /// 会务倒推表
  20318. /// ExcelDownload
  20319. /// </summary>
  20320. /// <param name="dto"></param>
  20321. /// <returns></returns>
  20322. [HttpPost]
  20323. [ApiLog("InforRetrogressTable", OperationEnum.Download)]
  20324. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20325. public async Task<IActionResult> InforRetrogressTableFileDownload(InforRetrogressTableFileDownloadDto dto)
  20326. {
  20327. var validator = new InforRetrogressTableFileDownloadDtoValidator();
  20328. var validatorRes = await validator.ValidateAsync(dto);
  20329. if (!validatorRes.IsValid)
  20330. {
  20331. StringBuilder sb = new StringBuilder();
  20332. foreach (var item in validatorRes.Errors)
  20333. {
  20334. sb.AppendLine(item.ErrorMessage);
  20335. }
  20336. return Ok(JsonView(false, sb.ToString()));
  20337. }
  20338. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.GroupId);
  20339. if (groupInfo == null) return Ok(JsonView(false, $"该团组信息未填写!"));
  20340. //时间根据团组出访日期-接团录入日期的天数来判断用哪个模板
  20341. var days = groupInfo.VisitDate.Subtract(groupInfo.CreateTime).Days;
  20342. #region Excel
  20343. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  20344. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  20345. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "InforRetrogressTable/";
  20346. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "InforRetrogressTable/";
  20347. var fileNamePrefix = string.Empty;
  20348. if (days >= 30)
  20349. {
  20350. tempPath += $"会务工作倒推进度表(30天).xlsx";
  20351. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(30天)";
  20352. }
  20353. else if (days < 30 && days > 7)
  20354. {
  20355. tempPath += $"会务工作倒推进度表(15天).xlsx";
  20356. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(15天)";
  20357. }
  20358. else if (days <= 7)
  20359. {
  20360. tempPath += $"会务工作倒推进度表(7天).xlsx";
  20361. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(7天)";
  20362. }
  20363. var fileName = $"{fileNamePrefix}{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  20364. fileName = CommonFun.ValidFileName(fileName);
  20365. //载入模板
  20366. WorkbookDesigner designer = new WorkbookDesigner();
  20367. designer.Workbook = new Workbook(tempPath);
  20368. designer.Process();
  20369. if (!Directory.Exists(savePath))
  20370. {
  20371. Directory.CreateDirectory(savePath);
  20372. }
  20373. string serverPath = $"{savePath}{fileName}";
  20374. designer.Workbook.Save(serverPath);
  20375. string rst = $"{servicePath}{ftpPath}{fileName}";
  20376. #endregion
  20377. return Ok(JsonView(new { url = rst }));
  20378. }
  20379. #endregion
  20380. #region 三公签证费用(签证费、代办费)
  20381. /// <summary>
  20382. /// 三公签证费用(签证费、代办费)
  20383. /// List
  20384. /// </summary>
  20385. /// <returns></returns>
  20386. [HttpPost]
  20387. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20388. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  20389. {
  20390. return Ok(await _visaFeeInfoRep.List(_dto.PortType, _dto.DiId));
  20391. }
  20392. /// <summary>
  20393. /// 三公签证费用(签证费、代办费)
  20394. /// Add Or Update
  20395. /// </summary>
  20396. /// <returns></returns>
  20397. [HttpPost]
  20398. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20399. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  20400. {
  20401. var _view = await _visaFeeInfoRep.Update(_dto);
  20402. if (_view.Code != 0)
  20403. {
  20404. return Ok(JsonView(false, _view.Msg));
  20405. }
  20406. return Ok(JsonView(true, _view.Msg));
  20407. }
  20408. #endregion
  20409. #region 酒店询价
  20410. /// <summary>
  20411. /// 酒店询价
  20412. /// Init
  20413. /// </summary>
  20414. /// <returns></returns>
  20415. [HttpPost]
  20416. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20417. public async Task<IActionResult> PostHotelInquiryInit()
  20418. {
  20419. var res = await _hotelInquiryRep._Init();
  20420. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  20421. return Ok(JsonView(true, res.Msg, res.Data));
  20422. }
  20423. /// <summary>
  20424. /// 酒店询价
  20425. /// page Item
  20426. /// </summary>
  20427. /// <param name="_dto"></param>
  20428. /// <returns></returns>
  20429. [HttpPost]
  20430. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20431. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  20432. {
  20433. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  20434. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  20435. var view = res.Data as PageDataViewBase;
  20436. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  20437. }
  20438. /// <summary>
  20439. /// 酒店询价
  20440. /// info
  20441. /// </summary>
  20442. /// <param name="_dto"></param>
  20443. /// <returns></returns>
  20444. [HttpPost]
  20445. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20446. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  20447. {
  20448. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  20449. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  20450. return Ok(JsonView(true, res.Msg, res.Data));
  20451. }
  20452. /// <summary>
  20453. /// 酒店询价
  20454. /// Add Or Edit
  20455. /// </summary>
  20456. /// <param name="_dto"></param>
  20457. /// <returns></returns>
  20458. [HttpPost]
  20459. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20460. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  20461. {
  20462. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  20463. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  20464. return Ok(JsonView(true, res.Msg, res.Data));
  20465. }
  20466. /// <summary>
  20467. /// 酒店询价
  20468. /// Del
  20469. /// </summary>
  20470. /// <param name="_dto"></param>
  20471. /// <returns></returns>
  20472. [HttpPost]
  20473. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20474. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  20475. {
  20476. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  20477. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  20478. return Ok(JsonView(true, res.Msg, res.Data));
  20479. }
  20480. #endregion
  20481. #region 下载匹配op行程单
  20482. /// <summary>
  20483. /// 匹配op行程单
  20484. /// Init
  20485. /// </summary>
  20486. /// <param name="dto">团组列表请求dto</param>
  20487. /// <returns></returns>
  20488. [HttpPost]
  20489. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20490. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  20491. {
  20492. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  20493. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  20494. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  20495. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  20496. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  20497. .Where(it => it.IsDel == 0)
  20498. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  20499. .OrderByDescending(it => it.VisitStartDate)
  20500. .ToList();
  20501. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  20502. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  20503. var diids = groupInfos.Select(it => it.Id).ToList();
  20504. List<string> countrys = new List<string>();
  20505. foreach (var item in country)
  20506. {
  20507. var data = _groupRepository.FormartTeamName(item);
  20508. var dataArray = _groupRepository.GroupSplitCountry(data);
  20509. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  20510. }
  20511. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  20512. List<string> areaArray = new List<string>(); //GetGroupCityLine
  20513. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  20514. foreach (var item in areaItem)
  20515. {
  20516. string areaStr = item.Value;
  20517. if (!string.IsNullOrEmpty(areaStr))
  20518. {
  20519. string[] str1 = areaStr.Split("-");
  20520. if (str1.Length > 0)
  20521. {
  20522. areaArray.AddRange(str1);
  20523. }
  20524. }
  20525. }
  20526. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  20527. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  20528. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  20529. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  20530. .ToList();
  20531. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  20532. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  20533. .Where(it => countriesIds.Contains(it.Id))
  20534. .Select(it => new { it.Id, Name = it.Name_CN })
  20535. .ToList();
  20536. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  20537. .Select(it => it.TeamName).ToList();
  20538. stopwatch.Stop();
  20539. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  20540. }
  20541. ///// <summary>
  20542. ///// 匹配op行程单
  20543. ///// Init 查询区域数据
  20544. ///// </summary>
  20545. ///// <param name="dto">团组列表请求dto</param>
  20546. ///// <returns></returns>
  20547. //[HttpPost]
  20548. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20549. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  20550. //{
  20551. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  20552. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  20553. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  20554. // if (string.IsNullOrEmpty(countriesDataStr))
  20555. // {
  20556. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  20557. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  20558. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  20559. // }
  20560. // else
  20561. // {
  20562. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  20563. // }
  20564. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  20565. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  20566. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  20567. // List<dynamic> childList = new List<dynamic>();
  20568. // int parentId = dto.CountriesId;
  20569. // if (provinceData.Count > 1)
  20570. // {
  20571. // foreach (var item1 in provinceData)
  20572. // {
  20573. // List<dynamic> childList1 = new List<dynamic>();
  20574. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  20575. // foreach (var item2 in citiesData1)
  20576. // {
  20577. // List<dynamic> childList2 = new List<dynamic>();
  20578. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  20579. // foreach (var item3 in countiesData1)
  20580. // {
  20581. // childList2.Add(new
  20582. // {
  20583. // id = item3.Id,
  20584. // parentId = item2.Id,
  20585. // level = "district",
  20586. // name = item3.Name_CN,
  20587. // });
  20588. // }
  20589. // childList1.Add(new
  20590. // {
  20591. // id = item2.Id,
  20592. // parentId = item1.Id,
  20593. // level = "city",
  20594. // name = item2.Name_CN,
  20595. // childList = childList2
  20596. // });
  20597. // }
  20598. // childList.Add(new
  20599. // {
  20600. // id = item1.Id,
  20601. // parentId = parentId,
  20602. // level = "province",
  20603. // name = item1.Name_CN,
  20604. // childList = childList1
  20605. // });
  20606. // }
  20607. // //城市
  20608. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  20609. // foreach (var item2 in citiesData2)
  20610. // {
  20611. // List<dynamic> childList22 = new List<dynamic>();
  20612. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  20613. // foreach (var item3 in countiesData1)
  20614. // {
  20615. // childList22.Add(new
  20616. // {
  20617. // id = item3.Id,
  20618. // parentId = item2.Id,
  20619. // level = "district",
  20620. // name = item3.Name_CN,
  20621. // });
  20622. // }
  20623. // childList.Add(new
  20624. // {
  20625. // id = item2.Id,
  20626. // parentId = parentId,
  20627. // level = "city",
  20628. // name = item2.Name_CN,
  20629. // childList = childList22
  20630. // });
  20631. // }
  20632. // }
  20633. // else
  20634. // {
  20635. // foreach (var item2 in citiesData)
  20636. // {
  20637. // string cname = item2.Name_CN;
  20638. // List<dynamic> childList1 = new List<dynamic>();
  20639. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  20640. // foreach (var item3 in countiesData1)
  20641. // {
  20642. // childList1.Add(new
  20643. // {
  20644. // Id = item3.Id,
  20645. // parentId = item2.Id,
  20646. // level = "district",
  20647. // name = item3.Name_CN
  20648. // });
  20649. // }
  20650. // childList.Add(new
  20651. // {
  20652. // id = item2.Id,
  20653. // parentId = parentId,
  20654. // level = "city",
  20655. // name = item2.Name_CN,
  20656. // childList = childList1
  20657. // });
  20658. // }
  20659. // }
  20660. // stopwatch.Stop();
  20661. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  20662. //}
  20663. /// <summary>
  20664. /// 匹配op行程单
  20665. /// 接团信息列表 Page
  20666. /// </summary>
  20667. /// <param name="dto">团组列表请求dto</param>
  20668. /// <returns></returns>
  20669. [HttpPost]
  20670. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20671. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  20672. {
  20673. var swatch = new Stopwatch();
  20674. swatch.Start();
  20675. #region 参数验证
  20676. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  20677. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  20678. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20679. #region 页面操作权限验证
  20680. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  20681. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  20682. #endregion
  20683. #endregion
  20684. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  20685. {
  20686. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  20687. //string sqlWhere = "";
  20688. if (!string.IsNullOrEmpty(dto.Country))
  20689. {
  20690. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  20691. }
  20692. if (!string.IsNullOrEmpty(dto.Area))
  20693. {
  20694. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  20695. }
  20696. if (!string.IsNullOrEmpty(dto.TeamName))
  20697. {
  20698. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  20699. }
  20700. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  20701. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  20702. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  20703. swatch.Stop();
  20704. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  20705. }
  20706. else
  20707. {
  20708. return Ok(JsonView(false, "查询失败"));
  20709. }
  20710. }
  20711. /// <summary>
  20712. /// 匹配op行程单
  20713. /// 行程单下载
  20714. /// </summary>
  20715. /// <param name="dto">团组列表请求dto</param>
  20716. /// <returns></returns>
  20717. [HttpPost]
  20718. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20719. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  20720. {
  20721. #region 参数验证
  20722. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  20723. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  20724. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20725. #region 页面操作权限验证
  20726. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  20727. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  20728. #endregion
  20729. #endregion
  20730. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  20731. {
  20732. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  20733. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  20734. }
  20735. else
  20736. {
  20737. return Ok(JsonView(false, "下载失败!"));
  20738. }
  20739. }
  20740. #endregion
  20741. #region 国家信息 数据 注释
  20742. //[HttpPost]
  20743. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  20744. //{
  20745. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  20746. // foreach (var item in dto)
  20747. // {
  20748. // infos.Add(new Grp_GroupsTaskAssignment()
  20749. // {
  20750. // DIId = item,
  20751. // CTId = 82,
  20752. // UId = 248,
  20753. // IsEnable = 1,
  20754. // CreateUserId = 233,
  20755. // CreateTime = DateTime.Now,
  20756. // IsDel = 0
  20757. // });
  20758. // infos.Add(new Grp_GroupsTaskAssignment()
  20759. // {
  20760. // DIId = item,
  20761. // CTId = 82,
  20762. // UId = 286,
  20763. // IsEnable = 1,
  20764. // CreateUserId = 233,
  20765. // CreateTime = DateTime.Now,
  20766. // IsDel = 0
  20767. // });
  20768. // }
  20769. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  20770. // return Ok("操作成功");
  20771. //}
  20772. //public class paramJsonDto
  20773. //{
  20774. // public List<CountriesInfo> str { get; set; }
  20775. //}
  20776. //[HttpPost]
  20777. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  20778. //{
  20779. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  20780. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  20781. // List<Sys_Cities> cities = new List<Sys_Cities>();
  20782. // List<Sys_Cities> districts = new List<Sys_Cities>();
  20783. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  20784. // _sqlSugar.BeginTran();
  20785. // int countitiesIndex = 0;
  20786. // foreach (var item in dto.str)
  20787. // {
  20788. // dynamic data = item.c;
  20789. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  20790. // if (data != null)
  20791. // {
  20792. // countitiesIndex++;
  20793. // foreach (var item1 in data)
  20794. // {
  20795. // string cnname = item1.cn;
  20796. // string enname = item1.en;
  20797. // Sys_Cities provinceInfo = new Sys_Cities()
  20798. // {
  20799. // CountriesId = countriesId,
  20800. // Name_CN = cnname,
  20801. // Name_EN = enname,
  20802. // ParentId = 0,
  20803. // IsCapital = 1,
  20804. // CreateUserId = 208,
  20805. // CreateTime = DateTime.Now,
  20806. // IsDel = 0
  20807. // };
  20808. // if (item1.lv == "province") //省份
  20809. // {
  20810. // provinceInfo.Level = 1;
  20811. // int provinceId = 0;
  20812. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  20813. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  20814. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  20815. // var data1 = item1.c;
  20816. // foreach (var item2 in data1)
  20817. // {
  20818. // if (item2.lv == "city")
  20819. // {
  20820. // string citycnname = item2.cn;
  20821. // string cityenname = item2.en;
  20822. // Sys_Cities cityInfo = new Sys_Cities()
  20823. // {
  20824. // CountriesId = countriesId,
  20825. // ParentId = provinceId,
  20826. // Level = 2,
  20827. // Name_CN = citycnname,
  20828. // Name_EN = cityenname,
  20829. // IsCapital = 1,
  20830. // CreateUserId = 208,
  20831. // CreateTime = DateTime.Now,
  20832. // IsDel = 0
  20833. // };
  20834. // if (item2.c != null)
  20835. // {
  20836. // int cityId = 0;
  20837. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  20838. // if (citiesInfo != null) cityId = citiesInfo.Id;
  20839. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  20840. // foreach (var item3 in item2.c)
  20841. // {
  20842. // if (item3.lv == "district")
  20843. // {
  20844. // var districtInfo = new Sys_Cities()
  20845. // {
  20846. // CountriesId = countriesId,
  20847. // Name_CN = item3.cn,
  20848. // Name_EN = item3.en,
  20849. // Level = 3,
  20850. // ParentId = cityId,
  20851. // IsCapital = 1,
  20852. // CreateUserId = 208,
  20853. // CreateTime = DateTime.Now,
  20854. // IsDel = 0
  20855. // };
  20856. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  20857. // //{
  20858. // districts.Add(districtInfo);
  20859. // //}
  20860. // }
  20861. // }
  20862. // }
  20863. // else
  20864. // {
  20865. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  20866. // //{
  20867. // cities.Add(cityInfo);
  20868. // //}
  20869. // }
  20870. // }
  20871. // }
  20872. // }
  20873. // else if (item1.lv == "city")//城市
  20874. // {
  20875. // provinceInfo.Level = 2;
  20876. // if (item1.c != null)
  20877. // {
  20878. // int cityId = 0;
  20879. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  20880. // if (citiesInfo != null) cityId = citiesInfo.Id;
  20881. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  20882. // foreach (var item3 in item1.c)
  20883. // {
  20884. // if (item3.lv == "district")
  20885. // {
  20886. // var districtInfo = new Sys_Cities()
  20887. // {
  20888. // CountriesId = countriesId,
  20889. // Name_CN = item3.cn,
  20890. // Name_EN = item3.en,
  20891. // Level = 3,
  20892. // ParentId = cityId,
  20893. // IsCapital = 1,
  20894. // CreateUserId = 208,
  20895. // CreateTime = DateTime.Now,
  20896. // IsDel = 0
  20897. // };
  20898. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  20899. // //{
  20900. // districts.Add(districtInfo);
  20901. // //}
  20902. // }
  20903. // }
  20904. // }
  20905. // else
  20906. // {
  20907. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  20908. // //{
  20909. // cities.Add(provinceInfo);
  20910. // //}
  20911. // }
  20912. // }
  20913. // }
  20914. // }
  20915. // }
  20916. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  20917. // cities = cities.Distinct().ToList();
  20918. // districts = districts.Distinct().ToList();
  20919. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  20920. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  20921. // cities.AddRange(districts);
  20922. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  20923. // //_sqlSugar.RollbackTran();
  20924. // _sqlSugar.CommitTran();
  20925. // return Ok(JsonView(false, "操作成功!"));
  20926. //}
  20927. //[HttpPost]
  20928. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  20929. //{
  20930. // List<CountitiesInfo> infos = dto.MyProperty;
  20931. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  20932. // _sqlSugar.BeginTran();
  20933. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  20934. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  20935. // foreach (var item in infos)
  20936. // {
  20937. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  20938. // if (countryInfo != null)
  20939. // {
  20940. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  20941. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  20942. // if (cityInfo1 != null)
  20943. // {
  20944. // cityInfo1.IsCapital = 0;
  20945. // cityInfos.Add(cityInfo1);
  20946. // }
  20947. // }
  20948. // }
  20949. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  20950. // .UpdateColumns(it => it.IsCapital)
  20951. // .WhereColumns(it => it.Id)
  20952. // .ExecuteCommand();
  20953. // //_sqlSugar.RollbackTran();
  20954. // _sqlSugar.CommitTran();
  20955. // return Ok(JsonView(false, "操作成功!"));
  20956. //}
  20957. //public class CounrtiesDto
  20958. //{
  20959. // public List<CountitiesInfo> MyProperty { get; set; }
  20960. //}
  20961. //public class CountitiesInfo
  20962. //{
  20963. // /// <summary>
  20964. // /// 圣约翰
  20965. // /// </summary>
  20966. // public string capital_name_chinese { get; set; }
  20967. // /// <summary>
  20968. // ///
  20969. // /// </summary>
  20970. // public string capital_name { get; set; }
  20971. // /// <summary>
  20972. // ///
  20973. // /// </summary>
  20974. // public string country_type { get; set; }
  20975. // /// <summary>
  20976. // /// 安提瓜和巴布达
  20977. // /// </summary>
  20978. // public string country_name_chinese { get; set; }
  20979. // /// <summary>
  20980. // /// 安提瓜和巴布达
  20981. // /// </summary>
  20982. // public string country_name_chinese_short { get; set; }
  20983. // /// <summary>
  20984. // /// 安提瓜和巴布达
  20985. // /// </summary>
  20986. // public string country_name_chinese_UN { get; set; }
  20987. // /// <summary>
  20988. // ///
  20989. // /// </summary>
  20990. // public string country_name_english_abbreviation { get; set; }
  20991. // /// <summary>
  20992. // ///
  20993. // /// </summary>
  20994. // public string country_name_english_formal { get; set; }
  20995. // /// <summary>
  20996. // ///
  20997. // /// </summary>
  20998. // public string country_name_english_UN { get; set; }
  20999. // /// <summary>
  21000. // ///
  21001. // /// </summary>
  21002. // public string continent_name { get; set; }
  21003. // /// <summary>
  21004. // ///
  21005. // /// </summary>
  21006. // public string subregion_name { get; set; }
  21007. // /// <summary>
  21008. // ///
  21009. // /// </summary>
  21010. // public string country_code2 { get; set; }
  21011. // /// <summary>
  21012. // ///
  21013. // /// </summary>
  21014. // public string country_code3 { get; set; }
  21015. // /// <summary>
  21016. // ///
  21017. // /// </summary>
  21018. // public string phone_code { get; set; }
  21019. //}
  21020. //public class CountriesInfo : BasicInfo
  21021. //{
  21022. // public List<CitiesInfo> c { get; set; }
  21023. //}
  21024. //public class CitiesInfo : BasicInfo
  21025. //{
  21026. // public List<AreaInfo> c { get; set; }
  21027. //}
  21028. //public class AreaInfo : BasicInfo
  21029. //{
  21030. // public List<AreaInfo> c { get; set; }
  21031. //}
  21032. //public class BasicInfo
  21033. //{
  21034. // public string code { get; set; }
  21035. // public string cn { get; set; }
  21036. // public string lv { get; set; }
  21037. // public string en { get; set; }
  21038. //}
  21039. #endregion
  21040. #region 查看邀请方
  21041. /// <summary>
  21042. /// 查看邀请方
  21043. /// 邀请方信息 Init
  21044. /// </summary>
  21045. /// <param name="dto"></param>
  21046. /// <returns></returns>
  21047. [HttpPost]
  21048. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21049. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  21050. {
  21051. string sqlWhere = string.Empty;
  21052. if (!string.IsNullOrEmpty(dto.Search))
  21053. {
  21054. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  21055. }
  21056. string sql = string.Format($@"Select
  21057. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  21058. Id,
  21059. UnitName
  21060. From Res_InvitationOfficialActivityData
  21061. Where IsDel = 0
  21062. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  21063. RefAsync<int> total = 0;
  21064. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  21065. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  21066. }
  21067. /// <summary>
  21068. /// 查看邀请方
  21069. /// 国家信息 Init
  21070. /// </summary>
  21071. /// <param name="dto"></param>
  21072. /// <returns></returns>
  21073. [HttpPost]
  21074. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21075. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  21076. {
  21077. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  21078. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  21079. var diids = groupInfos.Select(it => it.Id).ToList();
  21080. List<string> countrys = new List<string>();
  21081. foreach (var item in country)
  21082. {
  21083. var data = _groupRepository.FormartTeamName(item);
  21084. var dataArray = _groupRepository.GroupSplitCountry(data);
  21085. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  21086. }
  21087. countrys = countrys.Distinct().ToList();
  21088. for (int i = 0; i < countrys.Count; i++)
  21089. {
  21090. string item = countrys[i];
  21091. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  21092. {
  21093. countrys.Remove(item);
  21094. i--;
  21095. }
  21096. }
  21097. RefAsync<int> total = 0;
  21098. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  21099. .Where(it => countrys.Contains(it.Name_CN))
  21100. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  21101. .Select(it => new { id = it.Id, name = it.Name_CN })
  21102. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  21103. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  21104. }
  21105. /// <summary>
  21106. /// 查看邀请方
  21107. /// 城市信息 Init
  21108. /// </summary>
  21109. /// <param name="dto"></param>
  21110. /// <returns></returns>
  21111. [HttpPost]
  21112. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21113. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  21114. {
  21115. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  21116. RefAsync<int> total = 0;
  21117. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  21118. .Where(it => it.CountriesId == dto.CountiesId)
  21119. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  21120. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  21121. .Select(it => new { id = it.Id, name = it.Name_CN })
  21122. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  21123. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  21124. }
  21125. /// <summary>
  21126. /// 查看邀请方
  21127. /// 团组名称 Init
  21128. /// </summary>
  21129. /// <param name="dto"></param>
  21130. /// <returns></returns>
  21131. [HttpPost]
  21132. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21133. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  21134. {
  21135. var watch = new Stopwatch();
  21136. watch.Start();
  21137. RefAsync<int> total = 0;
  21138. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  21139. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  21140. .Where((oa, di) => oa.IsDel == 0)
  21141. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  21142. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  21143. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  21144. .Distinct()
  21145. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  21146. watch.Stop();
  21147. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  21148. }
  21149. /// <summary>
  21150. /// 查看邀请方
  21151. /// 团组 & 邀请方信息
  21152. /// </summary>
  21153. /// <param name="dto"></param>
  21154. /// <returns></returns>
  21155. [HttpPost]
  21156. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21157. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  21158. {
  21159. var watch = new Stopwatch();
  21160. watch.Start();
  21161. RefAsync<int> total = 0;
  21162. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  21163. .AS("Grp_DelegationInfo")
  21164. .Includes(x => x.InvitingInfos)
  21165. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  21166. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  21167. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  21168. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  21169. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  21170. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  21171. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  21172. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  21173. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  21174. infos.ForEach(x =>
  21175. {
  21176. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  21177. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  21178. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  21179. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  21180. });
  21181. watch.Stop();
  21182. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  21183. }
  21184. #endregion
  21185. #region 报批行程
  21186. /// <summary>
  21187. /// 报批行程初始化
  21188. /// </summary>
  21189. /// <param name="dto"></param>
  21190. /// <returns></returns>
  21191. [HttpPost]
  21192. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  21193. {
  21194. const int chiNumber = 5;
  21195. var jw = JsonView(false);
  21196. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  21197. var group = groupList.First();
  21198. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  21199. group = groupList.First(x => x.Id == diid);
  21200. var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  21201. .Where(x => x.DiId == diid && x.IsDel == 0)
  21202. .ToArray();
  21203. var count = 1;
  21204. foreach (var item in blackCodeList)
  21205. {
  21206. if (string.IsNullOrWhiteSpace(item.Title))
  21207. {
  21208. item.Title = "未设置名称数据" + count;
  21209. }
  21210. count++;
  21211. }
  21212. ;
  21213. if (group == null)
  21214. {
  21215. jw.Msg = "暂无团组!";
  21216. return Ok(jw);
  21217. }
  21218. var data = new
  21219. {
  21220. groupList = groupList.Select(x => new
  21221. {
  21222. x.TeamName,
  21223. x.Id
  21224. }),
  21225. content = new ArrayList(),
  21226. groupInfo = new
  21227. {
  21228. group.VisitDays,
  21229. group.TourCode,
  21230. group.VisitPNumber,
  21231. group.TeamName,
  21232. group.Id,
  21233. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  21234. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd"),
  21235. group.ClientUnit
  21236. },
  21237. blackCodeList = blackCodeList.Select(x => new
  21238. {
  21239. x.Title,
  21240. x.Id
  21241. }),
  21242. FileTempList = new ArrayList()
  21243. {
  21244. new { Index = 1,FileName = "旧模板" },
  21245. new { Index = 2,FileName = "省外办" },
  21246. new { Index = 3,FileName = "市外办" },
  21247. }
  21248. };
  21249. var resultArr = new ArrayList();
  21250. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  21251. #region 默认不生成行程
  21252. //if (content.Count == 0)
  21253. //{
  21254. // var stay = "-";
  21255. // var cityPath = "-";
  21256. // var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  21257. // .Where(x => x.DiId == diid && x.IsDel == 0)
  21258. // .ToList();
  21259. // //添加城市路径以及住宿地
  21260. // //黑屏代码数据
  21261. // DataTable dtBlack = GeneralMethod.GetTableByBlackCodeById(blackCodeList.FirstOrDefault());
  21262. // if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  21263. // {
  21264. // jw = JsonView(true, "黑屏代码有误!", data);
  21265. // return Ok(jw);
  21266. // }
  21267. // data = data with
  21268. // {
  21269. // blackCodeList = new ArrayList(blackCodeList.Select(x => new
  21270. // {
  21271. // x.Title,
  21272. // x.Id,
  21273. // }).ToArray())
  21274. // };
  21275. // foreach (DataRow row in dtBlack.Rows)
  21276. // {
  21277. // if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  21278. // {
  21279. // jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  21280. // return Ok(jw);
  21281. // }
  21282. // }
  21283. // //黑屏代码获取时间区间
  21284. // var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  21285. // string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  21286. // _sqlSugar.BeginTran();
  21287. // for (int i = 0; i < timeArr.Count; i++)
  21288. // {
  21289. // stay = "-";
  21290. // cityPath = "-";
  21291. // DateTime NewData = DateTime.Parse(timeArr[i]);
  21292. // string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  21293. // Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  21294. // var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  21295. // if (tbSelect.Length > 0)
  21296. // {
  21297. // List<string> threeCodeStr = new List<string>();
  21298. // foreach (var item in tbSelect)
  21299. // {
  21300. // var threeCode = item["Three"].ToString() ?? "";
  21301. // if (threeCode.Length == 6)
  21302. // {
  21303. // var start = threeCode.Substring(0, 3);
  21304. // var end = threeCode.Substring(3, 3);
  21305. // if (threeCodeStr.Count == 0)
  21306. // {
  21307. // threeCodeStr.Add(start);
  21308. // threeCodeStr.Add(end);
  21309. // }
  21310. // else
  21311. // {
  21312. // if (threeCodeStr[threeCodeStr.Count - 1] == start)
  21313. // {
  21314. // threeCodeStr.Add(end);
  21315. // }
  21316. // else
  21317. // {
  21318. // threeCodeStr.Add(start);
  21319. // threeCodeStr.Add(end);
  21320. // }
  21321. // }
  21322. // }
  21323. // }
  21324. // var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  21325. // var last = threeCodeStr.Last();
  21326. // foreach (var item in threeCodeStr)
  21327. // {
  21328. // cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  21329. // if (item.Equals(last))
  21330. // {
  21331. // stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  21332. // }
  21333. // }
  21334. // cityPath = cityPath.Trim('-');
  21335. // }
  21336. // appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  21337. // appro.Diid = diid ?? -1;
  21338. // var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  21339. // appro.Id = thisId;
  21340. // appro.CreateUserId = dto.UserId;
  21341. // appro.CreateTime = DateTime.Now;
  21342. // content.Add(appro);
  21343. // }
  21344. // _sqlSugar.CommitTran();
  21345. //}
  21346. #endregion
  21347. foreach (var x in content)
  21348. {
  21349. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  21350. if (chiList.Count < chiNumber)
  21351. {
  21352. for (int i = chiList.Count; i < chiNumber; i++)
  21353. {
  21354. chiList.Add(new Grp_ApprovalTravelDetails());
  21355. }
  21356. }
  21357. resultArr.Add(new
  21358. {
  21359. x.Id,
  21360. x.Date,
  21361. x.Diid,
  21362. chiList = chiList.Select(x1 => new
  21363. {
  21364. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  21365. x1.Details,
  21366. x1.ParentId,
  21367. x1.Id
  21368. })
  21369. });
  21370. }
  21371. data = data with
  21372. {
  21373. content = resultArr,
  21374. };
  21375. jw = JsonView(true, "获取成功!", data);
  21376. return Ok(jw);
  21377. }
  21378. /// <summary>
  21379. /// 报批行程删除
  21380. /// </summary>
  21381. /// <param name="dto"></param>
  21382. /// <returns></returns>
  21383. [HttpPost]
  21384. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  21385. {
  21386. var jw = JsonView(false);
  21387. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  21388. if (group == null)
  21389. {
  21390. jw.Msg = "团组参数有误!";
  21391. return Ok(jw);
  21392. }
  21393. try
  21394. {
  21395. _sqlSugar.BeginTran();
  21396. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  21397. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  21398. {
  21399. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  21400. DeleteUserId = dto.uesrId,
  21401. IsDel = 1
  21402. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  21403. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  21404. {
  21405. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  21406. DeleteUserId = dto.uesrId,
  21407. IsDel = 1
  21408. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  21409. _sqlSugar.CommitTran();
  21410. jw = JsonView(true, "删除成功");
  21411. }
  21412. catch (Exception ex)
  21413. {
  21414. jw = JsonView(false, ex.Message);
  21415. }
  21416. return Ok(jw);
  21417. }
  21418. /// <summary>
  21419. /// 报批行程保存
  21420. /// </summary>
  21421. /// <param name="dto"></param>
  21422. /// <returns></returns>
  21423. [HttpPost]
  21424. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  21425. {
  21426. var jw = JsonView(false);
  21427. var Find = dto.Arr.Find(x => x.id == 0);
  21428. if (Find != null)
  21429. {
  21430. jw.Msg = "生成的ID为0!";
  21431. return Ok(jw);
  21432. }
  21433. foreach (var item in dto.Arr)
  21434. {
  21435. foreach (var chi in item.chiList)
  21436. {
  21437. if (chi.parentId == 0)
  21438. {
  21439. chi.parentId = item.id;
  21440. }
  21441. }
  21442. }
  21443. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  21444. _sqlSugar.BeginTran();
  21445. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  21446. {
  21447. var parentIds = dto.Arr.Select(x => x.id).ToList();
  21448. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  21449. {
  21450. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  21451. DeleteUserId = dto.UserId,
  21452. IsDel = 1
  21453. }).ExecuteCommand();
  21454. }
  21455. try
  21456. {
  21457. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  21458. {
  21459. CreateTime = DateTime.Now,
  21460. CreateUserId = dto.UserId,
  21461. Details = x.details,
  21462. ParentId = x.parentId,
  21463. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  21464. Remark = "",
  21465. IsDel = 0
  21466. }).ToList()).ExecuteCommand();
  21467. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  21468. {
  21469. Id = x.id,
  21470. Details = x.details,
  21471. ParentId = x.parentId,
  21472. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  21473. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  21474. {
  21475. Details = x.Details,
  21476. ParentId = x.ParentId,
  21477. Time = x.Time
  21478. }).ExecuteCommand();
  21479. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  21480. {
  21481. Id = x.id,
  21482. Date = x.date,
  21483. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  21484. {
  21485. Date = x.Date
  21486. }).ExecuteCommand();
  21487. _sqlSugar.CommitTran();
  21488. jw = JsonView(true, "保存成功!");
  21489. }
  21490. catch (Exception ex)
  21491. {
  21492. _sqlSugar.RollbackTran();
  21493. jw = JsonView(false, "保存失败!" + ex.Message);
  21494. }
  21495. return Ok(jw);
  21496. }
  21497. /// <summary>
  21498. /// 报批行程生成
  21499. /// </summary>
  21500. /// <param name="dto"></param>
  21501. /// <returns></returns>
  21502. [HttpPost]
  21503. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  21504. {
  21505. var jw = JsonView(false);
  21506. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  21507. if (group == null)
  21508. {
  21509. jw.Msg = "暂无该团组!";
  21510. return Ok(jw);
  21511. }
  21512. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().First(x => x.Id == dto.BlackCodeId && x.IsDel == 0);
  21513. //黑屏代码数据
  21514. DataTable dtBlack = GeneralMethod.GetTableByBlackCodeBySingle(blackCode);
  21515. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  21516. {
  21517. jw.Msg = "黑屏代码有误!";
  21518. return Ok(jw);
  21519. }
  21520. foreach (DataRow row in dtBlack.Rows)
  21521. {
  21522. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  21523. {
  21524. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  21525. return Ok(jw);
  21526. }
  21527. }
  21528. //var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  21529. var resultArr = new ArrayList();
  21530. //if (officialActivitiesArr.Count == 0)
  21531. //{
  21532. // jw.Msg = "暂无公务出访信息!";
  21533. // return Ok(jw);
  21534. //}
  21535. try
  21536. {
  21537. _sqlSugar.BeginTran();
  21538. DeleteApprovalJourney(new
  21539. Domain.Dtos.Groups.DeleteApprovalJourney
  21540. {
  21541. Diid = dto.Diid,
  21542. uesrId = dto.Userid
  21543. });
  21544. var stay = "-";
  21545. var cityPath = "-";
  21546. var arriveCountry = string.Empty;
  21547. //添加城市路径以及住宿地
  21548. //黑屏代码获取时间区间
  21549. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  21550. var empty = "【未收入该三字码!请机票同事录入】";
  21551. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  21552. #region 配置公务活动时间
  21553. List<Tuple<int, string, string>> Times = new List<Tuple<int, string, string>>();
  21554. Times.Add(new Tuple<int, string, string>(9, "9:00", "10:30"));
  21555. Times.Add(new Tuple<int, string, string>(11, "11:00", "12:00"));
  21556. Times.Add(new Tuple<int, string, string>(14, "14:00", "15:30"));
  21557. Times.Add(new Tuple<int, string, string>(16, "16:00", "17:00"));
  21558. List<Tuple<DateTime, List<string>>> fallTimesCheckCountry = new List<Tuple<DateTime, List<string>>>()
  21559. {
  21560. 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" }),
  21561. 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"}),
  21562. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,11,30,0), new List<string>{"14:00-15:30","16:00-17:00"}),
  21563. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,13,30,0), new List<string>{"16:30-17:30"}),
  21564. };
  21565. List<Tuple<DateTime, List<string>>> fallTimesNotCheckCountry = new List<Tuple<DateTime, List<string>>>()
  21566. {
  21567. 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" }),
  21568. 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"}),
  21569. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,11,30,0), new List<string>{"14:00-15:30","16:00-17:00"}),
  21570. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,14,30,0), new List<string>{"16:30-17:30"}),
  21571. };
  21572. List<Tuple<DateTime, List<string>>> takeoffTimes = new List<Tuple<DateTime, List<string>>>()
  21573. {
  21574. 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" }),
  21575. 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"}),
  21576. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,14,00,0), new List<string>{"9:00-10:30", "11:00-12:00",}),
  21577. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,12,00,0), new List<string>{"09:00-10:00"}),
  21578. };
  21579. #endregion
  21580. var nextDayNum = 0;
  21581. for (int i = 0; i < timeArr.Count; i++)
  21582. {
  21583. stay = "-";
  21584. cityPath = "-";
  21585. var chiarr = new List<Grp_ApprovalTravelDetails>();
  21586. DateTime NewData = DateTime.Parse(timeArr[i]);
  21587. //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();
  21588. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  21589. if (nextDayNum > 0)
  21590. {
  21591. nextDayNum--;
  21592. }
  21593. if (tbSelect.Length > 0)
  21594. {
  21595. List<string> threeCodeStr = new List<string>();
  21596. bool isTrade = false;
  21597. string trip = string.Empty;
  21598. foreach (var item in tbSelect)
  21599. {
  21600. if (nextDayNum == 0)
  21601. {
  21602. nextDayNum = Convert.ToInt32(item["Sign"]);
  21603. }
  21604. var airStartTime = item["StartTime"].ToString() ?? "0000";
  21605. var airEndTime = item["EndTime"].ToString() ?? "0000";
  21606. var takeOffTime = DateTime.Parse(timeArr[i]);
  21607. var fallToTime = DateTime.Parse(timeArr[i]);
  21608. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  21609. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  21610. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  21611. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  21612. if (nextDayNum > 0)
  21613. {
  21614. fallToTime = fallToTime.AddDays(nextDayNum);
  21615. }
  21616. trip = string.Empty;
  21617. var start = string.Empty;
  21618. var end = string.Empty;
  21619. var threeCode = item["Three"].ToString() ?? "";
  21620. if (threeCode.Length == 6)
  21621. {
  21622. start = threeCode.Substring(0, 3);
  21623. end = threeCode.Substring(3, 3);
  21624. if (threeCodeStr.Count == 0)
  21625. {
  21626. threeCodeStr.Add(start);
  21627. threeCodeStr.Add(end);
  21628. }
  21629. else
  21630. {
  21631. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  21632. {
  21633. threeCodeStr.Add(end);
  21634. }
  21635. else
  21636. {
  21637. threeCodeStr.Add(start);
  21638. threeCodeStr.Add(end);
  21639. }
  21640. }
  21641. }
  21642. //处理机票信息
  21643. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  21644. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  21645. if (start_Object == null)
  21646. {
  21647. start_Object = new Res_ThreeCode()
  21648. {
  21649. AirPort = empty,
  21650. AirPort_En = empty,
  21651. City = empty,
  21652. Country = empty,
  21653. Four = empty,
  21654. Three = empty,
  21655. };
  21656. }
  21657. if (end_Object == null)
  21658. {
  21659. end_Object = new Res_ThreeCode()
  21660. {
  21661. AirPort = empty,
  21662. AirPort_En = empty,
  21663. City = empty,
  21664. Country = empty,
  21665. Four = empty,
  21666. Three = empty,
  21667. };
  21668. }
  21669. //机型判断
  21670. string airModel = item["AirModel"].ToString();
  21671. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  21672. string flightTime = item["FlightTime"].ToString();
  21673. flightTime = ParseBlackTime(flightTime);
  21674. //航班号
  21675. string flightcode = item["Fliagtcode"].ToString();
  21676. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  21677. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  21678. if (aircompany == null)
  21679. {
  21680. aircompany = new Res_AirCompany
  21681. {
  21682. CnName = hsEmpty,
  21683. EnName = hsEmpty,
  21684. ShortCode = hsEmpty,
  21685. };
  21686. }
  21687. //航班前公务安排
  21688. if (tbSelect.First().Equals(item) && i != 0)
  21689. {
  21690. foreach (var takeoff in takeoffTimes)
  21691. {
  21692. var takeoffItem1 = NewData.AddHours(takeoff.Item1.Hour).AddMinutes(takeoff.Item1.Minute);
  21693. if (DateTime.Compare(takeOffTime, takeoffItem1) > 0)
  21694. {
  21695. foreach (var addTime in takeoff.Item2)
  21696. {
  21697. chiarr.Add(new Grp_ApprovalTravelDetails
  21698. {
  21699. Time = addTime,
  21700. CreateTime = DateTime.Now,
  21701. CreateUserId = dto.Userid,
  21702. ParentId = 0,
  21703. Details = "公务活动"
  21704. });
  21705. }
  21706. break;
  21707. }
  21708. }
  21709. }
  21710. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  21711. //trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName}{flightcode}飞往{end_Object.City}。\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  21712. //乘坐四川航空3U3901次航班由成都飞往加德满都,3小时25分钟
  21713. trip += $"乘坐{aircompany.CnName}{flightcode}次航班由{start_Object.City}飞往{end_Object.City},{flightTime}";
  21714. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  21715. if (isTrade)
  21716. {
  21717. //trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  21718. trip += "(转机不出机场)。";
  21719. }
  21720. //else
  21721. //{
  21722. // trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  21723. //}
  21724. chiarr.Add(new Grp_ApprovalTravelDetails
  21725. {
  21726. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  21727. CreateTime = DateTime.Now,
  21728. CreateUserId = dto.Userid,
  21729. ParentId = 0,
  21730. Details = trip
  21731. });
  21732. //最后一条到达的时间安排公务
  21733. if (tbSelect.Last().Equals(item) && i != timeArr.Count - 1)
  21734. {
  21735. bool isCheckCountry = false;
  21736. if (end_Object.Country != arriveCountry)
  21737. {
  21738. arriveCountry = end_Object.Country;
  21739. isCheckCountry = true;
  21740. }
  21741. if (nextDayNum == 0)
  21742. {
  21743. //需要入境的情况
  21744. if (isCheckCountry)
  21745. {
  21746. foreach (var fallTime in fallTimesCheckCountry)
  21747. {
  21748. var fallTimeItem1 = NewData.AddHours(fallTime.Item1.Hour).AddMinutes(fallTime.Item1.Minute);
  21749. if (DateTime.Compare(fallToTime, fallTimeItem1) < 0)
  21750. {
  21751. foreach (var addTime in fallTime.Item2)
  21752. {
  21753. chiarr.Add(new Grp_ApprovalTravelDetails
  21754. {
  21755. Time = addTime,
  21756. CreateTime = DateTime.Now,
  21757. CreateUserId = dto.Userid,
  21758. ParentId = 0,
  21759. Details = "公务活动"
  21760. });
  21761. }
  21762. break;
  21763. }
  21764. }
  21765. }
  21766. else
  21767. {
  21768. foreach (var fallTime in fallTimesNotCheckCountry)
  21769. {
  21770. var fallTimeItem1 = NewData.AddHours(fallTime.Item1.Hour).AddMinutes(fallTime.Item1.Minute);
  21771. if (DateTime.Compare(fallToTime, fallTimeItem1) < 0)
  21772. {
  21773. foreach (var addTime in fallTime.Item2)
  21774. {
  21775. chiarr.Add(new Grp_ApprovalTravelDetails
  21776. {
  21777. Time = addTime,
  21778. CreateTime = DateTime.Now,
  21779. CreateUserId = dto.Userid,
  21780. ParentId = 0,
  21781. Details = "公务活动"
  21782. });
  21783. }
  21784. break;
  21785. }
  21786. }
  21787. }
  21788. }
  21789. }
  21790. }
  21791. //添加乘车语句
  21792. //chiarr.Add(new Grp_ApprovalTravelDetails
  21793. //{
  21794. // Time = (fallToTime.AddHours(2.5).ToString("HH:mm") + "-" + fallToTime.AddHours(3).ToString("HH:mm")),
  21795. // CreateTime = DateTime.Now,
  21796. // CreateUserId = dto.Userid,
  21797. // ParentId = 0,
  21798. // Details = "乘车前往市区(约xx公里,大约需要xx分钟)"
  21799. //});
  21800. //if (i != timeArr.Count - 1)
  21801. //{
  21802. // fallToTime = fallToTime.AddHours(2.5);
  21803. // foreach (var item in Times)
  21804. // {
  21805. // //排列公务时间
  21806. // if (fallToTime.Hour < item.Item1)
  21807. // {
  21808. // chiarr.Add(new Grp_ApprovalTravelDetails
  21809. // {
  21810. // Time = $"{item.Item2} - {item.Item3}",
  21811. // CreateTime = DateTime.Now,
  21812. // CreateUserId = dto.Userid,
  21813. // ParentId = 0,
  21814. // Details = "公务活动"
  21815. // });
  21816. // }
  21817. // }
  21818. //}
  21819. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  21820. var last = threeCodeStr.Last();
  21821. foreach (var item in threeCodeStr)
  21822. {
  21823. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  21824. if (item.Equals(last))
  21825. {
  21826. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  21827. }
  21828. }
  21829. cityPath = cityPath.Trim('-');
  21830. }
  21831. else
  21832. {
  21833. foreach (var item in Times)
  21834. {
  21835. chiarr.Add(new Grp_ApprovalTravelDetails
  21836. {
  21837. Time = $"{item.Item2} - {item.Item3}",
  21838. CreateTime = DateTime.Now,
  21839. CreateUserId = dto.Userid,
  21840. ParentId = 0,
  21841. Details = "公务活动"
  21842. });
  21843. }
  21844. }
  21845. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  21846. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  21847. appro.Date = NewData.Month + "月" + NewData.Day + "日(" + week + ")" + "第" + intToString(i + 1) + "天 ";
  21848. appro.Diid = dto.Diid;
  21849. appro.CreateUserId = dto.Userid;
  21850. appro.CreateTime = DateTime.Now;
  21851. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  21852. appro.Id = thisId;
  21853. //foreach (var item in gwinfo)
  21854. //{
  21855. // Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  21856. // chi.Details = "拜访" + item.Client;
  21857. // if (!string.IsNullOrWhiteSpace(item.ReqSample))
  21858. // {
  21859. // chi.Details += "," + item.ReqSample;
  21860. // }
  21861. // chi.ParentId = thisId;
  21862. // chi.Time = item.Time;
  21863. // chiarr.Add(chi);
  21864. //}
  21865. if (chiarr.Count < 6)
  21866. {
  21867. for (int j = chiarr.Count; j < 6; j++)
  21868. {
  21869. chiarr.Add(new
  21870. Grp_ApprovalTravelDetails());
  21871. }
  21872. }
  21873. resultArr.Add(new
  21874. {
  21875. appro.Id,
  21876. appro.Date,
  21877. appro.Diid,
  21878. chiList = chiarr.Select(x1 => new
  21879. {
  21880. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  21881. x1.Details,
  21882. x1.ParentId,
  21883. x1.Id
  21884. })
  21885. });
  21886. }
  21887. _sqlSugar.CommitTran();
  21888. jw = JsonView(true, "生成成功!", resultArr);
  21889. }
  21890. catch (Exception ex)
  21891. {
  21892. jw.Code = 400;
  21893. jw.Msg = "生成失败!" + ex.Message;
  21894. }
  21895. return Ok(jw);
  21896. }
  21897. /// <summary>
  21898. /// 报批行程word导出
  21899. /// </summary>
  21900. /// <param name="dto"></param>
  21901. /// <returns></returns>
  21902. [HttpPost]
  21903. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  21904. {
  21905. var jw = JsonView(false);
  21906. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  21907. if (group == null)
  21908. {
  21909. jw.Msg = "暂无该团组!";
  21910. return Ok(jw);
  21911. }
  21912. //模板路径
  21913. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/";
  21914. var fileName = string.Empty;
  21915. string titleFont = string.Empty, timeFont = string.Empty, contentFont = string.Empty;
  21916. bool bold = false;
  21917. if (dto.FileIndex == 1)
  21918. {
  21919. fileName = "公务行程导出模板.docx"; //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  21920. }
  21921. else if (dto.FileIndex == 2)
  21922. {
  21923. fileName = "省外办-报批.docx";
  21924. bold = false;
  21925. titleFont = "方正黑体简体";
  21926. timeFont = "Times New Roman";
  21927. contentFont = "方正仿宋_GBK";
  21928. }
  21929. else if (dto.FileIndex == 3)
  21930. {
  21931. fileName = "市外办-报批.docx";
  21932. titleFont = "方正黑体简体";
  21933. timeFont = "Times New Roman";
  21934. contentFont = "方正仿宋简体";
  21935. }
  21936. tempPath = tempPath + fileName;
  21937. //载入模板
  21938. Document doc = new Document(tempPath);
  21939. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  21940. //获取所填表格的序数
  21941. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  21942. Aspose.Words.Tables.Row titleRowClone = null;
  21943. Aspose.Words.Tables.Row CenterRowClone = null;
  21944. int index = 0;
  21945. int indexChi = 0;
  21946. int SetIndex = 0;
  21947. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  21948. //获取数据,放到datatable
  21949. foreach (var item in ApprovalTravelArr)
  21950. {
  21951. if (index > 0)
  21952. {
  21953. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  21954. tableOne.AppendChild(titleRowClone);
  21955. }
  21956. var textTime = item.Date;
  21957. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  21958. SetCells(tableOne, doc, SetIndex, 0, textTime, titleFont, bold);
  21959. SetIndex++;
  21960. if (ChiRep.Count > 0)
  21961. {
  21962. foreach (var itemChi in ChiRep)
  21963. {
  21964. var txtTime = itemChi.Time;
  21965. var txtDetail = itemChi.Details;
  21966. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  21967. {
  21968. //SetCells(tableOne, doc, SetIndex, 0, "", timeFont, bold);
  21969. //SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  21970. //indexChi++;
  21971. //SetIndex++;
  21972. break;
  21973. }
  21974. if (indexChi > 0)
  21975. {
  21976. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  21977. tableOne.AppendChild(CenterRowClone);
  21978. }
  21979. SetCells(tableOne, doc, SetIndex, 0, txtTime, timeFont, bold);
  21980. SetCells(tableOne, doc, SetIndex, 1, txtDetail, contentFont, bold);
  21981. indexChi++;
  21982. SetIndex++;
  21983. }
  21984. }
  21985. //else
  21986. //{
  21987. // if (indexChi > 0)
  21988. // {
  21989. // CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  21990. // tableOne.AppendChild(CenterRowClone);
  21991. // }
  21992. // SetCells(tableOne, doc, SetIndex, 0, "",timeFont, bold);
  21993. // SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  21994. // indexChi++;
  21995. // SetIndex++;
  21996. //}
  21997. index++;
  21998. }
  21999. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + fileName;
  22000. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName, Aspose.Words.SaveFormat.Docx); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  22001. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  22002. jw.Code = 200;
  22003. jw.Msg = "";
  22004. return Ok(jw);
  22005. }
  22006. private string ParseBlackTime(string time)
  22007. {
  22008. // 匹配可能只有分钟的情况
  22009. string pattern = @"(?:(\d+)H)?(?:(\d+)M)?";
  22010. System.Text.RegularExpressions.Match match = Regex.Match(time, pattern);
  22011. if (match.Success)
  22012. {
  22013. string hours = match.Groups[1].Value;
  22014. string minutes = match.Groups[2].Value;
  22015. // 如果小时部分为空,则只显示分钟
  22016. if (string.IsNullOrEmpty(hours))
  22017. {
  22018. return $"{minutes}分钟";
  22019. }
  22020. // 如果分钟部分为空,则只显示小时
  22021. else if (string.IsNullOrEmpty(minutes))
  22022. {
  22023. return $"{hours}小时";
  22024. }
  22025. // 否则显示完整格式
  22026. else
  22027. {
  22028. return $"{hours}小时{minutes}分钟";
  22029. }
  22030. }
  22031. else
  22032. {
  22033. return "未知时长";
  22034. }
  22035. }
  22036. private string intToString(int numberVal)
  22037. {
  22038. string numberval = numberVal.ToString();
  22039. Dictionary<char, string> Number = new Dictionary<char, string>();
  22040. Number.Add('1', "一");
  22041. Number.Add('2', "二");
  22042. Number.Add('3', "三");
  22043. Number.Add('4', "四");
  22044. Number.Add('5', "五");
  22045. Number.Add('6', "六");
  22046. Number.Add('7', "七");
  22047. Number.Add('8', "八");
  22048. Number.Add('9', "九");
  22049. string stringNumberVal = string.Empty;
  22050. for (int i = 0; i < numberval.Length; i++)
  22051. {
  22052. if (i == 0)
  22053. {
  22054. stringNumberVal += Number[numberval[i]];
  22055. }
  22056. else if (i >= 1)
  22057. {
  22058. if (numberval[i] == '0')
  22059. {
  22060. stringNumberVal = "十";
  22061. }
  22062. else
  22063. {
  22064. stringNumberVal += "十" + Number[numberval[i]];
  22065. }
  22066. }
  22067. }
  22068. return stringNumberVal;
  22069. }
  22070. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val, string font, bool bold)
  22071. {
  22072. //获取table中的某个单元格,从0开始
  22073. Cell lshCell = table.Rows[rows].Cells[cells];
  22074. //将单元格中段落移除
  22075. foreach (Paragraph item in lshCell.Paragraphs)
  22076. {
  22077. lshCell.Paragraphs.Remove(item);
  22078. }
  22079. if (val.Contains("\r\n"))
  22080. {
  22081. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  22082. foreach (var item in spArr)
  22083. {
  22084. //新建一个段落
  22085. Paragraph p = new Paragraph(doc);
  22086. var r = new Run(doc, item);
  22087. //设置字体
  22088. if (!string.IsNullOrEmpty(font))
  22089. {
  22090. r.Font.Name = font;
  22091. }
  22092. r.Font.Bold = bold;
  22093. //把设置的值赋给之前新建的段落
  22094. p.AppendChild(r);
  22095. //将此段落加到单元格内
  22096. lshCell.AppendChild(p);
  22097. }
  22098. }
  22099. else
  22100. {
  22101. //新建一个段落
  22102. Paragraph p = new Paragraph(doc);
  22103. var r = new Run(doc, val);
  22104. //设置字体
  22105. if (!string.IsNullOrEmpty(font))
  22106. {
  22107. r.Font.Name = font;
  22108. }
  22109. r.Font.Bold = bold;
  22110. //把设置的值赋给之前新建的段落
  22111. p.AppendChild(r);
  22112. //将此段落加到单元格内
  22113. lshCell.AppendChild(p);
  22114. }
  22115. }
  22116. /// <summary>
  22117. /// 报批行程AI续写
  22118. /// </summary>
  22119. /// <returns></returns>
  22120. [HttpPost]
  22121. public async Task<IActionResult> ApprovalJourneyAiWrite(ApprovalJourneyAiWriteDto dto)
  22122. {
  22123. var jw = JsonView(false);
  22124. if (dto.ClientPurpose.IsNullOrWhiteSpace() || dto.ClientName.IsNullOrWhiteSpace())
  22125. {
  22126. jw.Msg = "参数有误!";
  22127. return Ok(jw);
  22128. }
  22129. KiMiApiClient kiMi = new KiMiApiClient();
  22130. List<SeedMessages> messages = new List<SeedMessages>() {
  22131. new SeedMessages
  22132. {
  22133. Role = KimiRole.system,
  22134. Content = "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长中文和英文的对话。你会为用户提供安全,有帮助,准确的回答。"
  22135. },
  22136. new SeedMessages
  22137. {
  22138. Role = KimiRole.user,
  22139. Content = $@"参考这个模板格式来编写一份{dto.ClientName}拜访{dto.ClientPurpose},结合{dto.ClientName}的业务,描述拜访目的,字数在200字内(直接给出拜访目的,不输出其他内容)"
  22140. }
  22141. };
  22142. var kimi_result = await kiMi.SeedMessageByFullConterObject(messages);
  22143. string data = kimi_result.Choices[0]?.Message.Content;
  22144. if (string.IsNullOrWhiteSpace(data))
  22145. {
  22146. jw.Data = "Ai续写失败!";
  22147. }
  22148. else
  22149. {
  22150. jw = JsonView(true, "success!", data);
  22151. }
  22152. return Ok(jw);
  22153. }
  22154. #endregion
  22155. #region 团组接待意见调查
  22156. /// <summary>
  22157. /// 团组接待意见调查 - 信息管理
  22158. /// 基础数据(团组)
  22159. /// </summary>
  22160. /// <returns></returns>
  22161. [HttpGet]
  22162. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22163. public async Task<IActionResult> OpinionaireInit()
  22164. {
  22165. var groupData = await _groupRepository.Query(x => x.IsDel == 0)
  22166. .Select(x => new
  22167. {
  22168. x.Id,
  22169. GroupName = $"[{x.VisitDate.ToString("yyyy-MM-dd")}]{x.TeamName}"
  22170. })
  22171. .OrderByDescending(x => x.Id)
  22172. .ToListAsync();
  22173. return Ok(JsonView(groupData, groupData.Count));
  22174. }
  22175. /// <summary>
  22176. /// 团组接待意见调查 - 信息管理
  22177. /// 列表
  22178. /// </summary>
  22179. /// <param name="groupId"></param>
  22180. /// <returns></returns>
  22181. [HttpGet("{groupId}")]
  22182. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22183. public async Task<IActionResult> OpinionaireManageList(int groupId)
  22184. {
  22185. if (groupId < 1) Ok(JsonView(false, "请传入有效的diId"));
  22186. var data = await _opinionaireRep.Query(x => x.DiId == groupId)
  22187. .Select(x => new
  22188. {
  22189. x.Id,
  22190. x.TourGuideName,
  22191. x.CityName,
  22192. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x.CreateUserId == x1.Id).Select(x1 => x1.CnName),
  22193. x.CreateTime
  22194. })
  22195. .OrderBy(x => x.Id)
  22196. .ToListAsync();
  22197. return Ok(JsonView(data));
  22198. }
  22199. /// <summary>
  22200. /// 团组接待意见调查 - 信息管理
  22201. /// 保存
  22202. /// </summary>
  22203. /// <param name="dto"></param>
  22204. /// <returns></returns>
  22205. [HttpPost]
  22206. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22207. public async Task<IActionResult> OpinionaireManageSave(OpinionaireManageSaveDto dto)
  22208. {
  22209. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  22210. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  22211. if (dto.DiId < 1) Ok(JsonView(false, "请传入有效的diId"));
  22212. if (dto.Items.Length < 1) Ok(JsonView(false, "请传入需要保存的信息"));
  22213. var addData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id == 0).ToList());
  22214. var updData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id > 0).ToList());
  22215. _opinionaireRep.BeginTran();
  22216. if (addData != null && addData.Count > 0)
  22217. {
  22218. foreach (var item in addData)
  22219. {
  22220. item.CreateUserId = currUserInfo.UserId;
  22221. item.DiId = dto.DiId;
  22222. }
  22223. var add = await _opinionaireRep._sqlSugar.Insertable(addData).ExecuteCommandAsync();
  22224. }
  22225. if (updData != null && updData.Count > 0)
  22226. {
  22227. var upd = await _opinionaireRep._sqlSugar
  22228. .Updateable(updData)
  22229. .UpdateColumns(x => new { x.CityName, x.TourGuideName })
  22230. .WhereColumns(x => new { x.Id })
  22231. .ExecuteCommandAsync();
  22232. }
  22233. _opinionaireRep.CommitTran();
  22234. return Ok(JsonView("操作成功!"));
  22235. }
  22236. /// <summary>
  22237. /// 团组接待意见调查 - 信息管理
  22238. /// 删除
  22239. /// </summary>
  22240. /// <param name="id"></param>
  22241. /// <returns></returns>
  22242. [HttpDelete("{id}")]
  22243. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22244. public async Task<IActionResult> OpinionaireManageDel(int id)
  22245. {
  22246. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  22247. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  22248. if (id < 1) Ok(JsonView(false, "请传入有效的id"));
  22249. var del = await _opinionaireRep.SoftDeleteAsync(x => x.Id == id, currUserInfo.UserId);
  22250. if (!del) return Ok(JsonView("操作失败!"));
  22251. return Ok(JsonView("操作成功!"));
  22252. }
  22253. /// <summary>
  22254. /// 团组接待意见调查 - 用户
  22255. /// 列表
  22256. /// </summary>
  22257. /// <param name="diId"></param>
  22258. /// <returns></returns>
  22259. [HttpGet("{diId}")]
  22260. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22261. public async Task<IActionResult> OpinionaireUserList(int diId)
  22262. {
  22263. if (diId < 1) Ok(JsonView(false, "请传入有效的diId"));
  22264. var sql = string.Format(@"
  22265. SELECT
  22266. o.Id,
  22267. o.DiId,
  22268. di.TeamName AS 'GroupName',
  22269. di.VisitPNumber AS 'PeopleNumber',
  22270. di.ClientName AS 'LeadGroup',
  22271. di.VisitCountry AS 'Travel',
  22272. di.VisitDays AS 'Days',
  22273. o.CityName,
  22274. o.TourGuideName,
  22275. o.Catering,
  22276. o.CateringReason,
  22277. o.Stay,
  22278. o.StayReason,
  22279. o.[Route],
  22280. o.RouteReason,
  22281. o.OfficialActivity,
  22282. o.OfficialActivityReason,
  22283. o.TourGuide,
  22284. o.TourGuideReason,
  22285. o.[Translate],
  22286. o.TranslateReason,
  22287. o.Trip,
  22288. o.TripReason,
  22289. o.ESFileName,
  22290. o.SignatureDate,
  22291. o.Remark
  22292. FROM
  22293. Grp_Opinionaire o
  22294. LEFT JOIN Grp_DelegationInfo di ON o.DiId = di.Id
  22295. WHERE
  22296. o.IsDel = 0
  22297. AND o.DiId = {0}
  22298. ORDER BY
  22299. o.Id ASC", diId);
  22300. var data = await _sqlSugar.SqlQueryable<OpinionaireUserListView>(sql).ToListAsync();
  22301. if (data.Count < 1) return Ok(JsonView(false, "暂无数据"));
  22302. return Ok(JsonView(data));
  22303. }
  22304. /// <summary>
  22305. /// 团组接待意见调查 - 用户
  22306. /// 保存
  22307. /// </summary>
  22308. /// <param name="dto"></param>
  22309. /// <returns></returns>
  22310. [HttpPost]
  22311. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22312. public async Task<IActionResult> OpinionaireUserSave([FromForm] OpinionaireUserSaveInfo[] dto)
  22313. {
  22314. if (dto.Length < 1) Ok(JsonView(false, "请传入有效的参数"));
  22315. foreach (var item in dto)
  22316. {
  22317. if (string.IsNullOrEmpty(item.Catering)) Ok(JsonView(false, "请选择餐饮评分!"));
  22318. if (string.IsNullOrEmpty(item.Stay)) Ok(JsonView(false, "请选择住宿评分!"));
  22319. if (string.IsNullOrEmpty(item.Route)) Ok(JsonView(false, "请选择行程评分!"));
  22320. if (string.IsNullOrEmpty(item.OfficialActivity)) Ok(JsonView(false, "请选择公务活动评分!"));
  22321. if (string.IsNullOrEmpty(item.Translate)) Ok(JsonView(false, "请选择翻译评分!"));
  22322. if (string.IsNullOrEmpty(item.Trip)) Ok(JsonView(false, "请选择行程评分!"));
  22323. if (string.IsNullOrEmpty(item.SignatureDate)) Ok(JsonView(false, "请填写签名日期!"));
  22324. if (item.File.Length < 1) Ok(JsonView(false, "请上传签名图片!"));
  22325. }
  22326. var filePathBase = $"{AppSettingsHelper.Get("GrpFileBasePath")}OpinionaireElectronicSignature";
  22327. if (!Directory.Exists(filePathBase))
  22328. {
  22329. Directory.CreateDirectory(filePathBase);
  22330. }
  22331. #region 上传文件
  22332. var filePaths = new List<string>();
  22333. foreach (var item in dto)
  22334. {
  22335. var file = item.File;
  22336. // 将文件保存到指定位置
  22337. var filePath = Path.Combine(filePathBase, file.FileName);
  22338. using (var stream = new FileStream(filePath, FileMode.Create))
  22339. {
  22340. await file.CopyToAsync(stream);
  22341. }
  22342. //验证文件是否上传成功
  22343. if (!System.IO.File.Exists(filePath))
  22344. {
  22345. foreach (var filePathStr in filePaths)
  22346. {
  22347. System.IO.File.Delete(filePathStr);
  22348. }
  22349. return Ok(JsonView(false, "文件上传失败!"));
  22350. }
  22351. item.ESFileName = file.FileName;
  22352. }
  22353. #endregion
  22354. var infos = _mapper.Map<List<Grp_Opinionaire>>(dto);
  22355. var upd = await _sqlSugar.Updateable<Grp_Opinionaire>(infos)
  22356. .UpdateColumns(x => new
  22357. {
  22358. x.Catering,
  22359. x.CateringReason,
  22360. x.Stay,
  22361. x.StayReason,
  22362. x.Route,
  22363. x.RouteReason,
  22364. x.OfficialActivity,
  22365. x.OfficialActivityReason,
  22366. x.TourGuide,
  22367. x.TourGuideReason,
  22368. x.Translate,
  22369. x.TranslateReason,
  22370. x.Trip,
  22371. x.TripReason,
  22372. x.ESFileName,
  22373. x.SignatureDate,
  22374. x.Remark
  22375. })
  22376. .WhereColumns(x => new { x.Id })
  22377. .ExecuteCommandAsync();
  22378. if (upd < 1)
  22379. {
  22380. foreach (var filePathStr in filePaths)
  22381. {
  22382. System.IO.File.Delete(filePathStr);
  22383. }
  22384. return Ok(JsonView(false));
  22385. }
  22386. return Ok(JsonView(true));
  22387. }
  22388. #endregion
  22389. #region 团组餐厅相关信息
  22390. /// <summary>
  22391. /// 团组相关餐厅信息
  22392. /// 基础数据(团组)
  22393. /// </summary>
  22394. /// <returns></returns>
  22395. [HttpGet]
  22396. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22397. public async Task<IActionResult> RestaurantInit()
  22398. {
  22399. return Ok(await _restaurantRep.InitAsync());
  22400. }
  22401. /// <summary>
  22402. /// 团组相关餐厅信息
  22403. /// Item
  22404. /// </summary>
  22405. /// <param name="dto"></param>
  22406. /// <returns></returns>
  22407. [HttpPost]
  22408. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22409. public async Task<IActionResult> RestaurantItem(RestaurantItemDto dto)
  22410. {
  22411. int portType = dto.PortType,
  22412. groupId = dto.GroupId;
  22413. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  22414. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  22415. return Ok(await _restaurantRep.ItemAsync(portType, groupId));
  22416. }
  22417. /// <summary>
  22418. /// 团组相关餐厅信息
  22419. /// List
  22420. /// </summary>
  22421. /// <param name="dto"></param>
  22422. /// <returns></returns>
  22423. [HttpPost]
  22424. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22425. public async Task<IActionResult> RestaurantList(RestaurantItemDto dto)
  22426. {
  22427. int portType = dto.PortType,
  22428. groupId = dto.GroupId;
  22429. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  22430. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  22431. var sql = string.Format(@" SELECT
  22432. ri.Id,
  22433. ri.GroupId,
  22434. ri.Date,
  22435. ri.StartTime,
  22436. ri.EndTime,
  22437. CASE WHEN ri.Type = 1 THEN '早餐'
  22438. WHEN ri.Type = 2 THEN '午餐'
  22439. WHEN ri.Type = 3 THEN '晚餐'
  22440. ELSE '其他'
  22441. END AS 'Type',
  22442. ri.Name,
  22443. ri.Address,
  22444. ri.Tel,
  22445. ri.Remark,
  22446. ri.CreateTime,
  22447. u.CnName AS CreateUserName
  22448. FROM
  22449. Grp_RestaurantInfo ri
  22450. LEFT JOIN Sys_Users u ON ri.CreateUserId = u.Id
  22451. WHERE
  22452. ri.IsDel = 0
  22453. AND ri.GroupId = {0}
  22454. ORDER BY
  22455. ri.Date ASC
  22456. ", groupId);
  22457. var infos = await _sqlSugar.SqlQueryable<RestaurantItemView>(sql).ToListAsync();
  22458. if (!infos.Any()) Ok(JsonView(false, "数据未填写!"));
  22459. return Ok(JsonView(infos));
  22460. }
  22461. /// <summary>
  22462. /// 团组相关餐厅信息
  22463. /// Info
  22464. /// </summary>
  22465. /// <param name="dto"></param>
  22466. /// <returns></returns>
  22467. [HttpPost]
  22468. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22469. public async Task<IActionResult> RestaurantInfo(RestaurantInfoDto dto)
  22470. {
  22471. int portType = dto.PortType,
  22472. id = dto.Id;
  22473. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  22474. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  22475. return Ok(await _restaurantRep.InfoAsync(portType, id));
  22476. }
  22477. /// <summary>
  22478. /// 团组相关餐厅信息
  22479. /// Op
  22480. /// </summary>
  22481. /// <param name="dto"></param>
  22482. /// <returns></returns>
  22483. [HttpPost]
  22484. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22485. public async Task<IActionResult> RestaurantOp(RestaurantOpDto dto)
  22486. {
  22487. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  22488. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  22489. if (string.IsNullOrEmpty(dto.Name)) return Ok(JsonView(false, "餐厅名称为空!"));
  22490. return Ok(await _restaurantRep.OpAsync(dto));
  22491. }
  22492. /// <summary>
  22493. /// 团组相关餐厅信息
  22494. /// Del
  22495. /// </summary>
  22496. /// <param name="dto"></param>
  22497. /// <returns></returns>
  22498. [HttpPost]
  22499. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22500. public async Task<IActionResult> RestaurantDel(RestaurantDelDto dto)
  22501. {
  22502. int userId = dto.DeleteUserId;
  22503. var id = dto.Id;
  22504. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  22505. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  22506. return Ok(await _restaurantRep.DelAsync(dto));
  22507. }
  22508. #endregion
  22509. /// <summary>
  22510. /// 123132123
  22511. /// </summary>
  22512. /// <param name="_dto"></param>
  22513. /// <returns></returns>
  22514. [HttpPost]
  22515. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22516. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  22517. {
  22518. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  22519. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  22520. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  22521. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  22522. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  22523. dicDetail.Add(789, 1034);
  22524. dicDetail.Add(790, 1035);
  22525. dicDetail.Add(791, 1036);
  22526. dicDetail.Add(792, 1037);
  22527. dicDetail.Add(793, 1038);
  22528. dicDetail.Add(794, 1039);
  22529. dicDetail.Add(795, 1040);
  22530. dicDetail.Add(796, 1041);
  22531. dicDetail.Add(797, 1042);
  22532. dicDetail.Add(798, 1043);
  22533. dicDetail.Add(801, 1044);
  22534. dicDetail.Add(802, 1045);
  22535. dicDetail.Add(803, 1046);
  22536. Dictionary<int, int> dic = new Dictionary<int, int>();
  22537. dic.Add(806, 1027);
  22538. dic.Add(807, 1028);
  22539. dic.Add(808, 1029);
  22540. dic.Add(809, 1030);
  22541. dic.Add(810, 1031);
  22542. dic.Add(811, 1032);
  22543. dic.Add(812, 1033);
  22544. foreach (var item in list_visa)
  22545. {
  22546. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  22547. temp.Coefficient = item.coefficient;
  22548. DateTime dtCrt;
  22549. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  22550. if (b1)
  22551. {
  22552. temp.CreateTime = dtCrt;
  22553. }
  22554. else
  22555. {
  22556. temp.CreateTime = DateTime.Now;
  22557. }
  22558. temp.CreateUserId = item.Operators;
  22559. temp.DeleteTime = "";
  22560. temp.DeleteUserId = 0;
  22561. temp.DiId = int.Parse(item.DIID);
  22562. temp.FilePath = item.FilePath;
  22563. temp.IsDel = item.IsDel;
  22564. temp.Price = item.Price;
  22565. temp.PriceCount = 1;
  22566. temp.PriceCurrency = item.Currency;
  22567. int detailId = 0;
  22568. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  22569. {
  22570. detailId = dicDetail[item.PriceTypeDetail];
  22571. }
  22572. temp.PriceDetailType = detailId;
  22573. temp.PriceDt = DateTime.Now;
  22574. temp.PriceName = item.PriceName;
  22575. temp.PriceSum = item.Price;
  22576. int tid = 0;
  22577. if (dic.ContainsKey(item.PriceType))
  22578. {
  22579. tid = dic[item.PriceType];
  22580. }
  22581. temp.PriceType = tid;
  22582. temp.Remark = item.Remark;
  22583. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  22584. }
  22585. return Ok(JsonView(true, "操作成功!"));
  22586. }
  22587. [HttpPost]
  22588. public IActionResult TimeTest()
  22589. {
  22590. var jw = JsonView(false, "error");
  22591. _sqlSugar.BeginTran();
  22592. try
  22593. {
  22594. var clientList = _sqlSugar.Queryable<Crm_NewClientData>()
  22595. .Select(x => new Crm_NewClientData
  22596. {
  22597. Id = x.Id,
  22598. Client = x.Client,
  22599. Contact = x.Contact,
  22600. Location = x.Location,
  22601. })
  22602. .ToList();
  22603. var ids = clientList.Where(x => !string.IsNullOrEmpty(x.Client) && x.Client.Contains("重庆")).Select(x => x.Id).ToList();
  22604. _sqlSugar.Queryable<Crm_NewClientData>().Where(x => ids.Contains(x.Id)).ToList();
  22605. Stopwatch stopwatch = new Stopwatch();
  22606. // 开始计时
  22607. stopwatch.Start();
  22608. foreach (var item in clientList)
  22609. {
  22610. EncryptionProcessor.DecryptProperties(item);
  22611. }
  22612. stopwatch.Stop();
  22613. jw.Code = 200;
  22614. jw.Data = stopwatch.ElapsedMilliseconds;
  22615. jw.Msg = "运算耗时: " + stopwatch.ElapsedMilliseconds + " 毫秒,解密条数: " + clientList.Count;
  22616. }
  22617. catch (Exception ex)
  22618. {
  22619. jw.Code = 400;
  22620. jw.Msg = ex.Message;
  22621. }
  22622. return Ok(jw);
  22623. }
  22624. }
  22625. }